Sha256: 6f8e6e7194dfc185281872920689cb4f454b75b054a31ccb7e2d336c21f0e119
Contents?: true
Size: 1.25 KB
Versions: 30
Compression:
Stored size: 1.25 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(' ') 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 private attr_reader :west, :south, :east, :north end end
Version data entries
30 entries across 30 versions & 1 rubygems