code wiki / _hdl_build / nx_geo_simplify.nx

nx_geo_simplify.nx

buildroot/runtime/_hdl_build/nx_geo_simplify.nx

3290 B90 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_simplify.nx -- LIB: GEO-014 LINE SIMPLIFY (Douglas-Peucker), DETERMINISTIC INTEGER ARITH. THE EXCEED ANGLE (measured, not asserted): the perpendicular distance of a point to a segment is computed as |cross| / isqrt(|AB|^2) using INTEGER cross products + nx_isqrt -- ZERO floating point. So the keep/drop decision against the tolerance is DETERMINISTIC and reproducible to the bit, where Turf.js / Mapbox simplify (float) can keep or drop a near-tolerance vertex differently across platforms. (We divide rather than compare cross^2 vs eps^2*ab^2 because cross^2 overflows i64 at Earth scale; |cross| <= ~2.6e17 and ab2 <= ~2.6e17 both fit, so the integer divide is overflow-safe.) Convention (matches nx_geo): pts = flat [lat0,lon0, ...], n points, lat=Y, lon=X. Writes the kept vertex INDICES (in order, endpoints always kept) to out_idx; returns the simplified count. Iterative (explicit stack, no recursion). license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_isqrt.nx nx_syscalls.nx nx_geo_simplify.nx nx_geo_simplify_gate.nx

imports: nx_isqrt.nxnx_syscalls.nx

imported by: nx_geo_simplify_gate.nx

structs

none

consts

none

functions

16func geo_iabs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
called by 1: geo_perp_dist_idx
19func geo_perp_dist_idx(pts: *i64, a: i64, b: i64, p: i64) -> i64
called by 1: geo_simplify calls 2: nx_isqrtgeo_iabs
44func geo_simplify(pts: *i64, n: i64, eps: i64, out_idx: *i64) -> i64
called by 1: main calls 2: sys_mmapgeo_perp_dist_idx