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.
- #to_param ⇒ Object
Constructor Details
#initialize(west, south, east, north) ⇒ BoundingBox
Returns a new instance of BoundingBox.
11 12 13 14 15 16 17 |
# File 'lib/geoblacklight/bounding_box.rb', line 11 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
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/geoblacklight/bounding_box.rb', line 34 def self.from_rectangle(rectangle) rectangle_array = rectangle.is_a?(String) ? 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
22 23 24 |
# File 'lib/geoblacklight/bounding_box.rb', line 22 def to_envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |
#to_param ⇒ Object
26 27 28 |
# File 'lib/geoblacklight/bounding_box.rb', line 26 def to_param "#{west} #{south} #{east} #{north}" end |