<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6619.9">
<TITLE>RE: [mapguide-users] Convert lat lon to UTM</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><FONT SIZE=2>I can't believe I am recommending this, but if it is a web form, you can just paste the javascript from this page (<A HREF="http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html">http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html</A>) into your form and then call it to do the conversion. The source is free to use.<BR>
<BR>
It is an alternative to calling MapGuide coordinate system APIs...<BR>
<BR>
Traian<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: mapguide-users-bounces@lists.osgeo.org on behalf of Jim O'Leary<BR>
Sent: Tue 5/8/2007 8:01 PM<BR>
To: mapguide-users@lists.osgeo.org<BR>
Cc: <BR>
Subject: [mapguide-users] Convert lat lon to UTM<BR>
<BR>
<BR>
Is there a way to convert a lat lon to UTM and extract the zone, northing,<BR>
and easting? I have a form where the user enters a position either by<BR>
clicking on the map or by manually entering the coordinates. The map is in<BR>
BC Albers. They can also manually enter the UTM zone, northing, and easting<BR>
instead of the lat lon.<BR>
<BR>
On the database side, it would be nice to convert what the user entered so I<BR>
can put both (lat, lon) and (UTM zone, northing, easting) in the database.<BR>
<BR>
I found some code in the Web API Reference under MgCoordinateSystem that<BR>
might be on the right track:<BR>
<BR>
$wktProj = 'PROJCS["UTM Zone 18 (NAD 83)", GEOGCS ["NAD 83 (Continental<BR>
US)", DATUM ["NAD 83 (Continental US)", SPHEROID ["GRS 80", 6378137,<BR>
298.257222101]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree",<BR>
0.01745329251994330]], PROJECTION ["Transverse Mercator"], PARAMETER<BR>
["Scale_Factor", 0.999600], PARAMETER ["Central_Meridian", -75.000000],<BR>
PARAMETER ["False_Easting", 500000.000000], UNIT ["Meter",<BR>
1.000000000000]]';<BR>
$coordSysProj = $coordSysFactory->Create($wktProj);<BR>
$xGeog = -71.061342;<BR>
$yGeog = 42.355892;<BR>
$coordinate = $geometryFactory->CreateCoordinateXY($xGeog, $yGeog);<BR>
$convertedCoordinate =<BR>
$coordSysProj->ConvertFromLonLat($coordinate);<BR>
$xConv = $convertedCoordinate->GetX();<BR>
$yConv = $convertedCoordinate->GetY();<BR>
echo "($xGeog, $yGeog) to ($xConv, $yConv)n";<BR>
<BR>
However, this code assumes that you know what UTM zone you want. As well, it<BR>
does not show how to extract the northing and easting.<BR>
<BR>
Thanks<BR>
--<BR>
View this message in context: <A HREF="http://www.nabble.com/Convert-lat-lon-to-UTM-tf3712944s16610.html#a10386280">http://www.nabble.com/Convert-lat-lon-to-UTM-tf3712944s16610.html#a10386280</A><BR>
Sent from the MapGuide Users mailing list archive at Nabble.com.<BR>
<BR>
_______________________________________________<BR>
mapguide-users mailing list<BR>
mapguide-users@lists.osgeo.org<BR>
<A HREF="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</A><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>