[mapguide-dev] Coordinate Transform

Bruce Dechant bruce.dechant at autodesk.com
Mon Oct 2 11:43:00 EDT 2006


Greg,

 

You can use the coordinate system API to do coordinate system
transformations. If PROJ4 does not recognize your state plane you will
have to update it.

Here is some sample code for doing a coordinate system transformation:
(This is taken right from the open source unit test code)

 

    try

    {

        MgCoordinateSystemFactory factory;

        STRING ogcWkt1 = ProjectedWkt_GAW;

        Ptr<MgCoordinateSystem> coordinateSystemSource =
factory.Create(ogcWkt1);

        CPPUNIT_ASSERT(coordinateSystemSource);

 

        STRING ogcWkt2 = GeographicWkt_LL84;

        Ptr<MgCoordinateSystem> coordinateSystemTarget =
factory.Create(ogcWkt2);

        CPPUNIT_ASSERT(coordinateSystemTarget);

 

        Ptr<MgCoordinateSystemTransform> transform = new
MgCoordinateSystemTransform(coordinateSystemSource,
coordinateSystemTarget);

        CPPUNIT_ASSERT(transform);

 

        MgCoordinateXY coord(410983.2513, 1415115.971);

        Ptr<MgCoordinate> pCoord = transform->Transform(&coord);

        CPPUNIT_ASSERT(MgUtil::ValuesEqual(-84.46, pCoord->GetX()));

        CPPUNIT_ASSERT(MgUtil::ValuesEqual(33.89, pCoord->GetY()));

    }

    catch(MgException* e)

    {

        STRING message = e->GetDetails(TEST_LOCALE);

        SAFE_RELEASE(e);

        CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));

    }

    catch(...)

    {

        throw;

    }

 

 

Bruce

 

  _____  

From: Knight, Gregory [mailto:Gregory.Knight.bra at cityofboston.gov] 
Sent: September 28, 2006 10:55 AM
To: dev at mapguide.osgeo.org
Subject: [mapguide-dev] Coordinate Transform

 

Hi all,

 

I am new to both this list and the mapguide development environment.

 

I need to transform a lat-long coordinate received from a geocoding
service (like that returned from geocoder.us in the mapguide
dotnetviewer sample) to our local state plane system (MA-NAD83-F).


How might I go about this with the least amount of pain? Do I need to
use the GDAL/PROJ libraries?  Can I do this inside my development
environement with the mapguide api?  


Any advice is appreciated.

 

Thanks,


Greg

  _____  



The substance of this message, including any attachments, may be
confidential, legally
privileged and/or exempt from disclosure pursuant to Massachusetts
law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and
delete the material from any computer.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-internals/attachments/20061002/b0d42b3e/attachment.html


More information about the Mapguide-internals mailing list