[geos-devel] C-API Question about GEOSPolygonize()

Stephen Woodbridge woodbri at swoodbridge.com
Tue May 9 22:20:41 EDT 2006


With only the geos_c.h as doc for the C-API and getting totally lost in 
the doxygen doc. I thought I would just ask:

It seems from testing, that GEOSPolygonize() always returns a geometry 
collection. Is this true? If not what can I expect as the range of 
GEOSGeomTypeId that I can expect to get back.

Assuming it is a geometry collection, what can I expect to find in the 
collection. Only GEOS_POLYGON, or others like GEOS_MULTIPOLYGON and/or 
others.

How does one get the individual polygons out of a GEOS_MULTIPOLYGON? I 
would have thought to use:

extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeom g1);

/*
  * Return NULL on exception, Geometry must be a Collection.
  * Returned object is a pointer to internal storage:
  * it must NOT be destroyed directly.
  */
extern const GEOSGeom GEOS_DLL GEOSGetGeometryN(const GEOSGeom g, int n);

/* Return -1 on exception */


But the comment seems to imply that that is not the correct tool.

What I am trying to do is load a bunch of polylines into linestrings and 
feed them to GEOSPolygonize then load the results into polygon 
shapefiles. I would like the shapefiles to be able to be loaded into 
postGIS as valid polygons if I need to do that later.

Any thoughts, help, advice, sample code pointers, etc would be appreciated.

-Steve



More information about the geos-devel mailing list