Class: CocinaDisplay::Geospatial::BoundingBoxParser

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

Overview

Base class for bounding box parsers.

Constant Summary

Constants inherited from CoordinatesParser

CoordinatesParser::PATTERN

Class Method Summary collapse

Methods inherited from CoordinatesParser

supports?

Class Method Details

.parse(input_str) ⇒ BoundingBox?

Parse the input string into a BoundingBox, or nil if parsing fails.

Parameters:

  • input_str (String)

Returns:



404
405
406
407
408
409
410
411
412
413
414
# File 'lib/cocina_display/geospatial.rb', line 404

def self.parse(input_str)
  matches = input_str.match(self::PATTERN)
  return unless matches

  west = normalize_coord(matches[:west])
  east = normalize_coord(matches[:east])
  south = normalize_coord(matches[:south])
  north = normalize_coord(matches[:north])

  BoundingBox.from_coords(west: west, east: east, north: north, south: south)
end