#1891 closed defect (fixed)
ms_shapeObjFromWkt doesn't work with MULTILINESTRING and MULTIPOLYGON
Reported by: | Owned by: | dmorissette | |
---|---|---|---|
Priority: | high | Milestone: | 4.10 release |
Component: | MapScript-PHP | Version: | 4.8 |
Severity: | normal | Keywords: | |
Cc: |
Description
The PHP mapscript function ms_shapeObjFromWkt doesn't work with MULTILINESTRING and MULTIPOLYGON. For these geometry types the function generally returns nothing. No error message is produced.
Change History (13)
comment:2 by , 18 years ago
I compiled mapserver with OGR option only. My DGAL/OGR-Version was 2.0.33-1.1. I have tried to install GEOS 2.2.3, but then I get an Internal Server Error message, when using the ms_shapeObjFromWkt function.
comment:3 by , 18 years ago
Can you share the WKT strings? GEOS support was re-written in 4.10 and should be much more robust. I'll take a look against 4.8 though but need your test case. Steve
comment:4 by , 18 years ago
Sorry, my version info wasn't correct. So again. I'm using: MapServer/MapScript 4.8.4, GDAL/OGR 1.3.2, I compiled MapServer completely without GEOS, but with GDAL/OGR 1.3.2. The mapscript function ms_shapeObjFromWkt works very well, except for multipart geometries. Should I have to use GEOS? What version?
comment:5 by , 18 years ago
Short answer: it seems that the OGR implementation doesn't support multilinestring and multipolygon. Hopefully the GEOS implementation does but I didn't check. Long answer: After a quick check in mapogr.cpp, it seems that msOGRGeometryToShape() only supports wkbPoint, wkbLineString and wkbPolygon. However, it seems that the underlying ogrGeomLine() function should be able to handle wkbMultiLineString and wkbMultiPolygon as well. Question for Frank: did you intentionally omit wkbMultiLineString and wkbMultiPolygon in msOGRGeometryToShape() because of a know limitation of the underlying OGR_G_CreateFromWkt() or some other reason?
comment:6 by , 18 years ago
The GEOS version does implement multipart features... I've tested with simple multipart polygons but not multi linestrings. However, multiline strings are *much* easier since you don't have to deal with inner/outer rings. Steve
comment:7 by , 18 years ago
I modified the function in maporg.cpp for my own, re-compiled mapscript and now it works fine! int msOGRGeometryToShape(OGRGeometryH hGeometry, shapeObj *psShape, OGRwkbGeometryType nType) { if (hGeometry && psShape && nType > 0) { if (nType == wkbPoint) return ogrConvertGeometry((OGRGeometry *)hGeometry, psShape, MS_LAYER_POINT); else if (nType == wkbLineString || nType == wkbMultiLineString ) return ogrConvertGeometry((OGRGeometry *)hGeometry, psShape, MS_LAYER_LINE); else if (nType == wkbPolygon || nType == wkbMultiPolygon) return ogrConvertGeometry((OGRGeometry *)hGeometry, psShape, MS_LAYER_POLYGON); else return MS_FAILURE; } else return MS_FAILURE; }
comment:8 by , 18 years ago
Frank, can you please confirm that it would be safe to apply Maik's change to msOGRGeometryToShape() in 4.10? (That fix seems fine to me as long as there is no known limitation in OGR's OGR_G_CreateFromWkt() that I'm not aware of.)
comment:10 by , 18 years ago
Milestone: | → 4.10 release |
---|---|
Owner: | changed from | to
Sounds good. Applying this fix in 4.10 CVS now.
comment:11 by , 18 years ago
Cc: | added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Applied Maik's fix in CVS HEAD. Will be in 4.10.0-beta3. P.S. I just saw in CVS logs that msOGRGeometryToShape() was created by Assefa, not Frank. Sorry for bugging you about this one Frank, I thought it had been created by you.
comment:12 by , 18 years ago
I have also added MULTIPOINT support, and added tests for these three multi geometries in msautotest/misc/ogr_wkt.map.
comment:13 by , 18 years ago
This bug is also somewhat related to Bug 1618 which relates to going the other way.
Note:
See TracTickets
for help on using tickets.