Class: BlacklightMaps::GeojsonExport
- Inherits:
-
Object
- Object
- BlacklightMaps::GeojsonExport
- 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
-
#initialize(controller, action, response_docs, options = {}) ⇒ GeojsonExport
constructor
controller is a Blacklight CatalogController object passed by a helper action is the controller action response_docs is passed by a helper, and is either: - index view, map view: an array of facet values - show view: the document object options is an optional hash of possible configuration options.
-
#to_geojson ⇒ Object
build the GeoJSON FeatureCollection.
Constructor Details
#initialize(controller, action, response_docs, options = {}) ⇒ GeojsonExport
controller is a Blacklight CatalogController object passed by a helper action is the controller action response_docs is passed by a helper, and is either:
- index view, map view: an array of facet values
- show view: the document object
options is an optional hash of possible configuration options
17 18 19 20 21 22 |
# File 'lib/blacklight/maps/export.rb', line 17 def initialize(controller, action, response_docs, ={}) @controller = controller @action = action @response_docs = response_docs @options = end |
Instance Method Details
#to_geojson ⇒ Object
build the GeoJSON FeatureCollection
25 26 27 28 29 |
# File 'lib/blacklight/maps/export.rb', line 25 def to_geojson geojson_docs = { type: 'FeatureCollection', features: build_geojson_features } geojson_docs.to_json end |