module OceanNames
Constants
- GET_POINTS
drill down to main geometry points array
- VERSION
- WITHIN_BOUNDS
check bounds to avoid
Public Class Methods
data()
click to toggle source
# File lib/ocean_names.rb, line 47 def self.data @data ||= Oj.load(File.read(file)) end
file()
click to toggle source
# File lib/ocean_names.rb, line 43 def self.file File.expand_path("../data/water.json", File.dirname(__FILE__)) end
reverse_geocode(lat:, lng:)
click to toggle source
# File lib/ocean_names.rb, line 25 def self.reverse_geocode(lat:, lng:) rec = data.find do |record| # avoid check of obviously false geometries next unless WITHIN_BOUNDS.(record, lng, lat) record["geometry"].any? do |geometry| # get points from nested arrays points = GET_POINTS.(geometry) polygon = OceanNames::Polygon.new(points) polygon.contains?(lat: lat, lng: lng) end end rec&.reject do |key| key == "geometry" end end