class Geoblacklight::BoundingBox

Transforms and parses a bounding box for various formats

Attributes

east[R]
north[R]
south[R]
west[R]

Public Class Methods

from_rectangle(rectangle) click to toggle source

Create a Geoblacklight::BoundingBox from a Solr rectangle syntax @param [String] bbox as “W S E N” @return [Geoblacklight::BoundingBox]

# File lib/geoblacklight/bounding_box.rb, line 35
def self.from_rectangle(rectangle)
  rectangle_array = rectangle.is_a?(String) ? rectangle.split : []
  message = 'Bounding box should be a string in Solr rectangle syntax e.g."W S E N"'
  fail Geoblacklight::Exceptions::WrongBoundingBoxFormat, message if rectangle_array.count != 4
  new(
    rectangle_array[0],
    rectangle_array[1],
    rectangle_array[2],
    rectangle_array[3]
  )
end
new(west, south, east, north) click to toggle source

@param [String, Integer, Float] west @param [String, Integer, Float] south @param [String, Integer, Float] east @param [String, Integer, Float] north

# 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

Public Instance Methods

to_envelope() click to toggle source

Returns a bounding box in ENVELOPE syntax @return [String]

# File lib/geoblacklight/bounding_box.rb, line 23
def to_envelope
  "ENVELOPE(#{west}, #{east}, #{north}, #{south})"
end
to_param() click to toggle source
# File lib/geoblacklight/bounding_box.rb, line 27
def to_param
  "#{west} #{south} #{east} #{north}"
end