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.
-
#georss_box ⇒ String
Builds a GeoRSS box.
-
#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
Constructor Details
#initialize(metadata) ⇒ EsriOpenData
Initializes an EsriOpenData object for parsing Data portal
11 12 13 14 |
# File 'lib/geo_combine/esri_open_data.rb', line 11 def initialize() @metadata = JSON.parse() @geometry = @metadata['extent']['coordinates'] end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/geo_combine/esri_open_data.rb', line 5 def @metadata end |
Instance Method Details
#envelope ⇒ String
Builds a Solr Envelope using CQL syntax
75 76 77 |
# File 'lib/geo_combine/esri_open_data.rb', line 75 def envelope "ENVELOPE(#{west}, #{east}, #{north}, #{south})" end |
#geoblacklight_terms ⇒ Hash
Builds a Geoblacklight Schema type hash from Esri Open Data portal metadata
27 28 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 27 def geoblacklight_terms { uuid: @metadata['id'], 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, georss_box_s: georss_box, # 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 |
#georss_box ⇒ String
Builds a GeoRSS box
68 69 70 |
# File 'lib/geo_combine/esri_open_data.rb', line 68 def georss_box "#{south} #{west} #{north} #{east}" 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
19 20 21 |
# File 'lib/geo_combine/esri_open_data.rb', line 19 def to_geoblacklight GeoCombine::Geoblacklight.new(geoblacklight_terms.to_json) end |