code wiki / _hdl_build / nx_geo_area.nx
nx_geo_area.nx
buildroot/runtime/_hdl_build/nx_geo_area.nx
about
nx_geo_area.nx -- LIB: GEO-010 polygon AREA + ORIENTATION, INTEGER-EXACT (shoelace / Gauss).
THE EXCEED ANGLE (measured, not asserted): the area is the shoelace sum of INTEGER cross products
over microdegree coordinates -- ZERO floating point. So both the doubled-area magnitude AND the
orientation (its sign) are EXACT and DETERMINISTIC, and collinear / degenerate vertices contribute
EXACTLY 0. Those are precisely the cases where Turf.js / Shapely / PostGIS (all float) accumulate
epsilon error or flip orientation. Resolution is 1 microdegree (~0.11 m); a 1-microdegree apex
yields its exact area, not noise.
Convention (matches nx_geo): poly = flat [lat0,lon0, lat1,lon1, ...], npts vertices, implicitly
closed (last->first); lat = Y, lon = X. The result is the DOUBLED (un-halved) area in microdegree^2
(deg^2 * 1e12) so it stays a pure integer -- halving is the caller's choice and exact when the
doubled value is even. Overflow-safe for Earth coords in i64 (|lon*lat| <= 1.8e8 * 9e7 = 1.6e16;
the sum of hundreds of such terms fits in i64's 9.2e18).
Foundation rung: the area-weighted CENTROID and polygon clipping/union compose THIS. license_tier: ORIGINAL
dependencies 1 imports · 5 importers
imports: nx_syscalls.nx
imported by: nx_geo_area_gate.nxnx_geo_buffer.nxnx_geo_clip_gate.nxnx_geo_hull_gate.nxnx_geo_union.nx
structs
| none |
consts
| none |
functions
| 22 | func geo_signed_area2(poly: *i64, npts: i64) -> i64 |
| 39 | func geo_area2(poly: *i64, npts: i64) -> i64 called by 6: geo_buffer_area2mainmaingeo_inter_area2geo_union_area2geo_iou_permil calls 1: geo_signed_area2 |
| 47 | func geo_orientation(poly: *i64, npts: i64) -> i64 |