Repository navigation
Description
Context
The UTM zone projections (EPSG:32601–32660 / 32701–32760, PR #241) currently use the standard Snyder transverse Mercator series (Map Projections — A Working Manual, USGS PP 1395). Round trips were verified at ≤ 1.06e-8 degrees (~1.2 mm) worst case over 252 sample points — good within a zone, but the accuracy of the truncated series degrades quickly beyond ~±3 degrees from the central meridian.
PROJ uses Karney's algorithm instead, which is not confined to the zone: it stays sub-micrometer-accurate essentially anywhere on the ellipsoid and has guaranteed convergence. For libraries serving users with high standards, that is the algorithm to converge to.
Goal
Replace UtmDefinition.forward / UtmDefinition.inverse with Karney's transverse Mercator:
- Reference: C. F. F. Karney, "Transverse Mercator with an accuracy of a few nanometers" (arXiv 1009.3588) — 6th-order coefficients; GeographicLib's MIT-licensed C++ is the reference implementation. Do not depend on or copy the vendored code — implement from the paper.
- No API change: drop-in swap under the internal
ProjectionDefinitioncontract - Both directions (forward + iterative inverse with the standard TM Newton solve)
Verification discipline (as used in phases 3/5)
- Independent Python implementation first, validated against Karney's published test values, with explicit sign checks — the errors we made in earlier phases came from skipping exactly this step
- Round-trip sweep across all zones and latitudes with an expected worst error < 1 micrometer, compared against the Snyder baseline to quantify where both diverge
- Port only after the numbers agree
Behavior changes to acknowledge (sub-millimeter)
- Snyder vs. Karney disagree at the sub-millimeter level in-zone: the "known reference values" in
UtmAlgorithmTests(e.g. easting 331792.115 m in zone 19N) are Snyder-based and will shift at mm scale. The test tolerance (0.001 m) sits exactly at the crossover — expected values must be re-derived and verified under Karney, not silently widened. - This is a documented, sub-millimeter accuracy improvement; call it out for downstream users in the PR body rather than burying it in the diff.
Performance
Expect ~1.5–2x the float ops per projection (Snyder ~300 ns/op full path in our release benchmarks; Karney probably +100 ns). Benchmark numbers before/after in the PR. Negligible for existing users; only matters if bulk reprojection of point clouds ever lands.
Sequencing
After the #242/#245 chain lands (touches only UtmDefinition.swift), so UtmDefinition isn't rebased mid-flight; composes with any future TM-family CRS (Gauss-Kruger, State Plane TM), which can reuse the same code path.
Related
- Support CRSs on other datums (NAD27, OSGB, CH1903+, ...) #243 (other datums) is unaffected, but the same verification discipline applies there
Activity
Add pan-European and national CRSs: LAEA/LCC Europe, Lambert-93, RD N…
Replace Snyder transverse Mercator in UTM with Karney's algorithm