[geos-devel] Creating an invalid geometry

Frank Warmerdam warmerdam at pobox.com
Mon Oct 27 09:49:11 EDT 2008


Denise MacLeod wrote:
> Hi all -
> 
> I am trying to work on issue #170, a memory leak when performing the 
> intersection of a valid and an invalid polygon. My question is: how do I 
> get an invalid polygon?  I have one in a file in WKT format, but when 
> reading it in, GEOSGeomFromWKT detects that's invalid and returns a NULL 
> pointer. Likewise, the WKB function has similar logic. It's too robust  :-)
> 
> Is there anyway quick way around this, without changing the source to 
> skip the validation step in GEOSGeomFromWKT?

Denise,

Presumably you can create the invalid geometries the direct geometry
creation methods:


extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);

/*
  * Second argument is an array of GEOSGeometry* objects.
  * The caller remains owner of the array, but pointed-to
  * objects become ownership of the returned GEOSGeometry.
  */
extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
	GEOSGeometry** holes, unsigned int nholes);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
	GEOSGeometry* *geoms, unsigned int ngeoms);

extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the geos-devel mailing list