2278 const LWPOINT *start_node_geom = NULL;
2279 const LWPOINT *end_node_geom = NULL;
2293 lwerror(
"SQL/MM Spatial exception - curve not simple");
2300 newedge.
geom = geom;
2309 lwerror(
"Invalid edge (no two distinct vertices exist)");
2322 lwerror(
"Invalid edge (no two distinct vertices exist)");
2327 lwerror(
"error computing azimuth of first edgeend [%.15g %.15g,%.15g %.15g]",
2328 p1.
x, p1.
y, pn.
x, pn.
y);
2331 LWDEBUGF(1,
"edge's start node is %g,%g", p1.
x, p1.
y);
2339 lwerror(
"Invalid clean edge (no two distinct vertices exist) - should not happen");
2344 lwerror(
"error computing azimuth of last edgeend [%.15g %.15g,%.15g %.15g]",
2345 p2.
x, p2.
y, pn.
x, pn.
y);
2348 LWDEBUGF(1,
"edge's end node is %g,%g", p2.
x, p2.
y);
2355 if ( start_node != end_node ) {
2357 node_ids[0] = start_node;
2358 node_ids[1] = end_node;
2361 node_ids[0] = start_node;
2365 if (num_nodes == UINT64_MAX)
2370 for ( i=0; i<num_nodes; ++i )
2382 lwerror(
"SQL/MM Spatial exception - geometry crosses an edge"
2388 LWDEBUGF(1,
"Node %d, with geom %p (looking for %d and %d)",
2390 if ( node->
node_id == start_node ) {
2391 start_node_geom = node->
geom;
2393 if ( node->
node_id == end_node ) {
2394 end_node_geom = node->
geom;
2400 if ( ! start_node_geom )
2403 lwerror(
"SQL/MM Spatial exception - non-existent node");
2408 pa = start_node_geom->
point;
2413 lwerror(
"SQL/MM Spatial exception"
2414 " - start node not geometry start point."
2421 if ( ! end_node_geom )
2424 lwerror(
"SQL/MM Spatial exception - non-existent node");
2429 pa = end_node_geom->
point;
2434 lwerror(
"SQL/MM Spatial exception"
2435 " - end node not geometry end point."
2454 if ( newedge.
edge_id == -1 ) {
2460 int isclosed = start_node == end_node;
2463 isclosed ? &epan : NULL, -1 );
2468 LWDEBUGF(1,
"New edge %d is connected on start node, "
2469 "next_right is %d, prev_left is %d",
2481 LWDEBUGF(1,
"New edge %d is isolated on start node, "
2482 "next_right is %d, prev_left is %d",
2487 isclosed ? &span : NULL, -1 );
2492 LWDEBUGF(1,
"New edge %d is connected on end node, "
2493 "next_left is %d, prev_right is %d",
2499 lwerror(
"Side-location conflict: "
2500 "new edge starts in face"
2511 lwerror(
"Side-location conflict: "
2512 "new edge starts in face"
2523 LWDEBUGF(1,
"New edge %d is isolated on end node, "
2524 "next_left is %d, prev_right is %d",
2536 "faces mismatch: invalid topology ?",
2540 else if ( newedge.
face_left == -1 && modFace > -1 )
2542 lwerror(
"Could not derive edge face from linked primitives:"
2543 " invalid topology ?");
2555 }
else if ( ret == 0 ) {
2556 lwerror(
"Insertion of split edge failed (no reason)");
2564 if ( llabs(prev_left) != newedge.
edge_id )
2566 if ( prev_left > 0 )
2583 &updedge, updfields,
2593 if ( llabs(prev_right) != newedge.
edge_id )
2595 if ( prev_right > 0 )
2607 seledge.
edge_id = -prev_right;
2612 &updedge, updfields,
2654 if ( modFace > -1 ) {
2658 LWDEBUG(1,
"New edge is dangling, so it cannot split any face");
2670 if ( newface1 == 0 ) {
2671 LWDEBUG(1,
"New edge does not split any face");
2680 if ( newface == 0 ) {
2681 LWDEBUG(1,
"New edge does not split any face");
2691 if ( newface < 0 )
return newedge.
edge_id;
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
void lwgeom_free(LWGEOM *geom)
int lwgeom_is_simple(const LWGEOM *lwgeom)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_NEXT_RIGHT
#define LWT_COL_NODE_CONTAINING_FACE
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_EDGE_NEXT_LEFT
#define LWT_COL_NODE_NODE_ID
Node fields.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
static int lwt_be_deleteFacesById(const LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t numelems)
static int _lwt_FirstDistinctVertex2D(const POINTARRAY *pa, POINT2D *ref, int from, int dir, POINT2D *op)
LWT_ELEMID lwt_be_getNextEdgeId(LWT_TOPOLOGY *topo)
static int lwt_be_updateTopoGeomFaceSplit(LWT_TOPOLOGY *topo, LWT_ELEMID split_face, LWT_ELEMID new_face1, LWT_ELEMID new_face2)
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)
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)
static int _lwt_FindAdjacentEdges(LWT_TOPOLOGY *topo, LWT_ELEMID node, edgeend *data, edgeend *other, int myedge_id)
LWT_ISO_NODE * lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
static LWT_ELEMID _lwt_AddFaceSplit(LWT_TOPOLOGY *topo, LWT_ELEMID sedge, LWT_ELEMID face, int mbr_only)
int lwt_be_insertEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edge, uint64_t numelems)
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)
LWT_ELEMID containing_face
const LWT_BE_IFACE * be_iface