lib/bplmodels/geographic_data_funcs.rb
def bbox_formatter(bbox, output_format)
        coords_array = bbox.split(' ').map(&:to_f)
        min_x = coords_array[0]
        min_y = coords_array[1]
        max_x = coords_array[2]
        max_y = coords_array[3]
        case output_format
        when 'wkt_array' # used for geojson bounding box
          if min_x > max_x
            min_x, max_x = bbox_dateline_fix(min_x, max_x)
          end
          coords_to_wkt_polygon(min_x, min_y, max_x, max_y)
        when 'wkt_envelope' # used for subject_bbox_geospatial field
          coords = normalize_bbox(min_x, min_y, max_x, max_y)
          "ENVELOPE(#{coords[0]}, #{coords[2]}, #{coords[3]}, #{coords[1]})"
        when 'wkt_polygon' # may need if we use Solr JTS for _geospatial field
          wkt_polygon = coords_to_wkt_polygon(min_x, min_y, max_x, max_y)
          wkt_order_strings = wkt_polygon.map { |coords| "#{coords[0]} #{coords[1]}" }
          "POLYGON((#{wkt_order_strings.join(', ')}))"
        else
          Rails.logger.error("UNSUPPORTED BBOX OUTPUT REQUESTED: '#{output_format}'")
        end
      end
##
# take a simple bounding box from MODS and return in various WKT type syntax
# @param bbox [String] the basic bbox string: minX minY maxX maxY
# @param output_format [String] the format to be output
# @return [String || Array] depends on output_format param
take a simple bounding box from MODS and return in various WKT type syntax
take a simple bounding box from MODS and return in various WKT type syntax
def bbox_formatter(bbox, output_format)
        coords_array = bbox.split(' ').map(&:to_f)
        min_x = coords_array[0]
        min_y = coords_array[1]
        max_x = coords_array[2]
        max_y = coords_array[3]
        case output_format
        when 'wkt_array' 
          if min_x > max_x
            min_x, max_x = bbox_dateline_fix(min_x, max_x)
          end
          coords_to_wkt_polygon(min_x, min_y, max_x, max_y)
        when 'wkt_envelope' 
          coords = normalize_bbox(min_x, min_y, max_x, max_y)
          "ENVELOPE(#{coords[0]}, #{coords[2]}, #{coords[3]}, #{coords[1]})"
        when 'wkt_polygon' 
          wkt_polygon = coords_to_wkt_polygon(min_x, min_y, max_x, max_y)
          wkt_order_strings = wkt_polygon.map { |coords| "#{coords[0]} #{coords[1]}" }
          "POLYGON((#{wkt_order_strings.join(', ')}))"
        else
          Rails.logger.error("UNSUPPORTED BBOX OUTPUT REQUESTED: '#{output_format}'")
        end
      end
def bbox_formatter ( bbox , output_format ) coords_array = bbox . split ( ' ' ) . map ( & :to_f ) min_x = coords_array [ 0 ] min_y = coords_array [ 1 ] max_x = coords_array [ 2 ] max_y = coords_array [ 3 ] case output_format when 'wkt_array' if min_x > max_x min_x , max_x = bbox_dateline_fix ( min_x , max_x ) end coords_to_wkt_polygon ( min_x , min_y , max_x , max_y ) when 'wkt_envelope' coords = normalize_bbox ( min_x , min_y , max_x , max_y ) "ENVELOPE(#{coords[0]}, #{coords[2]}, #{coords[3]}, #{coords[1]})" when 'wkt_polygon' wkt_polygon = coords_to_wkt_polygon ( min_x , min_y , max_x , max_y ) wkt_order_strings = wkt_polygon . map { | coords | "#{coords[0]} #{coords[1]}" } "POLYGON((#{wkt_order_strings.join(', ')}))" else Rails . logger . error ( "UNSUPPORTED BBOX OUTPUT REQUESTED: '#{output_format}'" ) end end
take a simple bounding box from MODS and return in various WKT type syntax
take a simple bounding box from MODS and return in various WKT type syntax
# used for geojson bounding box # used for subject_bbox_geospatial field # may need if we use Solr JTS for _geospatial field
depends on output_format param
depends on output_format param
String || Array
bbox
the basic bbox string: minX minY maxX maxY
the basic bbox string : minX minY maxX maxY
output_format
the format to be output
the format to be output