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



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

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

#envelopeString

Builds a Solr Envelope using CQL syntax

Returns:

  • (String)


66
67
68
# File 'lib/geo_combine/esri_open_data.rb', line 66

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

#geoblacklight_termsHash

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

Returns:

  • (Hash)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

#referencesString

Converts references to json

Returns:

  • (String)


49
50
51
# File 'lib/geo_combine/esri_open_data.rb', line 49

def references
  references_hash.to_json
end

#references_hashHash

Builds references used for dct_references

Returns:

  • (Hash)


56
57
58
59
60
61
# 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_geoblacklightGeoCombine::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