Coordinate Systems

AutoCAD Map 3D Geospatial Platform API

Coordinate Systems

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.

NoteA coordinate system can also be called a spatial reference system (SRS) or a coordinate reference system (CRS). This guide uses the abbreviation SRS.

AutoCAD Map 3D supports three different types of coordinate system:

  • Arbitrary X-Y
  • Geographic, or latitude/longitude
  • Projected

An MgCoordinateSystem object represents a coordinate system.

NoteYou cannot transform between arbitrary X-Y coordinates and either geographic or projected coordinates.

To create an MgCoordinateSystem object from an AcMapMap object,

  • Get the WKT representation of the map coordinate system, using AcMapMap.GetMapSRS().
  • Create an MgCoordinateSystem object, using MgCoordinateSystemFactory.Create().

To create an MgCoordinateSystem object from a map layer,

  • Get the feature source for the layer.
  • Get the active spatial context for the feature source.
  • Convert the spatial context to a WKT.
  • Create an MgCoordinateSystem object from the WKT.

To transform geometry from one coordinate system to another, create an MgCoordinateSystemTransform object using 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:

string featureSource1 = layer1.GetFeatureSourceId();
MgSpatialContextsReader contexts1 = 
  featureSource1, true);
string srs1 = contexts1.GetCoordinateSystemWkt();
string featureSource2 = layer2.GetFeatureSourceId();
MgSpatialContextsReader contexts2 = 
  featureSource2, true);
string srs2 = contexts2.GetCoordinateSystemWkt();
MgCoordinateSystemFactory coordsysFactory = 
  new MgCoordinateSystemFactory();
MgCoordinateSystemTransform xform = 
  coordsysFactory.GetTransform(srs1, srs2);
MgGeometry geometry1xform = geometry1.Transform(xform);