Class: Geoblacklight::BoundingBox
- Inherits:
-
Object
- Object
- Geoblacklight::BoundingBox
- Defined in:
- lib/geoblacklight/bounding_box.rb
Overview
Transforms and parses a bounding box for various formats
Class Method Summary collapse
-
.from_rectangle(rectangle) ⇒ Geoblacklight::BoundingBox
Create a Geoblacklight::BoundingBox from a Solr rectangle syntax.
Instance Method Summary collapse
-
#initialize(west, south, east, north) ⇒ BoundingBox
constructor
A new instance of BoundingBox.
-
#to_envelope ⇒ String
Returns a bounding box in ENVELOPE syntax.
Constructor Details
#initialize(west, south, east, north) ⇒ BoundingBox
Returns a new instance of BoundingBox.
10 11 12 13 14 15 16 |
# File 'lib/geoblacklight/bounding_box.rb', line 10 def initialize(west, south, east, north) @west = west @south = south @east = east @north = north # TODO: check for valid Geometry and raise if not end |
Class Method Details
.from_rectangle(rectangle) ⇒ Geoblacklight::BoundingBox
Create a Geoblacklight::BoundingBox from a Solr rectangle syntax
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/geoblacklight/bounding_box.rb', line 29 def self.from_rectangle(rectangle) rectangle_array = rectangle.split(' ') = 'Bounding box should be a string in Solr rectangle syntax e.g."W S E N"' fail Geoblacklight::Exceptions::WrongBoundingBoxFormat, if rectangle_array.count != 4 new( rectangle_array[0], rectangle_array[1], rectangle_array[2], rectangle_array[3] ) end |
Instance Method Details
#to_envelope ⇒ String
Returns a bounding box in ENVELOPE syntax
21 22 23 |
# File 'lib/geoblacklight/bounding_box.rb', line 21 def to_envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |