ambit (ambit v1.0.0)

View Source

Ambit - Icosahedral Gnomonic Aperture 4 Triangle Grid

A hierarchical Discrete Global Grid System (DGGS) that tiles the sphere with triangles.

Model

The Earth is modeled as an icosahedron (20 faces) projected to the sphere. Each face is gnomonically projected to a 2D plane and recursively subdivided with aperture 4: each triangle splits into 4 children (3 corner + 1 central inverted).

A code is <<FaceBase20, "-", Digits/binary>> where FaceBase20 is 0..J (0-19 in base-20) and each digit 0..3 is a child index. Resolution is byte_size(Digits), 0..24.

Summary

Types

bounds()

-type bounds() :: {MinLat :: number(), MinLon :: number(), MaxLat :: number(), MaxLon :: number()}.

code()

-type code() :: <<_:16, _:_*8>>.

disk_mode()

-type disk_mode() :: corner | centroid.

lat()

-type lat() :: float().

latlon()

-type latlon() :: {lat(), lon()}.

lon()

-type lon() :: float().

meters()

-type meters() :: number().

resolution()

-type resolution() :: 0..24.

triangle()

-type triangle() :: {latlon(), latlon(), latlon()}.

xyz()

-type xyz() :: {float(), float(), float()}.

Functions

bounds(Bounds, Level)

-spec bounds(Bounds :: bounds(), Level :: resolution()) -> [code()].

bounds(Bounds, Res, Mode)

cell_geometry(Code)

-spec cell_geometry(code()) -> triangle().

coarsen/2

-spec coarsen(code(), resolution()) -> code().

decode(Code)

-spec decode(code()) -> latlon().

disk/2

-spec disk(code() | latlon(), meters()) -> [code()].

disk/3

-spec disk(code() | latlon(), resolution(), meters()) -> [code()].

disk/4

-spec disk(latlon(), resolution(), meters(), disk_mode()) -> [code()].

disk_center/1

-spec disk_center({Lat :: float(), Lon :: float()}) -> {float(), float()}.

encode(Coord)

-spec encode(latlon()) -> code().

encode/2

-spec encode(latlon(), resolution()) -> code().

from_xyz/1

-spec from_xyz(xyz()) -> latlon().

neighbors(Code)

neighbors_2(Code)

optimal_level(DiameterMeters)

-spec optimal_level(DiameterMeters :: number()) -> 1..24.

orthocenter(Code)

-spec orthocenter(code()) -> latlon().

parent/1

-spec parent(code()) -> code().

resolution(Code)

-spec resolution(code()) -> resolution().

shape(GeoJSON, Res)

-spec shape(GeoJSON :: map(), Res :: resolution()) -> [code()].

shape(GeoJSON, Res, Mode)

-spec shape(GeoJSON :: map(), Res :: pos_integer(), Mode :: disk_mode()) -> [binary()].