A single map will often combine data from different sources, and the different sources may use different coordinate systems. The map has its own coordinate system, and any feature sources used in the map may have different coordinate systems. It is important for display and analysis that all locations are transformed to the same coordinate system.
To transform geometry from one coordinate system to another, create an MgCoordinateSystemTransform object using an MgCoordinateSystemFactory and the two coordinate systems. Apply this transform to the MgGeometry object.
For example, if you have geometry representing a feature on a layer that uses one coordinate system, and you want to compare it to a feature on another layer that uses a different coordinate system, perform the following steps:
$featureSource1 = $layer1->GetFeatureSourceId(); $contexts1 = $featureService->GetSpatialContexts( $featureSource1, true); $contexts1->ReadNext(); $srs1 = $contexts1->GetCoordinateSystemWkt(); $featureSource2 = $layer2->GetFeatureSourceId(); $contexts2 = $featureService->GetSpatialContexts( $featureSource2, true); $contexts2->ReadNext(); $srs2 = $contexts2->GetCoordinateSystemWkt(); $coordSysFactory = new MgCoordinateSystemFactory(); $xform = $coordSysFactory->GetTransform($srs1, $srs2); $geometry1xform = $geometry1->Transform($xform);