<!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:&nbsp;&nbsp; mapguide-users-bounces@lists.osgeo.org on behalf of Jim O'Leary<BR>
Sent:&nbsp;&nbsp; Tue 5/8/2007 8:01 PM<BR>
To:&nbsp;&nbsp;&nbsp;&nbsp; mapguide-users@lists.osgeo.org<BR>
Cc:&nbsp;&nbsp;&nbsp;&nbsp;<BR>
Subject:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [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,&nbsp; 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[&quot;UTM Zone 18 (NAD 83)&quot;, GEOGCS [&quot;NAD 83 (Continental<BR>
US)&quot;, DATUM [&quot;NAD 83 (Continental US)&quot;, SPHEROID [&quot;GRS 80&quot;, 6378137,<BR>
298.257222101]], PRIMEM [ &quot;Greenwich&quot;, 0.000000 ], UNIT [&quot;Decimal Degree&quot;,<BR>
0.01745329251994330]], PROJECTION [&quot;Transverse Mercator&quot;], PARAMETER<BR>
[&quot;Scale_Factor&quot;, 0.999600], PARAMETER [&quot;Central_Meridian&quot;, -75.000000],<BR>
PARAMETER [&quot;False_Easting&quot;, 500000.000000], UNIT [&quot;Meter&quot;,<BR>
1.000000000000]]';<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $coordSysProj = $coordSysFactory-&gt;Create($wktProj);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $xGeog = -71.061342;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $yGeog = 42.355892;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $coordinate = $geometryFactory-&gt;CreateCoordinateXY($xGeog, $yGeog);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $convertedCoordinate =<BR>
$coordSysProj-&gt;ConvertFromLonLat($coordinate);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $xConv = $convertedCoordinate-&gt;GetX();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $yConv = $convertedCoordinate-&gt;GetY();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo&nbsp; &quot;($xGeog, $yGeog) to ($xConv, $yConv)n&quot;;<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>