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

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)


75
76
77
# File 'lib/geo_combine/esri_open_data.rb', line 75

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
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_boxString

Builds a GeoRSS box

Returns:

  • (String)


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

def georss_box
  "#{south} #{west} #{north} #{east}"
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



19
20
21
# File 'lib/geo_combine/esri_open_data.rb', line 19

def to_geoblacklight
  GeoCombine::Geoblacklight.new(geoblacklight_terms.to_json)
end