356 GEOSGeometry* g1_bounds;
357 GEOSGeometry* polygons;
358 const GEOSGeometry *vgeoms[1];
379 g1_bounds = GEOSBoundary(g1);
380 if ( NULL == g1_bounds )
382 GEOSGeom_destroy(g1);
390 GEOSGeom_destroy(g1);
391 GEOSGeom_destroy(g1_bounds);
396 vgeoms[0] = GEOSUnion(g1_bounds, g2);
397 if ( NULL == vgeoms[0] )
399 GEOSGeom_destroy(g1);
400 GEOSGeom_destroy(g2);
401 GEOSGeom_destroy(g1_bounds);
406 polygons = GEOSPolygonize(vgeoms, 1);
407 if ( NULL == polygons )
409 GEOSGeom_destroy(g1);
410 GEOSGeom_destroy(g2);
411 GEOSGeom_destroy(g1_bounds);
412 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
417 #if PARANOIA_LEVEL > 0
420 GEOSGeom_destroy(g1);
421 GEOSGeom_destroy(g2);
422 GEOSGeom_destroy(g1_bounds);
423 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
424 GEOSGeom_destroy(polygons);
425 lwerror(
"%s [%s] Unexpected return from GEOSpolygonize", __FILE__, __LINE__);
434 n = GEOSGetNumGeometries(polygons);
443 const GEOSGeometry* p = GEOSGetGeometryN(polygons, i);
446 pos = GEOSPointOnSurface(p);
449 GEOSGeom_destroy(g1);
450 GEOSGeom_destroy(g2);
451 GEOSGeom_destroy(g1_bounds);
452 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
453 GEOSGeom_destroy(polygons);
461 GEOSGeom_destroy(g1);
462 GEOSGeom_destroy(g2);
463 GEOSGeom_destroy(g1_bounds);
464 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
465 GEOSGeom_destroy(polygons);
466 GEOSGeom_destroy(pos);
471 GEOSGeom_destroy(pos);
484 GEOSGeom_destroy(g1);
485 GEOSGeom_destroy(g2);
486 GEOSGeom_destroy(g1_bounds);
487 GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
488 GEOSGeom_destroy(polygons);
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
void * lwrealloc(void *mem, size_t size)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Datum contains(PG_FUNCTION_ARGS)