[mapguide-users] Convert lat lon to UTM

Jim O'Leary joleary.public at gmail.com
Tue May 8 20:01:10 EDT 2007


Is there a way to convert a lat lon to UTM and extract the zone, northing,
and easting? I have a form where the user enters a position either by
clicking on the map or by manually entering the coordinates. The map is in
BC Albers. They can also manually enter the UTM zone, northing, and easting
instead of the lat lon.

On the database side, it would be nice to convert what the user entered so I
can put both (lat,  lon) and (UTM zone, northing, easting) in the database. 

I found some code in the Web API Reference under MgCoordinateSystem that
might be on the right track:

$wktProj = 'PROJCS["UTM Zone 18 (NAD 83)", GEOGCS ["NAD 83 (Continental
US)", DATUM ["NAD 83 (Continental US)", SPHEROID ["GRS 80", 6378137,
298.257222101]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree",
0.01745329251994330]], PROJECTION ["Transverse Mercator"], PARAMETER
["Scale_Factor", 0.999600], PARAMETER ["Central_Meridian", -75.000000],
PARAMETER ["False_Easting", 500000.000000], UNIT ["Meter",
1.000000000000]]';
        $coordSysProj = $coordSysFactory->Create($wktProj);
        $xGeog = -71.061342;
        $yGeog = 42.355892;
        $coordinate = $geometryFactory->CreateCoordinateXY($xGeog, $yGeog);
        $convertedCoordinate =
$coordSysProj->ConvertFromLonLat($coordinate);
        $xConv = $convertedCoordinate->GetX();
        $yConv = $convertedCoordinate->GetY();
        echo  "($xGeog, $yGeog) to ($xConv, $yConv)n";

However, this code assumes that you know what UTM zone you want. As well, it
does not show how to extract the northing and easting.

Thanks
-- 
View this message in context: http://www.nabble.com/Convert-lat-lon-to-UTM-tf3712944s16610.html#a10386280
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list