Class: GeoRuby::SimpleFeatures::Envelope
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::Envelope
- Defined in:
- lib/georuby-ext/georuby/envelope.rb
Class Method Summary collapse
Instance Method Summary collapse
- #contains_point?(point) ⇒ Boolean (also: #contains?)
- #overlaps?(bound) ⇒ Boolean
- #sql_box ⇒ Object (also: #to_sql)
- #to_google ⇒ Object
- #to_openlayers ⇒ Object
- #to_polygon ⇒ Object
- #to_rgeo ⇒ Object
Class Method Details
Instance Method Details
#contains_point?(point) ⇒ Boolean Also known as: contains?
3 4 5 6 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 3 def contains_point?(point) (lower_corner.x...upper_corner.x).include?(point.x) and (lower_corner.y...upper_corner.y).include?(point.y) end |
#overlaps?(bound) ⇒ Boolean
8 9 10 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 8 def overlaps?(bound) contains_point?(bound.upper_corner) or contains_point?(bound.lower_corner) or bound.contains_point?(upper_corner) or bound.contains_point?(lower_corner) end |
#sql_box ⇒ Object Also known as: to_sql
22 23 24 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 22 def sql_box "SetSRID('BOX3D(#{upper_corner.lng} #{upper_corner.lat}, #{lower_corner.lng} #{lower_corner.lat})'::box3d, #{srid})" end |
#to_google ⇒ Object
32 33 34 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 32 def to_google GeoRuby::SimpleFeatures::Envelope.from_points [lower_corner.to_google, upper_corner.to_google], 900913, with_z end |
#to_openlayers ⇒ Object
28 29 30 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 28 def to_openlayers OpenLayers::Bounds.new lower_corner.x, lower_corner.y, upper_corner.x, upper_corner.y end |
#to_polygon ⇒ Object
36 37 38 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 36 def to_polygon GeoRuby::SimpleFeatures::Polygon.from_coordinates( [ [ [lower_corner.x, lower_corner.y], [lower_corner.x, upper_corner.y], [upper_corner.x, upper_corner.y], [upper_corner.x, lower_corner.y] ] ] ) end |
#to_rgeo ⇒ Object
40 41 42 |
# File 'lib/georuby-ext/georuby/envelope.rb', line 40 def to_rgeo self.to_polygon.to_rgeo end |