Class: CocinaDisplay::Geospatial::BoundingBoxParser
- Inherits:
-
CoordinatesParser
- Object
- CoordinatesParser
- CocinaDisplay::Geospatial::BoundingBoxParser
- Defined in:
- lib/cocina_display/geospatial.rb
Overview
Base class for bounding box parsers.
Direct Known Subclasses
Constant Summary
Constants inherited from CoordinatesParser
Class Method Summary collapse
-
.parse(input_str) ⇒ BoundingBox?
Parse the input string into a BoundingBox, or nil if parsing fails.
Methods inherited from CoordinatesParser
Class Method Details
.parse(input_str) ⇒ BoundingBox?
Parse the input string into a BoundingBox, or nil if parsing fails.
294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/cocina_display/geospatial.rb', line 294 def self.parse(input_str) matches = input_str.match(self::PATTERN) return unless matches min_lng = normalize_coord(matches[:min_lng]) max_lng = normalize_coord(matches[:max_lng]) min_lat = normalize_coord(matches[:min_lat]) max_lat = normalize_coord(matches[:max_lat]) BoundingBox.from_coords(west: min_lng, east: max_lng, north: min_lat, south: max_lat) end |