601 uint64_t i, num_nodes, num_edges;
605 GEOSGeometry *edgegg;
620 LWDEBUGF(1,
"lwt_be_getNodeWithinBox2D returned %d nodes", num_nodes);
621 if (num_nodes == UINT64_MAX)
626 for ( i=0; i<num_nodes; ++i )
630 if ( node->
node_id == start_node )
continue;
631 if ( node->
node_id == end_node )
continue;
638 GEOSGeom_destroy(edgegg);
640 lwerror(
"SQL/MM Spatial exception - geometry crosses a node");
649 LWDEBUGF(1,
"lwt_be_getEdgeWithinBox2D returned %d edges", num_edges);
650 if (num_edges == UINT64_MAX)
652 GEOSGeom_destroy(edgegg);
656 for ( i=0; i<num_edges; ++i )
664 if ( edge_id == myself )
continue;
666 if ( ! edge->
geom ) {
668 lwerror(
"Edge %d has NULL geometry!", edge_id);
674 GEOSGeom_destroy(edgegg);
680 LWDEBUGF(2,
"Edge %d converted to GEOS", edge_id);
684 relate = GEOSRelateBoundaryNodeRule(eegg, edgegg, 2);
686 GEOSGeom_destroy(eegg);
687 GEOSGeom_destroy(edgegg);
693 LWDEBUGF(2,
"Edge %d relate pattern is %s", edge_id, relate);
695 match = GEOSRelatePatternMatch(relate,
"FF*F*****");
698 GEOSGeom_destroy(eegg);
702 GEOSGeom_destroy(edgegg);
709 match = GEOSRelatePatternMatch(relate,
"1FFF*FFF2");
712 GEOSGeom_destroy(edgegg);
713 GEOSGeom_destroy(eegg);
724 match = GEOSRelatePatternMatch(relate,
"1********");
727 GEOSGeom_destroy(edgegg);
728 GEOSGeom_destroy(eegg);
733 lwerror(
"Spatial exception - geometry intersects edge %"
739 match = GEOSRelatePatternMatch(relate,
"T********");
742 GEOSGeom_destroy(edgegg);
743 GEOSGeom_destroy(eegg);
748 lwerror(
"SQL/MM Spatial exception - geometry crosses edge %"
754 match = GEOSRelatePatternMatch(relate,
"*T*******");
757 GEOSGeom_destroy(edgegg);
758 GEOSGeom_destroy(eegg);
763 lwerror(
"Spatial exception - geometry boundary touches interior of edge %"
769 match = GEOSRelatePatternMatch(relate,
"***T*****");
772 GEOSGeom_destroy(edgegg);
773 GEOSGeom_destroy(eegg);
778 lwerror(
"Spatial exception - boundary of edge % touches interior of geometry"
784 LWDEBUGF(2,
"Edge %d analisys completed, it does no harm", edge_id);
787 GEOSGeom_destroy(eegg);
789 LWDEBUGF(1,
"No edge crossing detected among the %d candidate edges", num_edges);
793 GEOSGeom_destroy(edgegg);
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
static LWT_ISO_NODE * lwt_be_getNodeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
static LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Datum contains(PG_FUNCTION_ARGS)
const LWT_BE_IFACE * be_iface