[mapguide-trac] #143: Transforming Coordinates from MgPoint
MapGuide Open Source
trac_mapguide at osgeo.org
Thu May 17 18:00:11 EDT 2007
#143: Transforming Coordinates from MgPoint
-----------------------+----------------------------------------------------
Reporter: JimO | Owner:
Type: defect | Status: new
Priority: medium | Milestone:
Component: General | Version:
Severity: major | Keywords:
External_id: |
-----------------------+----------------------------------------------------
I am able to transform coordinates on the fly from a FeatureReader,
but not from an MgPoint. The MgPoint->Transform() returns the coordinate
as rads and must be converted like this:
$x = $x / M_PI * 180.0;// M_PI is the PHP constant for pi
$y = $y / M_PI * 180.0;
This transform into rads works from BC Albers to LL84, but does not work
at all the other way.
The featurereader code that works goes:
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 works only one way and returns a coordinate as rads
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);
--
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/143>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals
More information about the mapguide-trac
mailing list