/*
LamToLonLat
© System
http://qdl.scs-inc.us/?top=6188
*/
/*
Converts Map XY to LonLat.
longitude/latitude input/output is in radians
*/
function LamToLonLat(x, y, primeLon, primeLat, lowerLat, upperLat) {
var tmp1 = Math.log(Math.cos(lowerLat) / Math.cos(upperLat));
var tmp2 = Math.tan((Math.PI / 4) + (upperLat / 2));
var tmp3 = Math.tan((Math.PI / 4) + (lowerLat / 2));
var n = tmp1 / Math.log(tmp2 / tmp3);
var F = (Math.cos(lowerLat) * Math.pow(Math.tan((Math.PI / 4) + (lowerLat / 2)), n)) / n;
var p0 = F * Math.pow((1 / Math.tan((Math.PI / 4) + (primeLat / 2))), n);
var sgn = ((n == 0) ? 0 : (n / Math.abs(n)));
var p = sgn * Math.sqrt(Math.pow(x, 2) + Math.pow((p0 - y), 2));
var theta = Math.atan(x / (p0 - y));
var lat = (2 * Math.atan(Math.pow((F / p), (1 / n)))) - (Math.PI / 2);
var lon = primeLon + (theta / n);
var result = new Array(lon, lat);
return result;
}
|