Opened 16 years ago
Closed 14 years ago
#2762 closed defect (fixed)
PHP MapScript shapeObj->toWkt() returns single point for multipoint geometry
Reported by: | mgleahy | Owned by: | mapserverbugs |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MapScript-PHP | Version: | 5.2 |
Severity: | normal | Keywords: | |
Cc: | aboudreault |
Description
As described here: http://lists.osgeo.org/pipermail/mapserver-dev/2008-September/007643.html
Change History (6)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Yes, I just tested it with PHP mapscript 5.6.3 on Ubuntu 10.04, using the packages from the UbuntuGIS unstable repo, and it still happens.
I eventually created a php class works around this for me:
class My_ShapeObj { /** * Return the geometry in Well Known Text format - basically, this * is a proxy for the $oShape->toWkt() method, but corrects for * multi-point geometries which are not currently working (where * it instead returns WKT for just the first point found in the * geometry object). * * @param shapeObj $oShape */ public function toWkt($oShape) { if ($oShape->type!=MS_SHAPE_POINT || $oShape->numlines<=1) { return $oShape->toWkt(); } // This appears to be a point shape with more than one lineObj. else { $aWkt = array(); // Each line is simply a lineObj containing one pointObj: for ($i=0;$i<$oShape->numlines;$i++) { $oPoint = $oShape->line($i)->point(0); $aWkt[] = $oPoint->x." ".$oPoint->y; } // Fixed WKT: return "MULTIPOINT(".implode(",",$aWkt).")"; } } }
The above can be called to translate multipoints into appropriate WKT like so:
$sWkt = My_ShapeObj::toWkt($oShape);
comment:5 by , 14 years ago
mgleahy, I guess you experienced this bug using a postgis layer? Am I right?
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Is this ticket still valid?