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.
A coordinate system can also be called a spatial reference system (SRS) or a coordinate reference system (CRS). This guide uses the abbreviation SRS.
Infrastructure Map Server supports three different types of coordinate system:
An MgCoordinateSystem object represents a coordinate system.
You cannot transform between arbitrary X-Y coordinates and either geographic or projected coordinates.
To create an MgCoordinateSystem object from an MgMap object,
To create an MgCoordinateSystem object from a map layer,
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);