593 int i, num_nodes, num_edges;
597 GEOSGeometry *edgegg;
598 const GEOSPreparedGeometry* prepared_edge;
607 prepared_edge = GEOSPrepare( edgegg );
608 if ( ! prepared_edge ) {
617 LWDEBUGF(1,
"lwt_be_getNodeWithinBox2D returned %d nodes", num_nodes);
618 if ( num_nodes == -1 ) {
619 GEOSPreparedGeom_destroy(prepared_edge);
620 GEOSGeom_destroy(edgegg);
624 for ( i=0; i<num_nodes; ++i )
627 GEOSGeometry *nodegg;
629 if ( node->
node_id == start_node )
continue;
630 if ( node->
node_id == end_node )
continue;
634 contains = GEOSPreparedContains( prepared_edge, nodegg );
635 GEOSGeom_destroy(nodegg);
638 GEOSPreparedGeom_destroy(prepared_edge);
639 GEOSGeom_destroy(edgegg);
646 GEOSPreparedGeom_destroy(prepared_edge);
647 GEOSGeom_destroy(edgegg);
649 lwerror(
"SQL/MM Spatial exception - geometry crosses a node");
658 LWDEBUGF(1,
"lwt_be_getEdgeWithinBox2D returned %d edges", num_edges);
659 if ( num_edges == -1 ) {
660 GEOSPreparedGeom_destroy(prepared_edge);
661 GEOSGeom_destroy(edgegg);
665 for ( i=0; i<num_edges; ++i )
673 if ( edge_id == myself )
continue;
675 if ( ! edge->
geom ) {
677 lwerror(
"Edge %d has NULL geometry!", edge_id);
683 GEOSPreparedGeom_destroy(prepared_edge);
684 GEOSGeom_destroy(edgegg);
690 LWDEBUGF(2,
"Edge %d converted to GEOS", edge_id);
694 relate = GEOSRelateBoundaryNodeRule(eegg, edgegg, 2);
696 GEOSGeom_destroy(eegg);
697 GEOSPreparedGeom_destroy(prepared_edge);
698 GEOSGeom_destroy(edgegg);
704 LWDEBUGF(2,
"Edge %d relate pattern is %s", edge_id, relate);
706 match = GEOSRelatePatternMatch(relate,
"F********");
709 GEOSGeom_destroy(eegg);
713 GEOSPreparedGeom_destroy(prepared_edge);
714 GEOSGeom_destroy(edgegg);
721 match = GEOSRelatePatternMatch(relate,
"1FFF*FFF2");
724 GEOSPreparedGeom_destroy(prepared_edge);
725 GEOSGeom_destroy(edgegg);
726 GEOSGeom_destroy(eegg);
737 match = GEOSRelatePatternMatch(relate,
"1********");
740 GEOSPreparedGeom_destroy(prepared_edge);
741 GEOSGeom_destroy(edgegg);
742 GEOSGeom_destroy(eegg);
747 lwerror(
"Spatial exception - geometry intersects edge %" 753 match = GEOSRelatePatternMatch(relate,
"T********");
756 GEOSPreparedGeom_destroy(prepared_edge);
757 GEOSGeom_destroy(edgegg);
758 GEOSGeom_destroy(eegg);
763 lwerror(
"SQL/MM Spatial exception - geometry crosses edge %" 769 LWDEBUGF(2,
"Edge %d analisys completed, it does no harm", edge_id);
772 GEOSGeom_destroy(eegg);
777 GEOSPreparedGeom_destroy(prepared_edge);
778 GEOSGeom_destroy(edgegg);
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Datum contains(PG_FUNCTION_ARGS)
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
void lwgeom_geos_error(const char *fmt,...)
const LWT_BE_IFACE * be_iface
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWDEBUGF(level, msg,...)
static LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, int *numelems, int fields, int limit)
static LWT_ISO_NODE * lwt_be_getNodeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, int *numelems, int fields, int limit)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.