I stumbled upon this old post while working on a similar project and was able to get Jeff's code to work for the first function(convertSPtoLL_LLC) by adding in the false northing variable and Y coordinate correction. New lines are in red. org.mymanatee.common.latlong.convertSPtoLL_LLC = function (uX,uY) { var a = 20925604.48; //major radius of ellipsoid, map units (NAD 83) var ec = 0.08181905782; //eccentricity of ellipsoid (NAD 83) var angRad = 0.01745329252; //number of radians in a degree var pi4 = Math.PI / 4; //Pi / 4 var p0 = 24.333333 * angRad; //latitude of origin var p1 = 24.333333 * angRad; //latitude of first standard parallel var p2 = 31.5 * angRad; //latitude of second standard parallel var m0 = -82.000000 * angRad; //central meridian var x0 = 656166.666667; //False easting of central meridian, map units var y0 = value; //False northing of central meridian, map units // Calculate the coordinate system constants. with (Math) { var m1 = cos(p1) / sqrt(1 - (pow(ec,2)) * pow(sin(p1),2)); var m2 = cos(p2) / sqrt(1 - (pow(ec,2)) * pow(sin(p2),2)); var t0 = tan(pi4 - (p0 / 2)); var t1 = tan(pi4 - (p1 / 2)); var t2 = tan(pi4 - (p2 / 2)); t0 = t0 / pow(((1 - (ec * (sin(p0)))) / (1 + (ec * (sin(p0))))),ec/2); t1 = t1 / pow(((1 - (ec * (sin(p1)))) / (1 + (ec * (sin(p1))))),ec/2); t2 = t2 / pow(((1 - (ec * (sin(p2)))) / (1 + (ec * (sin(p2))))),ec/2); var n = log(m1 / m2) / log(t1 / t2); var f = m1 / (n * pow(t1,n)); var rho0 = a * f * pow(t0,n); // Convert the coordinate to Latitude/Longitude. // Calculate the Longitude. var uX = uX - x0; var uY = uY - y0; var pi2 = pi4 * 2; var rho = sqrt(pow(uX,2) + pow((rho0 - uY),2)); var theta = atan(uX / (rho0 - uY)); var txy = pow((rho / (a * f)),(1 / n)); var lon = (theta / n) + m0; var uX = uX + x0; // Estimate the Latitude var lat0 = pi2 - (2 * atan(txy)); // Substitute the estimate into the iterative calculation that // converges on the correct Latitude value. var part1 = (1 - (ec * sin(lat0))) / (1 + (ec * sin(lat0))); var lat1 = pi2 - (2 * atan(txy * pow(part1,(ec/2)))); while ((abs(lat1 - lat0)) > 0.000000002) { lat0 = lat1; part1 = (1 - (ec * sin(lat0))) / (1 + (ec * sin(lat0))); lat1 = pi2 - (2 * atan(txy * pow(part1,(ec/2)))); } // Convert from radians to degrees. var Lat = lat1 / angRad; var Lon = lon / angRad; //alert(Lat); //alert(Lon); //Round the latitude and longitude //lat = (CLng(lat * 100000)) / 100000; //lon = (CLng(lon * 100000)) / 100000; Lat = Lat.toPrecision(7); Lon = Lon.toPrecision(8); return [Lat,Lon]; } }; //End of Code for converting map units to decimal degrees.
... View more