Class: BlacklightMaps::GeojsonExport

Inherits:
Object
  • Object
show all
Includes:
BlacklightMaps
Defined in:
lib/blacklight/maps/export.rb

Overview

This class provides the ability to export a response document to GeoJSON. The export is formated as a GeoJSON FeatureCollection, where the features consist of an array of Point features. For more on the GeoJSON specification see geojson.org/geojson-spec.html.

Instance Method Summary collapse

Constructor Details

#initialize(controller, action, response_docs, options = {}) ⇒ GeojsonExport

Returns a new instance of GeojsonExport.

Parameters:

  • controller (CatalogController)
  • action (Symbol)

    the controller action

  • response_docs (Array || SolrDocument)

    either:

    • index view, map view: an array of facet values

    • show view: the document object

  • options (Hash) (defaults to: {})

    optional hash of configuration options



18
19
20
21
22
23
24
# File 'lib/blacklight/maps/export.rb', line 18

def initialize(controller, action, response_docs, options = {})
  @controller = controller
  @action = action
  @response_docs = response_docs
  @options = options
  @features = []
end

Instance Method Details

#to_geojsonObject

builds the GeoJSON FeatureCollection



27
28
29
# File 'lib/blacklight/maps/export.rb', line 27

def to_geojson
  { type: 'FeatureCollection', features: build_geojson_features }.to_json
end