Module: CocinaDisplay::Geospatial::DMSParser

Included in:
DMSBoundingBoxParser, DMSCoordinateNormalizer, DMSPointParser
Defined in:
lib/cocina_display/geospatial.rb

Overview

Mixin that adds normalization for DMS coordinates.

Defined Under Namespace

Modules: Helpers

Constant Summary collapse

DMS_PATTERN =

The degrees, minutes, and seconds of a coordinate, without a hemisphere.

/(?<deg>\d{1,3})[°⁰º]?(?:(?<min>\d{1,2})[ʹ′']?)?(?:(?<sec>\d{1,2})[ʺ"″]?)?/
POINT_PATTERN =
Note:

A trailing hemisphere cannot be followed by digits, otherwise a MARC 034 $b scale like "$b3100000W120°00′00″" would read the scale as the degrees and steal the hemisphere from the coordinate after it.

A single coordinate, with the hemisphere either leading or trailing the degrees. A hemisphere is required, so that a bare number is not read as a coordinate. Both spellings are common in MARC 034 and 255$c, and the trailing form is what Coordinates#format_point itself emits.

/(?:(?<hem>[NESW])#{DMS_PATTERN}|#{DMS_PATTERN}(?<hem>[NESW])(?!\d))/

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



380
381
382
383
# File 'lib/cocina_display/geospatial.rb', line 380

def self.included(base)
  base.const_set(:POINT_PATTERN, POINT_PATTERN)
  base.extend(Helpers)
end