Skip to main content

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^32
  • LAT_MIN = -90 × SCALE
  • LAT_MAX = +90 × SCALE
  • LON_MIN = -180 × SCALE
  • LON_MAX = +180 × SCALE (exclusive)

Validity constraints

  • LAT_MIN ≤ lat_fp ≤ LAT_MAX
  • LON_MIN ≤ lon_fp < LON_MAX

Inputs outside these ranges MUST be rejected.

Grid dimensions

For a given level:

  • NX = 2^level
  • NY = 2^level

Longitude index (ix)

Define:

  • A_x = (lon_fp + 180 × SCALE) × NX
  • D_x = 360 × SCALE

Compute (ix, r_x) such that:

  • A_x = ix × D_x + r_x
  • 0 ≤ r_x < D_x
  • 0 ≤ ix < NX

ix is the longitude tile index.

Latitude index (iy)

Define:

  • A_y = (lat_fp + 90 × SCALE) × NY
  • D_y = 180 × SCALE

Compute provisional (iy_raw, r_y) such that:

  • A_y = iy_raw × D_y + r_y
  • 0 ≤ r_y < D_y
  • 0 ≤ 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 < NX
  • 0 ≤ iy < NY

Boundary semantics (summary)

  • Longitude is half-open [-180°, +180°)
  • Latitude is inclusive [-90°, +90°]
  • Floor semantics resolve edge cases deterministically