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.
12 13 14 15 16 17 18 |
# File 'lib/geoblacklight/bounding_box.rb', line 12 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
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/geoblacklight/bounding_box.rb', line 35 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
23 24 25 |
# File 'lib/geoblacklight/bounding_box.rb', line 23 def to_envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |
#to_param ⇒ Object
27 28 29 |
# File 'lib/geoblacklight/bounding_box.rb', line 27 def to_param "#{west} #{south} #{east} #{north}" end |