class GeoCombine::EsriOpenData

Data model for ESRI's open data portal metadata

Attributes

metadata[R]

Public Class Methods

new(metadata) click to toggle source

Initializes an EsriOpenData object for parsing @param [String] metadata a valid serialized JSON string from an ESRI Open Data portal

# File lib/geo_combine/esri_open_data.rb, line 11
def initialize(metadata)
  @metadata = JSON.parse(metadata)
  @geometry = @metadata['extent']['coordinates']
end

Public Instance Methods

envelope() click to toggle source

Builds a Solr Envelope using CQL syntax @return [String]

# File lib/geo_combine/esri_open_data.rb, line 66
def envelope
  "ENVELOPE(#{west}, #{east}, #{north}, #{south})"
end
geoblacklight_terms() click to toggle source

Builds a Geoblacklight Schema type hash from Esri Open Data portal metadata @return [Hash]

# File lib/geo_combine/esri_open_data.rb, line 27
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() click to toggle source

Converts references to json @return [String]

# File lib/geo_combine/esri_open_data.rb, line 49
def references
  references_hash.to_json
end
references_hash() click to toggle source

Builds references used for dct_references @return [Hash]

# File lib/geo_combine/esri_open_data.rb, line 56
def references_hash
  {
    'http://schema.org/url' => @metadata['landing_page'],
    'http://resources.arcgis.com/en/help/arcgis-rest-api' => @metadata['url']
  }
end
to_geoblacklight() click to toggle source

Creates and returns a Geoblacklight schema object from this metadata @return [GeoCombine::Geoblacklight]

# File lib/geo_combine/esri_open_data.rb, line 19
def to_geoblacklight
  GeoCombine::Geoblacklight.new(geoblacklight_terms.to_json)
end

Private Instance Methods

east() click to toggle source
# File lib/geo_combine/esri_open_data.rb, line 80
def east
  @geometry[1][0]
end
north() click to toggle source
# File lib/geo_combine/esri_open_data.rb, line 72
def north
  @geometry[1][1]
end
south() click to toggle source
# File lib/geo_combine/esri_open_data.rb, line 76
def south
  @geometry[0][1]
end
west() click to toggle source
# File lib/geo_combine/esri_open_data.rb, line 84
def west
  @geometry[0][0]
end