Class: GeoCombine::EsriOpenData

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

Parameters:

  • metadata (String)

    a valid serialized JSON string from an ESRI Open



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

#metadataObject (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

#envelopeString

Builds a Solr Envelope using CQL syntax

Returns:

  • (String)


68
69
70
# File 'lib/geo_combine/esri_open_data.rb', line 68

def envelope
  "ENVELOPE(#{west}, #{east}, #{north}, #{south})"
end

#geoblacklight_termsHash

Builds a Geoblacklight Schema type hash from Esri Open Data portal metadata

Returns:

  • (Hash)


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

#referencesString

Converts references to json

Returns:

  • (String)


51
52
53
# File 'lib/geo_combine/esri_open_data.rb', line 51

def references
  references_hash.to_json
end

#references_hashHash

Builds references used for dct_references

Returns:

  • (Hash)


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_geoblacklightGeoCombine::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