Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created February 23, 2015 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/aafac623c286fe9a9aa4 to your computer and use it in GitHub Desktop.
Save tmcw/aafac623c286fe9a9aa4 to your computer and use it in GitHub Desktop.
navitime.geo.Util.transDatumJtoW = function() {
return function(a) {
var b = a.lat / 1E3 * Math.PI / 648E3, c = a.lng / 1E3 * Math.PI / 648E3, d = 6377397.155 / Math.sqrt(1 - 0.006674372174974933 * Math.sin(b) * Math.sin(b));
a = (d + 0) * Math.cos(b) * Math.cos(c) - 147.54;
var c = (d + 0) * Math.cos(b) * Math.sin(c) - -507.26, b = (0.9933256278250251 * d + 0) * Math.sin(b) - -680.47, d = Math.sqrt(a * a + c * c), e = Math.atan(6378137 * b / (6356752.31424518 * d)), b = Math.atan2(b + 42841.311513312336 * Math.sin(e) * Math.sin(e) * Math.sin(e), d - 42697.67270717874 * Math.cos(e) * Math.cos(e) *
Math.cos(e));
a = Math.atan2(c, a);
return new navitime.geo.LatLng(Math.round(1E3 * b * (648E3 / Math.PI)), Math.round(1E3 * a * (648E3 / Math.PI)))
}
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment