Module: CocinaDisplay::Concerns::Geospatial

Included in:
CocinaDisplay::CocinaRecord
Defined in:
lib/cocina_display/concerns/geospatial.rb

Overview

Methods for extracting geospatial metadata, such as coordinates.

Instance Method Summary collapse

Instance Method Details

#coordinatesArray<String>

All coordinate data as DMS format strings.

Examples:

“34°03′08″N 118°14′37″W”

Returns:

  • (Array<String>)


12
13
14
# File 'lib/cocina_display/concerns/geospatial.rb', line 12

def coordinates
  coordinate_subjects.map(&:to_s).compact.uniq
end

#coordinates_as_envelopeArray<String>

Note:

Points are not included since they can’t be represented as a box.

All valid coordinate data formatted for indexing into a Solr BBoxField.

Examples:

“ENVELOPE(-118.2437, -117.9522, 34.1996, 34.0522)”

Returns:

  • (Array<String>)

See Also:



30
31
32
# File 'lib/cocina_display/concerns/geospatial.rb', line 30

def coordinates_as_envelope
  coordinate_objects.map(&:as_envelope).compact.uniq
end

#coordinates_as_pointArray<String>

Note:

Bounding boxes are automatically converted to their center point.

All valid coordinate data formatted for indexing into a Solr LatLon field.

Examples:

“34.0522,-118.2437”

Returns:

  • (Array<String>)

See Also:



39
40
41
# File 'lib/cocina_display/concerns/geospatial.rb', line 39

def coordinates_as_point
  coordinate_objects.map(&:as_point).uniq
end

#coordinates_as_wktArray<String>

Note:

This type of field accommodates both points and bounding boxes.

All valid coordinate data formatted for indexing into a Solr RPT field.

Examples:

“POINT(34.0522 -118.2437)”, “POLYGON((-118.2437 34.0522, -118.2437 34.1996, -117.9522 34.1996, -117.9522 34.0522, -118.2437 34.0522))”

Returns:

  • (Array<String>)

See Also:



21
22
23
# File 'lib/cocina_display/concerns/geospatial.rb', line 21

def coordinates_as_wkt
  coordinate_objects.map(&:as_wkt).uniq
end

#geonames_idsArray<String>

Identifiers assigned by geonames.org for places related to the object.

Examples:

“6252001”, “5368361”

Returns:

  • (Array<String>)


46
47
48
# File 'lib/cocina_display/concerns/geospatial.rb', line 46

def geonames_ids
  place_subject_values.map { |s| s.geonames_id }.compact.uniq
end