605 int i, num_nodes, num_edges;
609 GEOSGeometry *edgegg;
623 LWDEBUGF(1,
"lwt_be_getNodeWithinBox2D returned %d nodes", num_nodes);
624 if ( num_nodes == -1 ) {
628 for ( i=0; i<num_nodes; ++i )
632 if ( node->
node_id == start_node )
continue;
633 if ( node->
node_id == end_node )
continue;
640 GEOSGeom_destroy(edgegg);
642 lwerror(
"SQL/MM Spatial exception - geometry crosses a node");
651 LWDEBUGF(1,
"lwt_be_getEdgeWithinBox2D returned %d edges", num_edges);
652 if ( num_edges == -1 ) {
653 GEOSGeom_destroy(edgegg);
657 for ( i=0; i<num_edges; ++i )
665 if ( edge_id == myself )
continue;
667 if ( ! edge->
geom ) {
669 lwerror(
"Edge %d has NULL geometry!", edge_id);
675 GEOSGeom_destroy(edgegg);
681 LWDEBUGF(2,
"Edge %d converted to GEOS", edge_id);
685 relate = GEOSRelateBoundaryNodeRule(eegg, edgegg, 2);
687 GEOSGeom_destroy(eegg);
688 GEOSGeom_destroy(edgegg);
694 LWDEBUGF(2,
"Edge %d relate pattern is %s", edge_id, relate);
696 match = GEOSRelatePatternMatch(relate,
"F********");
699 GEOSGeom_destroy(eegg);
703 GEOSGeom_destroy(edgegg);
710 match = GEOSRelatePatternMatch(relate,
"1FFF*FFF2");
713 GEOSGeom_destroy(edgegg);
714 GEOSGeom_destroy(eegg);
725 match = GEOSRelatePatternMatch(relate,
"1********");
728 GEOSGeom_destroy(edgegg);
729 GEOSGeom_destroy(eegg);
734 lwerror(
"Spatial exception - geometry intersects edge %"
740 match = GEOSRelatePatternMatch(relate,
"T********");
743 GEOSGeom_destroy(edgegg);
744 GEOSGeom_destroy(eegg);
749 lwerror(
"SQL/MM Spatial exception - geometry crosses edge %"
755 LWDEBUGF(2,
"Edge %d analisys completed, it does no harm", edge_id);
758 GEOSGeom_destroy(eegg);
763 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.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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, int *numelems, int fields, int limit)
static LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, int *numelems, int fields, int limit)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Datum contains(PG_FUNCTION_ARGS)
const LWT_BE_IFACE * be_iface