Ticket #143 (closed defect: fixed)
Transforming Coordinates from MgPoint
| Reported by: | JimO | Owned by: | |
|---|---|---|---|
| Priority: | medium | Milestone: | 1.2 |
| Component: | General | Version: | 1.2.0 |
| Severity: | major | Keywords: | |
| Cc: | External ID: | 938892 |
Description
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) $_REQUESTx?, (double) $_REQUESTy?); // MgPoint? * CreatePoint? (MgCoordinate? *coordinate) // Creates a point from a coordinate. $point = $geometryFactory->CreatePoint?($coord); // MgPoint? is a subclass of MgGeometry? $point = $point->Transform($transform);
