[mapguide-dev] area calculation conversion to meters

Daniel Morissette dmorissette at mapgears.com
Mon Dec 4 10:55:53 EST 2006


Paul Spencer wrote:
> over my head, for sure!  I don't think I need that kind of accuracy.  I 
> would like to know if there is a programmatic way to determine a UTM 
> coordinate system centered on a particular location or, as a minimum, a 
> way to find the UTM zone that a given coordinate lies in.
> 
> Is there some base string I could use and just substitute in some values?
> 

The OGC WMS spec has projection AUTO:42001 that does that. There used to 
be some background info including some code snippets showing how to 
setup a UTM coordsys centered on a given location/zone at 
http://www.digitalearth.gov/wmt/auto.html but this page has been taken 
down a little while ago.

Thanks to the Web Archive, you can still find the info here:
http://web.archive.org/web/20010430015937/http://www.digitalearth.gov/wmt/auto.html 


The block of code you're looking for is:

         /** WGS 84 / Auto UTM **/
         zone = floor( (lon0 + 180.0) / 6.0 ) + 1;
         sprintf( wktStr, "PROJCS[\"WGS 84 / Auto UTM\",GEOGCS[\"WGS 
84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Decimal_Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"central_meridian\",%.16g],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",%.16g],UNIT[\"Meter\",1]]", 
zoneStr, -183.0 + zone * 6.0, (lat0 >= 0.0) ? 0.0 : 10000000.0 );


Daniel
-- 
Daniel Morissette
http://www.mapgears.com/




More information about the Mapguide-internals mailing list