641{
643 int i;
644 const GBOX *minenv = NULL;
647 GEOSGeometry *ghole;
648
650
652
653
654 {
658 if ( ! ghole ) {
660 return -1;
661 }
662 }
663
664
665 if ( ! shells->
tree )
666 {
668 LWDEBUG(1,
"Building STRtree");
670 if (shells->
tree == NULL)
671 {
673 return -1;
674 }
675 for (i=0; i<shells->
size; ++i)
676 {
679 LWDEBUGF(2,
"GBOX of shell %p for edge %lld is %g %g,%g %g",
685 pt.
x = shellbox->
xmin;
686 pt.
y = shellbox->
ymin;
688 pt.
x = shellbox->
xmax;
689 pt.
y = shellbox->
ymax;
692
693
696 GEOSSTRtree_insert(shells->
tree, sring->
genv, sring);
697 }
698 LWDEBUG(1,
"STRtree build completed");
699 }
700
704 LWDEBUGF(1,
"Found %d candidate shells containing first point of ring's originating edge %lld",
706
707
708
709 for (i=0; i<candidates.
size; ++i)
710 {
714
716 {
717 LWDEBUGF(1,
"Shell %lld is on other side of ring",
719 continue;
720 }
721
722
724 {
725 LWDEBUGF(1,
"Bbox of shell %lld equals that of hole ring",
727 continue;
728 }
729
730
732 {
733 LWDEBUGF(1,
"Bbox of shell %lld does not contain bbox of ring point",
735 continue;
736 }
737
738
739
741 {
742 LWDEBUGF(2,
"Bbox of shell %d (face %lld) not contained by bbox "
743 "of last shell found to contain the point",
745 continue;
746 }
747
750 {
751
752
753
754 LWDEBUGF(1,
"Shell %lld contains hole of edge %lld",
757 minenv = shellbox;
759 }
760 }
761 if ( foundInFace == -1 ) foundInFace = 0;
762
765
766 GEOSGeom_destroy(ghole);
767
768 return foundInFace;
769}
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
int gbox_contains_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the first GBOX contains the second on the 2d plane, LW_FALSE otherwise.
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
void lwpoint_free(LWPOINT *pt)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void lwline_free(LWLINE *line)
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
LWT_INT64 LWT_ELEMID
Identifier of topology element.
static const int STRTREE_NODE_CAPACITY
Datum contains(PG_FUNCTION_ARGS)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int _lwt_EdgeRingContainsPoint(LWT_EDGERING *ring, POINT2D *p)
static GBOX * _lwt_EdgeRingGetBbox(LWT_EDGERING *ring)
static LWT_ELEMID _lwt_EdgeRingGetFace(LWT_EDGERING *ring)
#define LWT_EDGERING_ARRAY_INIT(a)
static void _lwt_AccumulateCanditates(void *item, void *userdata)
#define LWT_EDGERING_ARRAY_CLEAN(a)
LWT_EDGERING_ELEM ** elems