Class: CocinaDisplay::Geospatial::CoordinateNormalizer

Inherits:
CoordinatesParser show all
Defined in:
lib/cocina_display/geospatial.rb

Overview

Base class for normalizers that standardize a single coordinate value, as found in Cocina structured values, so that Geo::Coord can parse it. Subclasses define a PATTERN and mix in a parser module for normalize_coord.

Constant Summary

Constants inherited from CoordinatesParser

CocinaDisplay::Geospatial::CoordinatesParser::PATTERN

Class Method Summary collapse

Methods inherited from CoordinatesParser

supports?

Class Method Details

.hemisphere_first(value) ⇒ String

Move a trailing hemisphere letter to the front, since that is where the parser normalizers expect it.

Examples:

"121.5W" becomes "W121.5"

Parameters:

  • value (String)

Returns:

  • (String)


426
427
428
# File 'lib/cocina_display/geospatial.rb', line 426

def self.hemisphere_first(value)
  value.sub(/\A(.+?)([NESW])\z/, '\2\1')
end