Module: BlacklightHeatmaps::GeometrySolrDocument

Defined in:
app/models/concerns/blacklight_heatmaps/geometry_solr_document.rb

Overview

Provides methods to convert Solr geometry strings

Instance Method Summary collapse

Instance Method Details

#to_geojson(blacklight_config = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/concerns/blacklight_heatmaps/geometry_solr_document.rb', line 5

def to_geojson(blacklight_config = nil)
  return unless blacklight_config.try(:geometry_field) && fetch(blacklight_config.geometry_field, nil)
  {
    type: 'FeatureCollection',
    features: Array(fetch(blacklight_config.geometry_field)).map do |geometry|
      {
        type: 'Feature',
        geometry: JSON.parse(
          BlacklightHeatmaps::GeometryParser.parse(geometry).to_geojson
        ),
        properties: {}
      }
    end
  }.to_json
end