module SearchSolrTools::Helpers::TranslateSpatialCoverage
Methods to translate list of geoJson objects to solr format values
Public Class Methods
convert_multipoint_to_point(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 19 def self.convert_multipoint_to_point(spatial_coverage_geom) return_geom = [] spatial_coverage_geom.each do |geom| if geom.geometry_type.to_s.downcase.eql?('multipoint') geom.each do |point| return_geom << point end else return_geom << geom end end return_geom end
geojson_to_global_facet(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 59 def self.geojson_to_global_facet(spatial_coverage_geom) return nil if spatial_coverage_geom.nil? spatial_coverage_geom.each do |geo_json| bbox_hash = BoundingBoxUtil.bounding_box_hash_from_geo_json(geo_json) return 'Show Global Only' if BoundingBoxUtil.box_global?(bbox_hash) end nil end
geojson_to_spatial_area(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 45 def self.geojson_to_spatial_area(spatial_coverage_geom) spatial_areas = spatial_coverage_geom.map do |geo_json| if %w[point].include?(geo_json.geometry_type.to_s.downcase) 0.0 else bbox = RGeo::Cartesian::BoundingBox.create_from_geometry(geo_json) bbox.max_y - bbox.min_y end end return nil if spatial_areas.empty? spatial_areas.max end
geojson_to_spatial_display_str(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 11 def self.geojson_to_spatial_display_str(spatial_coverage_geom) spatial_coverage_geom = convert_multipoint_to_point(spatial_coverage_geom) spatial_coverage_geom.map do |geom| bbox = RGeo::Cartesian::BoundingBox.create_from_geometry(geom) "#{bbox.min_y} #{bbox.min_x} #{bbox.max_y} #{bbox.max_x}" end end
geojson_to_spatial_index_str(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 33 def self.geojson_to_spatial_index_str(spatial_coverage_geom) spatial_coverage_geom = convert_multipoint_to_point(spatial_coverage_geom) spatial_coverage_geom.map do |geo_json| if geo_json.geometry_type.to_s.downcase.eql?('point') "#{geo_json.x} #{geo_json.y}" else bbox = RGeo::Cartesian::BoundingBox.create_from_geometry(geo_json) "ENVELOPE(#{bbox.min_x}, #{bbox.max_x}, #{bbox.max_y}, #{bbox.min_y})" end end end
geojson_to_spatial_scope_facet(spatial_coverage_geom)
click to toggle source
# File lib/search_solr_tools/helpers/translate_spatial_coverage.rb, line 69 def self.geojson_to_spatial_scope_facet(spatial_coverage_geom) return if spatial_coverage_geom.nil? spatial_coverage_geom.map do |geo_json| bbox_hash = BoundingBoxUtil.bounding_box_hash_from_geo_json(geo_json) scope = SolrFormat.get_spatial_scope_facet_with_bounding_box(bbox_hash) scope unless scope.nil? end.uniq end