Class: BlacklightHeatmaps::BoundingBox
- Inherits:
-
Object
- Object
- BlacklightHeatmaps::BoundingBox
- Defined in:
- app/models/concerns/blacklight_heatmaps/bounding_box.rb
Overview
Used for creating and parsing bounding boxes from CQL Envelope syntax
Class Method Summary collapse
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_geojson ⇒ Object
String.
Constructor Details
#initialize(west, south, east, north) ⇒ BoundingBox
Returns a new instance of BoundingBox.
10 11 12 13 14 15 |
# File 'app/models/concerns/blacklight_heatmaps/bounding_box.rb', line 10 def initialize(west, south, east, north) @west = west.to_f @south = south.to_f @east = east.to_f @north = north.to_f end |
Class Method Details
.from_envelope(envelope) ⇒ Object
41 42 43 44 |
# File 'app/models/concerns/blacklight_heatmaps/bounding_box.rb', line 41 def self.from_envelope(envelope) envelope = envelope[/.*ENVELOPE\(([^\)]*)/,1].split(',') new(envelope[0], envelope[3], envelope[1], envelope[2]) end |
Instance Method Details
#to_envelope ⇒ String
Returns a bounding box in ENVELOPE syntax
20 21 22 |
# File 'app/models/concerns/blacklight_heatmaps/bounding_box.rb', line 20 def to_envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |
#to_geojson ⇒ Object
Returns String.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/concerns/blacklight_heatmaps/bounding_box.rb', line 26 def to_geojson { type: 'Polygon', coordinates: [ [ [west, south], [west, north], [east, north], [east, south], [west, south] ] ] }.to_json end |