350 GEOSGeometry* g1_bounds;
351 GEOSGeometry* polygons;
352 const GEOSGeometry *vgeoms[1];
373 g1_bounds = GEOSBoundary(g1);
374 if ( NULL == g1_bounds )
376 GEOSGeom_destroy(g1);
384 GEOSGeom_destroy(g1);
385 GEOSGeom_destroy(g1_bounds);
390 vgeoms[0] = GEOSUnion(g1_bounds, g2);
391 if ( NULL == vgeoms[0] )
393 GEOSGeom_destroy(g1);
394 GEOSGeom_destroy(g2);
395 GEOSGeom_destroy(g1_bounds);
400 polygons = GEOSPolygonize(vgeoms, 1);
401 if ( NULL == polygons )
403 GEOSGeom_destroy(g1);
404 GEOSGeom_destroy(g2);
405 GEOSGeom_destroy(g1_bounds);
406 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
411 #if PARANOIA_LEVEL > 0 414 GEOSGeom_destroy(g1);
415 GEOSGeom_destroy(g2);
416 GEOSGeom_destroy(g1_bounds);
417 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
418 GEOSGeom_destroy(polygons);
419 lwerror(
"%s [%s] Unexpected return from GEOSpolygonize", __FILE__, __LINE__);
428 n = GEOSGetNumGeometries(polygons);
437 const GEOSGeometry* p = GEOSGetGeometryN(polygons, i);
440 pos = GEOSPointOnSurface(p);
443 GEOSGeom_destroy(g1);
444 GEOSGeom_destroy(g2);
445 GEOSGeom_destroy(g1_bounds);
446 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
447 GEOSGeom_destroy(polygons);
452 contains = GEOSContains(g1, pos);
455 GEOSGeom_destroy(g1);
456 GEOSGeom_destroy(g2);
457 GEOSGeom_destroy(g1_bounds);
458 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
459 GEOSGeom_destroy(polygons);
460 GEOSGeom_destroy(pos);
465 GEOSGeom_destroy(pos);
478 GEOSGeom_destroy(g1);
479 GEOSGeom_destroy(g2);
480 GEOSGeom_destroy(g1_bounds);
481 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
482 GEOSGeom_destroy(polygons);
Datum contains(PG_FUNCTION_ARGS)
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
void * lwrealloc(void *mem, size_t size)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.