2350 const LWPOINT *start_node_geom = NULL;
2351 const LWPOINT *end_node_geom = NULL;
2365 lwerror(
"SQL/MM Spatial exception - curve not simple");
2372 newedge.
geom = geom;
2381 lwerror(
"Invalid edge (no two distinct vertices exist)");
2394 lwerror(
"Invalid edge (no two distinct vertices exist)");
2399 lwerror(
"error computing azimuth of first edgeend [%.15g %.15g,%.15g %.15g]",
2400 p1.
x, p1.
y, pn.
x, pn.
y);
2403 LWDEBUGF(1,
"edge's start node is %g,%g", p1.
x, p1.
y);
2411 lwerror(
"Invalid clean edge (no two distinct vertices exist) - should not happen");
2416 lwerror(
"error computing azimuth of last edgeend [%.15g %.15g,%.15g %.15g]",
2417 p2.
x, p2.
y, pn.
x, pn.
y);
2420 LWDEBUGF(1,
"edge's end node is %g,%g", p2.
x, p2.
y);
2427 if ( start_node != end_node ) {
2429 node_ids[0] = start_node;
2430 node_ids[1] = end_node;
2433 node_ids[0] = start_node;
2437 if ( num_nodes < 0 ) {
2441 for ( i=0; i<num_nodes; ++i )
2453 lwerror(
"SQL/MM Spatial exception - geometry crosses an edge" 2459 LWDEBUGF(1,
"Node %d, with geom %p (looking for %d and %d)",
2461 if ( node->
node_id == start_node ) {
2462 start_node_geom = node->
geom;
2464 if ( node->
node_id == end_node ) {
2465 end_node_geom = node->
geom;
2471 if ( ! start_node_geom )
2474 lwerror(
"SQL/MM Spatial exception - non-existent node");
2479 pa = start_node_geom->
point;
2484 lwerror(
"SQL/MM Spatial exception" 2485 " - start node not geometry start point." 2492 if ( ! end_node_geom )
2495 lwerror(
"SQL/MM Spatial exception - non-existent node");
2500 pa = end_node_geom->
point;
2505 lwerror(
"SQL/MM Spatial exception" 2506 " - end node not geometry end point." 2525 if ( newedge.
edge_id == -1 ) {
2531 int isclosed = start_node == end_node;
2534 isclosed ? &epan : NULL, -1 );
2539 LWDEBUGF(1,
"New edge %d is connected on start node, " 2540 "next_right is %d, prev_left is %d",
2552 LWDEBUGF(1,
"New edge %d is isolated on start node, " 2553 "next_right is %d, prev_left is %d",
2558 isclosed ? &span : NULL, -1 );
2563 LWDEBUGF(1,
"New edge %d is connected on end node, " 2564 "next_left is %d, prev_right is %d",
2570 lwerror(
"Side-location conflict: " 2571 "new edge starts in face" 2582 lwerror(
"Side-location conflict: " 2583 "new edge starts in face" 2594 LWDEBUGF(1,
"New edge %d is isolated on end node, " 2595 "next_left is %d, prev_right is %d",
2607 "faces mismatch: invalid topology ?",
2613 lwerror(
"Could not derive edge face from linked primitives:" 2614 " invalid topology ?");
2626 }
else if ( ret == 0 ) {
2627 lwerror(
"Insertion of split edge failed (no reason)");
2635 if ( llabs(prev_left) != newedge.
edge_id )
2637 if ( prev_left > 0 )
2654 &updedge, updfields,
2664 if ( llabs(prev_right) != newedge.
edge_id )
2666 if ( prev_right > 0 )
2678 seledge.
edge_id = -prev_right;
2683 &updedge, updfields,
2727 LWDEBUG(1,
"New edge is dangling, so it cannot split any face");
2739 if ( newface1 == 0 ) {
2740 LWDEBUG(1,
"New edge does not split any face");
2749 if ( newface == 0 ) {
2750 LWDEBUG(1,
"New edge does not split any face");
2760 if ( newface < 0 )
return newedge.
edge_id;
static int _lwt_CheckEdgeCrossing(LWT_TOPOLOGY *topo, LWT_ELEMID start_node, LWT_ELEMID end_node, const LWLINE *geom, LWT_ELEMID myself)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
#define LWT_COL_NODE_CONTAINING_FACE
LWT_ELEMID containing_face
void lwgeom_free(LWGEOM *geom)
static int _lwt_FirstDistinctVertex2D(const POINTARRAY *pa, POINT2D *ref, int from, int dir, POINT2D *op)
static int lwt_be_updateTopoGeomFaceSplit(LWT_TOPOLOGY *topo, LWT_ELEMID split_face, LWT_ELEMID new_face1, LWT_ELEMID new_face2)
#define LWDEBUG(level, msg)
static LWT_ELEMID _lwt_AddFaceSplit(LWT_TOPOLOGY *topo, LWT_ELEMID sedge, LWT_ELEMID face, int mbr_only)
static int lwt_be_updateNodes(LWT_TOPOLOGY *topo, const LWT_ISO_NODE *sel_node, int sel_fields, const LWT_ISO_NODE *upd_node, int upd_fields, const LWT_ISO_NODE *exc_node, int exc_fields)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int lwt_be_updateEdges(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *sel_edge, int sel_fields, const LWT_ISO_EDGE *upd_edge, int upd_fields, const LWT_ISO_EDGE *exc_edge, int exc_fields)
const LWT_BE_IFACE * be_iface
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
static int lwt_be_deleteFacesById(const LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int numelems)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWT_ELEMID lwt_be_getNextEdgeId(LWT_TOPOLOGY *topo)
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_NODE_NODE_ID
Node fields.
#define LWT_COL_EDGE_NEXT_LEFT
static int _lwt_FindAdjacentEdges(LWT_TOPOLOGY *topo, LWT_ELEMID node, edgeend *data, edgeend *other, int myedge_id)
int lwt_be_insertEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edge, int numelems)
#define LWT_COL_EDGE_NEXT_RIGHT
int lwgeom_is_simple(const LWGEOM *lwgeom)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Remove repeated points!
LWT_ISO_NODE * lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int *numelems, int fields)
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
#define LWDEBUGF(level, msg,...)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.