Class: GeoCombine::EsriOpenData
- Inherits:
-
Object
- Object
- GeoCombine::EsriOpenData
- Includes:
- Formatting
- Defined in:
- lib/geo_combine/esri_open_data.rb
Overview
Data model for ESRI’s open data portal metadata
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#envelope ⇒ String
Builds a Solr Envelope using CQL syntax.
-
#geoblacklight_terms ⇒ Hash
Builds a Geoblacklight Schema type hash from Esri Open Data portal metadata.
-
#initialize(metadata) ⇒ EsriOpenData
constructor
Initializes an EsriOpenData object for parsing Data portal.
-
#references ⇒ String
Converts references to json.
-
#references_hash ⇒ Hash
Builds references used for dct_references.
-
#to_geoblacklight ⇒ GeoCombine::Geoblacklight
Creates and returns a Geoblacklight schema object from this metadata.
Methods included from Formatting
#remove_lines, #sanitize, #sanitize_and_remove_lines, #sluggify
Constructor Details
#initialize(metadata) ⇒ EsriOpenData
Initializes an EsriOpenData object for parsing Data portal
13 14 15 16 |
# File 'lib/geo_combine/esri_open_data.rb', line 13 def initialize() @metadata = JSON.parse() @geometry = @metadata['extent']['coordinates'] end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/geo_combine/esri_open_data.rb', line 7 def @metadata end |
Instance Method Details
#envelope ⇒ String
Builds a Solr Envelope using CQL syntax
68 69 70 |
# File 'lib/geo_combine/esri_open_data.rb', line 68 def envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |
#geoblacklight_terms ⇒ Hash
Builds a Geoblacklight Schema type hash from Esri Open Data portal metadata
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/geo_combine/esri_open_data.rb', line 29 def geoblacklight_terms { dc_identifier_s: @metadata['id'], dc_title_s: @metadata['name'], dc_description_s: sanitize_and_remove_lines(@metadata['description']), dc_rights_s: 'Public', dct_provenance_s: @metadata['owner'], dct_references_s: references, # layer_id_s is used for describing a layer id for a web serivce (WMS, WFS) but is still a required field layer_id_s: '', layer_geom_type_s: @metadata['geometry_type'], layer_modified_dt: @metadata['updated_at'], layer_slug_s: @metadata['id'], solr_geom: envelope, # solr_year_i: '', No equivalent in Esri Open Data metadata dc_subject_sm: @metadata['tags'] } end |
#references ⇒ String
Converts references to json
51 52 53 |
# File 'lib/geo_combine/esri_open_data.rb', line 51 def references references_hash.to_json end |
#references_hash ⇒ Hash
Builds references used for dct_references
58 59 60 61 62 63 |
# File 'lib/geo_combine/esri_open_data.rb', line 58 def references_hash { 'http://schema.org/url' => @metadata['landing_page'], 'http://resources.arcgis.com/en/help/arcgis-rest-api' => @metadata['url'] } end |
#to_geoblacklight ⇒ GeoCombine::Geoblacklight
Creates and returns a Geoblacklight schema object from this metadata
21 22 23 |
# File 'lib/geo_combine/esri_open_data.rb', line 21 def to_geoblacklight GeoCombine::Geoblacklight.new(geoblacklight_terms.to_json) end |