[mapguide-users] Transform Coordinates from MgPoint
Jim O'Leary
joleary.public at gmail.com
Wed May 9 20:16:21 EDT 2007
I am able to transform coordinates on the fly from a FeatureReader,
but not from an MgPoint. Both codes below produce an MgGeometry object,
and both codes produce a $transform object like this:
$coordSysFactory = new MgCoordinateSystemFactory();
$source = $coordSysFactory->Create($map->GetMapSRS());
$target = $coordSysFactory->Create($LL84WKT);// $LL84WKT is a the WKT string
for LL84
$transform = new MgCoordinateSystemTransform($source, $target);
I've pasted the doxygen comments in the code below for clarity.
The FeatureReader code that works goes:
$agfWriter = new MgAgfReaderWriter();
while ($featureReader->ReadNext())
{
// MgByteReader * GetGeometry (CREFSTRING propertyName)=0
// Gets the Geometry for the specified property.
$byteReader = $featureReader->GetGeometry('GEOMETRY');
// MgGeometry * Read (MgByteReader *agf)
// Translates an MgByteReader object into an MgGeometry object.
$geometry = $agfReaderWriter->Read($byteReader);
$geometry = $geometry->Transform($transform);
The MgPoint code that doesn't work goes:
// MgCoordinate * CreateCoordinateXY (double x, double y)
// Creates an MgCoordinate object with Dimension = XY
$coord = $geometryFactory->CreateCoordinateXY((double) $_REQUEST['x'],
(double) $_REQUEST['y']);
// MgPoint * CreatePoint (MgCoordinate *coordinate)
// Creates a point from a coordinate.
$point = $geometryFactory->CreatePoint($coord);
// MgPoint is a subclass of MgGeometry
$point = $point->Transform($transform);
One MgGeometry object can transform, but one cannot. All I get from the
second is a nonsense number. Suggestions?
--
View this message in context: http://www.nabble.com/Transform-Coordinates-from-MgPoint-tf3719024s16610.html#a10405212
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list