Module: GD::GIS::Extents

Defined in:
lib/gd/gis/extents.rb

Overview

Note:

Bounding boxes are approximate and intended for visualization.

Provides access to predefined geographic extents loaded from a JSON dataset.

Extents are WGS84 bounding boxes defined as:

min_lng, min_lat, max_lng, max_lat

Supports lookup by symbolic name.

Examples:

Fetch extent

Extents.fetch(:world)

Using bracket syntax

Extents[:argentina]

Constant Summary collapse

DATA_PATH =
File.expand_path(
  "data/extents_global.json",
  __dir__
)

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



38
39
40
# File 'lib/gd/gis/extents.rb', line 38

def [](name)
  fetch(name)
end

.allObject



42
43
44
45
# File 'lib/gd/gis/extents.rb', line 42

def all
  load_data!
  @extents.keys.map(&:to_sym)
end

.fetch(name) ⇒ Object



31
32
33
34
35
36
# File 'lib/gd/gis/extents.rb', line 31

def fetch(name)
  load_data!
  @extents.fetch(name.to_s.downcase) do
    raise ArgumentError, "Unknown extent: #{name}"
  end
end