code wiki / _hdl_build / nx_geo_hilbert.nx

nx_geo_hilbert.nx

buildroot/runtime/_hdl_build/nx_geo_hilbert.nx

6078 B143 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_hilbert.nx -- GEO-005: Hilbert space-filling-curve cell ordering, the S2/H3 superiority target. The geohash (GEO-002) interleaves lon/lat bits = a Z-ORDER (Morton) curve, which has BOUNDARY DISCONTINUITIES: consecutive indices can map to cells far apart (a jump at every quadrant seam), so a range-scan over an index window can miss/overshoot spatially-near cells. The Hilbert curve's DEFINING PROPERTY: consecutive indices are ALWAYS spatially adjacent (Manhattan distance exactly 1) -- no discontinuities. PURE-INTEGER (division/modulo, NO bitwise -- the geohash's no-float discipline + dodges the shift/or miscompile landmine), exact + deterministic. A grid of n=2^order cells per axis maps bijectively to [0, n*n) Hilbert indices. EXCEED is MEASURED, not asserted: hilbert_max_jump==1 vs zorder_max_jump>1 on the SAME grid.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_geo_hilbert.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap hil_d2xy hil_rot hil_xy2d sys_mmap ↻ hil_rot ↻ gh_abs mort_z2xy gh_w sys_write gh_n sys_mmap ↻ sys_write ↻ sys_openat_append sys_close sys_exit

structs

none

consts

none

functions

12func gh_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
13func gh_n(fd: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
19func gh_abs(a: i64) -> i64 { if a < 0 { return 0 - a } return a }
called by 1: main
21func hil_rot(size: i64, xb: *i64, yb: *i64, rx: i64, ry: i64) -> i64
called by 2: hil_xy2dhil_d2xy
29func hil_xy2d(n: i64, x: i64, y: i64) -> i64
called by 1: main calls 2: sys_mmaphil_rot
49func hil_d2xy(n: i64, d: i64, xb: *i64, yb: *i64) -> i64
called by 1: main calls 1: hil_rot
65func mort_z2xy(z: i64, order: i64, xb: *i64, yb: *i64) -> i64
called by 1: main
81func main(argc: i64, argv: *i64) -> i64