Hi, Using georuby, how would you determine if a given point is within a given bounding box? require 'geo_ruby' denver = GeoRuby::SimpleFeatures::Point.from_x_y(-105.0, 39.7188) seattle = GeoRuby::SimpleFeatures::Point.from_x_y(-122.23, 47.547) boise = GeoRuby::SimpleFeatures::Point.from_x_y(-116.06, 43.53) kcity = GeoRuby::SimpleFeatures::Point.from_x_y(-94.42, 38.94) Using the above examples, I would expect boise to be in a bounding box between denver and seattle, but not kansas city. In theory I'd like to be able to do something like this: ls = GeoRuby::SimpleFeatures::LineString.from_points([seattle, denver], 4326) ls.include?(boise) # => true ls.include?(kcity) # => false I poked around the API a bit, but didn't see how to do that. Any suggestions? Regards, Dan
on 2010-09-01 22:14
on 2010-09-02 05:40
On Sep 1, 2:14 pm, Daniel Berger <djber...@gmail.com> wrote: > Using georuby, how would you determine if a given point is within a > given bounding box? I've never used GeoRuby, but looking at the implementation of bounding_box for various classes, how about: # untested class GeoRuby::SimpleFeatures::Geometry def point_in_bounds?( point ) min, max = bounding_box point.x >= min.x && point.x <= max.x && point.y >= min.y && point.y <= max.y && min.z && point.z >= min.z && point.z <= max.z end end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.