BUG: GEOSGeom_clone() was( Re: [geos-devel] GEOSPolygonize()
ERROR: Shell is not a LinearRing
strk at refractions.net
strk at refractions.net
Thu Dec 29 06:00:23 EST 2005
Sorry for late answer. This is a known bug, and it's fixed
in CVS (GEOS-3.0.0). It's basically LinearRing::clone() missing,
thus using LineString::clone(), which returns a LineString
rather then a LinearRing...
In PostGIS I decided to handle the bug from caller, to ensure
also old *bogus* geos were supported... see LWGEOM_buildarea
in lwgeom/lwgeom_geos_c.c (basically you extract a CoordinateSequence,
clone that and create a LinearRing).
--strk;
On Wed, Dec 28, 2005 at 09:14:07PM -0500, Stephen Woodbridge wrote:
> 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
> >
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
--
/"\ ASCII Ribbon Campaign
\ / Respect for low technology.
X Keep e-mail messages readable by any computer system.
/ \ Keep it ASCII.
More information about the geos-devel
mailing list