MapGuide API Reference
|
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.
virtual MgCoordinate Transform(MgCoordinate coordinate); |
virtual MgCoordinate Transform(MgCoordinate coordinate); |
virtual MgCoordinate Transform(MgCoordinate coordinate); |
coordinate | (MgCoordinate) An MgCoordinate object defined in terms of the source coordinate system. |
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:
x21: -71.061341999861
y21: 42.355891999573
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";
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;
MgCoordinateSystemTransformFailedException |
Implements MgTransform.