module NaturalEarth::Geometries

Constants

COUNTRY_PATH
SUBDIVISION_PATH

Public Class Methods

country(iso3166) click to toggle source
# File lib/natural_earth/geometries.rb, line 14
def country(iso3166)
  raise KeyError unless Countries.supported?(iso3166)

  load(path(COUNTRY_PATH, iso3166_1: as_iso3166_1(iso3166)))
end
subdivision(iso3166) click to toggle source
# File lib/natural_earth/geometries.rb, line 20
def subdivision(iso3166)
  raise KeyError unless Subdivisions.supported?(iso3166)

  load(path(SUBDIVISION_PATH, iso3166_1: as_iso3166_1(iso3166), iso3166_2: as_iso3166_2(iso3166)))
end

Protected Class Methods

load(file_path) click to toggle source
# File lib/natural_earth/geometries.rb, line 32
def load(file_path)
  raise ArgumentError unless File.exist?(file_path)
  raise ArgumentError unless File.readable?(file_path)

  RGeo::GeoJSON.decode(MultiJson.load(File.read(file_path)))
end
path(pattern, args = {}) click to toggle source
# File lib/natural_earth/geometries.rb, line 28
def path(pattern, args = {})
  File.join(NaturalEarth::RESOURCES_DIR, format(pattern, **args))
end