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.
7706{
7707 *nfaces = -1;
7708 int num;
7710 uint64_t nfacesinbox;
7711 uint64_t j;
7714 const GEOSPreparedGeometry *ppoly;
7715 GEOSGeometry *polyg;
7716
7717
7719 {
7720 *nfaces = 0;
7721 return NULL;
7722 }
7723
7724
7726 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
7727
7729
7730
7731
7732
7733
7738 if (nfacesinbox == UINT64_MAX)
7739 {
7742 return NULL;
7743 }
7744
7745 num = 0;
7746 if ( nfacesinbox )
7747 {
7749 if ( ! polyg )
7750 {
7753 return NULL;
7754 }
7755 ppoly = GEOSPrepare(polyg);
7757 for ( j=0; j<nfacesinbox; ++j )
7758 {
7761 GEOSGeometry *fgg, *sp;
7763
7764
7766 if ( ! fg )
7767 {
7769 GEOSPreparedGeom_destroy(ppoly);
7770 GEOSGeom_destroy(polyg);
7774 return NULL;
7775 }
7776
7779 if ( ! fgg )
7780 {
7781 GEOSPreparedGeom_destroy(ppoly);
7782 GEOSGeom_destroy(polyg);
7785 return NULL;
7786 }
7787 sp = GEOSPointOnSurface(fgg);
7788 GEOSGeom_destroy(fgg);
7789 if ( ! sp )
7790 {
7791 GEOSPreparedGeom_destroy(ppoly);
7792 GEOSGeom_destroy(polyg);
7795 return NULL;
7796 }
7797 covers = GEOSPreparedCovers( ppoly, sp );
7798 GEOSGeom_destroy(sp);
7800 {
7801 GEOSPreparedGeom_destroy(ppoly);
7802 GEOSGeom_destroy(polyg);
7805 return NULL;
7806 }
7808 {
7809 continue;
7810 }
7811
7812
7814 }
7815 GEOSPreparedGeom_destroy(ppoly);
7816 GEOSGeom_destroy(polyg);
7818 }
7819
7820
7821
7822 *nfaces = num;
7823
7824 return ids;
7825}
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.