Module: CocinaDisplay::Concerns::Geospatial

Included in:
CocinaDisplay::CocinaRecord, RelatedResource
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>)


10
11
12
# File 'lib/cocina_display/concerns/geospatial.rb', line 10

def coordinates
  coordinate_subject_values.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:



28
29
30
# File 'lib/cocina_display/concerns/geospatial.rb', line 28

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:



37
38
39
# File 'lib/cocina_display/concerns/geospatial.rb', line 37

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:



19
20
21
# File 'lib/cocina_display/concerns/geospatial.rb', line 19

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


44
45
46
# File 'lib/cocina_display/concerns/geospatial.rb', line 44

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