Sha256: 843d5ee44f46906e288b8d602b58e74ba89552916913608a6d718d8181605259
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
module Geoblacklight ## # Transforms and parses a bounding box for various formats class BoundingBox ## # @param [String, Integer, Float] west # @param [String, Integer, Float] south # @param [String, Integer, Float] east # @param [String, Integer, Float] north def initialize(west, south, east, north) @west = west @south = south @east = east @north = north # TODO: check for valid Geometry and raise if not end ## # Returns a bounding box in ENVELOPE syntax # @return [String] def to_envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end ## # Create a Geoblacklight::BoundingBox from a Solr rectangle syntax # @param [String] bbox as "W S E N" # @return [Geoblacklight::BoundingBox] def self.from_rectangle(rectangle) rectangle_array = rectangle.split(' ') fail Geoblacklight::Exceptions::WrongBoundingBoxFormat, 'Bounding box should be a string in Solr rectangle syntax e.g."W S E N"' if rectangle_array.count != 4 new( rectangle_array[0], rectangle_array[1], rectangle_array[2], rectangle_array[3] ) end private attr_reader :west, :south, :east, :north end end
Version data entries
4 entries across 4 versions & 1 rubygems