Ticket #135 (closed defect: fixed)
*_getDimensions functions do not return correct dimensions
|Reported by:||hrz@…||Owned by:||strk|
Description (last modified by mloskot) (diff)
Based on the comments in geos_c.h, I would expect the following code to print 'dimensions=0' instead of the 'dimensions=3' I currently get.
geom = GEOSGeomFromWKT("POLYGON EMPTY"); printf("dimensions=%dn", GEOSGeom_getDimensions(geom));
This is the same for POINT, LINESTRING and LINEARRING types, although GEOMETRYCOLLECTION and subtypes thereof work as expected.
On a possibly related note, I would expect the following code to output 'coords dimensions=2' instead of the 'coords dimension=3' I get.
coords = GEOSCoordSeq_create(1, 2); GEOSCoordSeq_setX(coords, 0, 43.2); GEOSCoordSeq_setY(coords, 0, 44.2); GEOSCoordSeq_getDimensions(coords, &dims); printf("coords dimensions=%dn", dims);
Wouldn't it be more useful if GEOSGeom_getDimensions() used a similar prototype to GEOSCoordSeq_getDimensions()? This would allow to easily distinguish between empty geometries and testing if an exception was thrown. Alternatively GEOSGeom_getDimensions() could return -1 if an exception occurred.
Or am I missing something fundamental?
My system details are the same as in Bug #133