Web API Reference | MapGuide Open Source

- Overview
- Modules
- Classes

GetLastTransformStatus
GetSource
GetTarget
IgnoreDatumShiftWarning
IgnoreOutsideDomainWarning
IsIgnoreDatumShiftWarning
IsIgnoreOutsideDomainWarning
IsValidSourcePoint
IsValidSourcePoint
IsValidTargetPoint
IsValidTargetPoint
ResetLastTransformStatus
SetSourceAndTarget
Transform
Transform
Transform
Transform
TransformCoordinate
TransformDatumShiftWarning
TransformM
TransformM
TransformOk
TransformOutsideDomainWarning
TransformTotalFailure
virtual MgCoordinate* MgCoordinateSystemTransform::Transform | ( | MgCoordinate * | coordinate | ) | `[pure virtual]`
Transforms the given coordinate whose frame of reference is the source coordinate system into a coordinate whose frame of reference is the target coordinate system. .NET Syntax
`virtual MgCoordinate Transform(MgCoordinate coordinate);`
Java Syntax
`virtual MgCoordinate Transform(MgCoordinate coordinate);`
PHP Syntax
`virtual MgCoordinate Transform(MgCoordinate coordinate);`
  Parameters:
  | coordinate | (MgCoordinate) An MgCoordinate object defined in terms of the source coordinate system.
Returns: Returns an MgCoordinate object which is the equivalent in the target coordinate system of the given coordinate. Example (PHP) The name of $coordSys1 is "Longitude / Latitude (NAD 83)". The name of $coordSys2 is "UTM Zone 18 (NAD 83)". $csTransform12 transforms coordinates defined in terms of $coordSys1 to coordinates defined in terms of $coordSys2. $csTransform21 does the reverse. The MgCoordinate object can contain an XY, XYM, XYZ, or XYZM coordinate. This example uses an XY coordinate. The value of $x1Arg is -71.061342, and the value of $y1Arg is 42.355892. These values are the longitude and latitude of Boston, Massachusetts. The output is: xArg -71.061342; x21: -71.061341999861 yArg 42.355892; y21: 42.355891999573 x12 824390.29381426; y12 : 4696809.9055963
     $csTransform12 = new MgCoordinateSystemTransform($coordSys1, $coordSys2);
     $csTransform21 = new MgCoordinateSystemTransform($coordSys2, $coordSys1);
     $coordinateArg = $geometryFactory->CreateCoordinateXY($xArg, $yArg);
     $coordinate12 = $csTransform12->Transform($coordinateArg);
     $x12 = $coordinate12->GetX();
     $y12 = $coordinate12->GetY();
     $coordinate21 = $csTransform21->Transform($coordinate12);
     $x21 = $coordinate21->GetX();
     $y21 = $coordinate21->GetY();
     echo "$xArg: $xArg; $x21: $x21n";
     echo "$yArg: $yArg; $y21: $y21n";
     echo "$x12: $x12; $y12 : $y12n";
Example (C#)
     using OSGeo.MapGuide;
     private MgCoordinateSystemTransform coordSysTransformGeogToProj;
     private MgCoordinateSystemTransform coordSysTransformProjToGeog;
     private double geogCSX = -160.101421317;
     private double geogCSY = 22.0234263273;
     private double projCSX = 386323.97632;
     private double projCSY = 2435829.67936;
     private MgCoordinate XY;
     Boolean isEquivalent;
     private double tolerance = 0.001;

     XY = coordSysTransformGeogToProj.Transform(geogCSX, geogCSY);
     the X and Y values of XY are equal to projCSX and projCSY
     isEquivalent = Math.Abs(projCSX - XY.GetX()) < tolerance && Math.Abs(projCSY - XY.GetY()) < tolerance;

     XY = coordSysTransformProjToGeog.Transform(projCSX, projCSY);
     the X and Y values of XY are equal to geogCSX and geogCSY
     isEquivalent = Math.Abs(geogCSX - XY.GetX()) < tolerance && Math.Abs(geogCSY - XY.GetY()) < tolerance;
  Exceptions:
  | MgCoordinateSystemTransformFailedException |
Implements MgTransform.

Comments or suggestions? Send us feedback.