Skip to content

Commit

Permalink
Improve accuracy of toLatLon
Browse files Browse the repository at this point in the history
The current implemenation has inaccuracies.  See:
- Turbo87/utm#36
- Turbo87/utm#49

repro:
```
var utm = require("utm");

var originalLatitude = -33.8688
var originalLongitude = 151.2093

const { easting, northing, zoneNum, zoneLetter} = utm.fromLatLon(originalLatitude,originalLongitude);

const { latitude, longitude } = utm.toLatLon(easting, northing, zoneNum, zoneLetter);

console.log(latitude, longitude)
console.log(`lat/lon delta: ${latitude-originalLatitude}:${longitude-originalLongitude}`)

{
  const { easting: easting2, northing: northing2, zoneNum: zoneNum2, zoneLetter: zoneLetter2} = utm.fromLatLon(latitude,longitude);
  console.log(`delta: ${easting - easting2}:${northing-northing2}`);
}
```
  • Loading branch information
chris-cooper authored Feb 9, 2021
1 parent 3e414c6 commit 1fc002d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function toLatLon(easting, northing, zoneNum, zoneLetter, northern, stric
var n = R / epSinSqrt;
var r = (1 - E) / epSin;

var c = _E * pCos * pCos;
var c = E_P2 * pCos * pCos;
var c2 = c * c;

var d = x / (n * K0);
Expand Down

0 comments on commit 1fc002d

Please sign in to comment.