MCPcopy Create free account
hub / github.com/ecto/muni / createTransform

Function createTransform

depot/console/src/lib/coordinates.ts:58–77  ·  view source on GitHub ↗
(origin: GpsCoord)

Source from the content-addressed store, hash-verified

56 * Create a coordinate transform for a given origin.
57 */
58export function createTransform(origin: GpsCoord): CoordinateTransform {
59 const latRad = (origin.lat * Math.PI) / 180;
60
61 // Radius of curvature in the meridian
62 const Rm =
63 (WGS84_A * (1 - WGS84_E2)) / Math.pow(1 - WGS84_E2 * Math.sin(latRad) ** 2, 1.5);
64
65 // Radius of curvature in the prime vertical
66 const Rn = WGS84_A / Math.sqrt(1 - WGS84_E2 * Math.sin(latRad) ** 2);
67
68 // Meters per degree
69 const metersPerDegLat = (Math.PI / 180) * Rm;
70 const metersPerDegLon = (Math.PI / 180) * Rn * Math.cos(latRad);
71
72 return {
73 origin,
74 metersPerDegLat,
75 metersPerDegLon,
76 };
77}
78
79/**
80 * Convert GPS coordinate to local ENU meters relative to transform origin.

Callers 1

useMap3DFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected