code wiki / _hdl_build / nx_geo.nx
nx_geo.nx
buildroot/runtime/_hdl_build/nx_geo.nx
about
nx_geo.nx -- LIB: sovereign INTEGER-EXACT geofencing primitives. The hardware-rung-up foundation
of the Nishi geo / geofencing / maps stack (operator: "superior to google or open source tools").
THE EXCEED ANGLE (measured, not asserted): coordinates are MICRODEGREES (degrees * 1e7) as i64,
and point-in-polygon is decided by INTEGER cross-multiplication -- NO floating point anywhere. So
the inside/outside verdict is EXACT and DETERMINISTIC at 1e-7 deg (~1.1 cm) resolution, with no
epsilon/robustness bugs on edges or vertices. Turf.js / Shapely / PostGIS all use float and give
non-deterministic or convention-dependent answers exactly there; the gate proves our result is
exact on the cases that break them. Overflow-safe for Earth coordinates in i64.
This is the geofence FLOOR. Geodesic distance (haversine, rides a sovereign trig rung) and the
spatial index (geohash/grid) are rungs above; both compose THIS. license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_geo_gate.nxnx_geohash_gate.nx
structs
| none |
consts
| 14 | const GEO_MAGIC_90000000: i64 = 90000000 |
| 15 | const GEO_MAGIC_180000000: i64 = 180000000 |
| 17 | const GEO_MICRO: i64 = 1000000 // microdegrees per degree (degrees * 1e6); ~0.11 m resolution. |
| 96 | const GEO_SCALE: i64 = 1000000 // fixed-point unit for lon_scale (cos(lat) * 1e6) |
functions
| 21 | func geo_bbox(minlat: i64, minlon: i64, maxlat: i64, maxlon: i64, lat: i64, lon: i64) -> i64 called by 1: geo_fence_contains |
| 31 | func geo_poly_bbox(poly: *i64, npts: i64, out: *i64) -> i64 called by 1: main |
| 57 | func geo_point_in_poly(poly: *i64, npts: i64, lat: i64, lon: i64) -> i64 |
| 86 | func geo_fence_contains(poly: *i64, npts: i64, bbox: *i64, lat: i64, lon: i64) -> i64 |
| 97 | func geo_in_radius(clat: i64, clon: i64, lon_scale: i64, r2: i64, lat: i64, lon: i64) -> i64 called by 1: main |
| 112 | func geo_geohash(lat: i64, lon: i64, prec: i64, out: *u8) -> i64 called by 1: main |
| 144 | func geo_prefix_common(a: *u8, b: *u8) -> i64 called by 1: main |