Adds a polygon to the topology.
The boundary of the given polygon will snap to existing nodes or edges within given tolerance. Existing edges or faces may be split by the boundary of the polygon.
7547{
7548 *nfaces = -1;
7549 int num;
7551 uint64_t nfacesinbox;
7552 uint64_t j;
7555 const GEOSPreparedGeometry *ppoly;
7556 GEOSGeometry *polyg;
7557
7558
7560 {
7561 *nfaces = 0;
7562 return NULL;
7563 }
7564
7565
7567 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
7568
7570
7571
7572
7573
7574
7579 if (nfacesinbox == UINT64_MAX)
7580 {
7583 return NULL;
7584 }
7585
7586 num = 0;
7587 if ( nfacesinbox )
7588 {
7590 if ( ! polyg )
7591 {
7594 return NULL;
7595 }
7596 ppoly = GEOSPrepare(polyg);
7598 for ( j=0; j<nfacesinbox; ++j )
7599 {
7602 GEOSGeometry *fgg, *sp;
7604
7605
7607 if ( ! fg )
7608 {
7610 GEOSPreparedGeom_destroy(ppoly);
7611 GEOSGeom_destroy(polyg);
7615 return NULL;
7616 }
7617
7620 if ( ! fgg )
7621 {
7622 GEOSPreparedGeom_destroy(ppoly);
7623 GEOSGeom_destroy(polyg);
7626 return NULL;
7627 }
7628 sp = GEOSPointOnSurface(fgg);
7629 GEOSGeom_destroy(fgg);
7630 if ( ! sp )
7631 {
7632 GEOSPreparedGeom_destroy(ppoly);
7633 GEOSGeom_destroy(polyg);
7636 return NULL;
7637 }
7638 covers = GEOSPreparedCovers( ppoly, sp );
7639 GEOSGeom_destroy(sp);
7641 {
7642 GEOSPreparedGeom_destroy(ppoly);
7643 GEOSGeom_destroy(polyg);
7646 return NULL;
7647 }
7649 {
7650 continue;
7651 }
7652
7653
7655 }
7656 GEOSPreparedGeom_destroy(ppoly);
7657 GEOSGeom_destroy(polyg);
7659 }
7660
7661
7662
7663 *nfaces = num;
7664
7665 return ids;
7666}
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_free(LWGEOM *geom)
void * lwalloc(size_t size)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int lwpoly_is_empty(const LWPOLY *poly)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define PGTOPO_BE_ERROR()
Datum covers(PG_FUNCTION_ARGS)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_ISO_FACE * lwt_be_getFaceWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
void _lwt_release_faces(LWT_ISO_FACE *faces, int num_faces)
static void lwt_LoadPolygon(LWT_TOPOLOGY *topo, const LWPOLY *poly, double tol)
#define _LWT_MINTOLERANCE(topo, geom)
LWGEOM * lwt_GetFaceGeometry(LWT_TOPOLOGY *topo, LWT_ELEMID faceid)
Return the geometry of a face.