code wiki / _hdl_build / nx_geo_webmerc.nx

nx_geo_webmerc.nx

buildroot/runtime/_hdl_build/nx_geo_webmerc.nx

2530 B52 linesdepth 4pulls 4 transitivereach 1 importersview sourcekind librarytopic geo
docsdependenciesstructsconstsfunctions

about

nx_geo_webmerc.nx -- LIB: GEO-019b WEB-MERCATOR (EPSG:3857) slippy z/x/y tiles -- the web de-facto standard (OSM/Google/Mapbox tile numbering). Hardening of GEO-019 (which is the geodetic grid). xtile = floor((lon+180) / 360 * 2^z) (linear, same as geodetic) ytile = floor((1 - asinh(tan(lat)) / pi) / 2 * 2^z) (the Mercator projection) with asinh(tan(lat)) = ln(tan(pi/4 + lat/2)) computed sovereignly via fx.nx CORDIC sin/cos + fx_log2 (ln x = log2 x * ln2). All Q16.16 fixed point -> deterministic; no float, no proj4, no API. This is last-mile interop (matching the worldwide web tile standard) per the ecosystem-only law -- the projection itself is sovereign. Valid for |lat| < ~85.05 deg (the Mercator cutoff); beyond that tan -> inf and we clamp. Convention: lat/lon microdegrees; out2 = [xtile, ytile]. license_tier: ORIGINAL

dependencies 2 imports · 1 importers

fx.nx nx_syscalls.nx nx_geo_webmerc.nx nx_geo_webmerc_gate.nx

imports: fx.nxnx_syscalls.nx

imported by: nx_geo_webmerc_gate.nx

structs

none

consts

14const MERC_MAGIC_180000000: i64 = 180000000
15const MERC_MAGIC_360000000: i64 = 360000000
17const MERC_LN2: i64 = 45426 // round(ln(2) * 65536) -- converts log2 -> ln in Q16.16

functions

19func geo_webmerc_pow2(z: i64) -> i64 { var n: i64 = 1; var t: i64 = 0; while t < z { n = n * 2; t = t + 1 } return n }
called by 1: geo_webmerc_tile
22func geo_webmerc_tile(z: i64, lat: i64, lon: i64, out2: *i64) -> i64