Expand description
The fixed lookup grid.
Longitude and latitude are each mapped onto 16 bits and interleaved into a 32-bit Z-order key, so that a quadtree cell at any depth is one contiguous range of keys and a lookup is a single indexed query.
Every operation here has an exact counterpart in the Python builder
(tools/regiondb-build/src/regiondb_build/morton.py). Both are written as
the same two floating-point operations rather than in whichever idiom each
language finds natural, because a position that lands in different cells on
different platforms would be a lookup that disagrees with itself.
Enums§
- Morton
Error - A coordinate that cannot be placed on the grid.
Constants§
- GRID
- Cells per axis at maximum depth.
- MAX_
DEPTH - Depth of the grid: 16 bits per axis, so cells are roughly 600 m by 300 m at the equator.
Functions§
- cell_xy
- Grid coordinates of the cell containing a position.
- check_
latitude - Validate latitude, which is clamped into the grid rather than wrapped.
- interleave
- Interleave two 16-bit values,
xinto the even bits. - key
- The maximum-depth Morton key for a position.
- normalize_
longitude - Wrap longitude into
[-180, 180).