usng.js
usng.js copied to clipboard
Switch to WGS84
Browsers can report location data in WGS84 instead of NAD83. Using this standard, or allowing the converter to use this standard, would be great so coordinates don't need to be manipulated going into and out of this library.
I was able to work around this with the following code.
// By default, usng uses NAD83 but doesn't support WGS84. This is a workaround.
const converter = new (Converter as any)();
converter.ECC_SQUARED = 0.00669437999014;
converter.ECC_PRIME_SQUARED =
converter.ECC_SQUARED / (1 - converter.ECC_SQUARED);
converter.E1 =
(1 - Math.sqrt(1 - converter.ECC_SQUARED)) /
(1 + Math.sqrt(1 - converter.ECC_SQUARED));