BUG: GEOSGeom_clone() was( Re: [geos-devel] GEOSPolygonize() ERROR: Shell is not a LinearRing

Stephen Woodbridge woodbri at swoodbridge.com
Wed Dec 28 21:14:07 EST 2005


Ah, I think I found a bug ...

woodbri at linus:~/cvs/dev/shptools/test$ fixpoly county out
2.2.1-CAPI-1.0.1
GEOSPolygonize returned 6 geoms IsValid(1)
Processing Geom 6
Geom(0) is type (3), IsValid(1)
ExteriorRing(0) is type (2), IsValid(1)
Cloned ExteriorRing(0) is type (1), IsValid(1)
ERROR: Shell is not a LinearRing

NOTICE, that the type changed when I cloned the ExteriorRing from a 
LINEARRING to LINESTRING

       g4 = GEOSGetExteriorRing(g3);
printf("ExteriorRing(%d) is type (%d), IsValid(%d)\n", i, 
GEOSGeomTypeId(g4), GEOSisValid(g4));

       g5 = GEOSGeom_clone(g4);
printf("Cloned ExteriorRing(%d) is type (%d), IsValid(%d)\n", i, 
GEOSGeomTypeId(g5), GEOSisValid(g5));

       extring = GEOSGeom_createPolygon(g5, NULL, 0);

-Steve

Stephen Woodbridge wrote:
> I am trying to write a simple utility that will read a shapefile of 
> polygons, decompose them into simple linestrings and feed them to 
> GEOSPolygonize() so I can take the results and write  a new shapefile 
> with good polygons.
> 
> So, I have this coded using geos_c.h. I used postgis buildarea() as an 
> example of how to process the output of GEOSPolygonize(), but get the 
> following  ERROR thrown by GEOS from this statement:
> 
>   g = GEOSPolygonize(geoms, nedge);
> 
>   if (! g || GEOSGeomTypeId(g) != GEOS_GEOMETRYCOLLECTION)
>     goto DONE;
> 
>   ngeoms = GEOSGetNumGeometries(g);
> 
>   printf("GEOSPolygonize returned %d geoms\n", ngeoms);
> 
> ...
> 
>       extring = GEOSGeom_createPolygon(
>         GEOSGeom_clone(GEOSGetExteriorRing(GEOSGetGeometryN(g, i))),
>         NULL, 0);
> 
> 
> GEOSPolygonize returned 6 geoms
> Processing Geom 0
> ERROR: Shell is not a LinearRing
> 
> I guess, my question is what does this error mean? And why would 
> GEOSPolygonize return something that is not a polygon or LinearRing?
> 
> If it would by helpful, I can post fixpoly.c and the shapefile.
> 
> -Steve
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 




More information about the geos-devel mailing list