Canonical mapping algorithm (v1)
This page is a guided restatement of the normative algorithm from the LocateTile Mapping Specification v1.
Inputs
level(non-negative integer)lat_fp,lon_fp(fixed-point signed integers)celestial_model = "wgs84_ellipsoid"
Fixed constants
SCALE = 2^32LAT_MIN = -90 × SCALELAT_MAX = +90 × SCALELON_MIN = -180 × SCALELON_MAX = +180 × SCALE(exclusive)
Validity constraints
LAT_MIN ≤ lat_fp ≤ LAT_MAXLON_MIN ≤ lon_fp < LON_MAX
Inputs outside these ranges MUST be rejected.
Grid dimensions
For a given level:
NX = 2^levelNY = 2^level
Longitude index (ix)
Define:
A_x = (lon_fp + 180 × SCALE) × NXD_x = 360 × SCALE
Compute (ix, r_x) such that:
A_x = ix × D_x + r_x0 ≤ r_x < D_x0 ≤ ix < NX
ix is the longitude tile index.
Latitude index (iy)
Define:
A_y = (lat_fp + 90 × SCALE) × NYD_y = 180 × SCALE
Compute provisional (iy_raw, r_y) such that:
A_y = iy_raw × D_y + r_y0 ≤ r_y < D_y0 ≤ iy_raw ≤ NY
North pole handling
If lat_fp == +90 × SCALE, then:
iy = NY - 1
Else:
iy = iy_raw
Output
The LocateTile identifier is:
lt:<level>:<ix>:<iy>
with:
0 ≤ ix < NX0 ≤ iy < NY
Boundary semantics (summary)
- Longitude is half-open
[-180°, +180°) - Latitude is inclusive
[-90°, +90°] - Floor semantics resolve edge cases deterministically