2274 const LWPOINT *start_node_geom = NULL;
2275 const LWPOINT *end_node_geom = NULL;
2289 lwerror(
"SQL/MM Spatial exception - curve not simple");
2296 newedge.
geom = geom;
2305 lwerror(
"Invalid edge (no two distinct vertices exist)");
2318 lwerror(
"Invalid edge (no two distinct vertices exist)");
2323 lwerror(
"error computing azimuth of first edgeend [%.15g %.15g,%.15g %.15g]",
2324 p1.
x, p1.
y, pn.
x, pn.
y);
2327 LWDEBUGF(1,
"edge's start node is %g,%g", p1.
x, p1.
y);
2335 lwerror(
"Invalid clean edge (no two distinct vertices exist) - should not happen");
2340 lwerror(
"error computing azimuth of last edgeend [%.15g %.15g,%.15g %.15g]",
2341 p2.
x, p2.
y, pn.
x, pn.
y);
2344 LWDEBUGF(1,
"edge's end node is %g,%g", p2.
x, p2.
y);
2351 if ( start_node != end_node ) {
2353 node_ids[0] = start_node;
2354 node_ids[1] = end_node;
2357 node_ids[0] = start_node;
2361 if ( num_nodes < 0 ) {
2365 for ( i=0; i<num_nodes; ++i )
2377 lwerror(
"SQL/MM Spatial exception - geometry crosses an edge"
2383 LWDEBUGF(1,
"Node %d, with geom %p (looking for %d and %d)",
2385 if ( node->
node_id == start_node ) {
2386 start_node_geom = node->
geom;
2388 if ( node->
node_id == end_node ) {
2389 end_node_geom = node->
geom;
2395 if ( ! start_node_geom )
2398 lwerror(
"SQL/MM Spatial exception - non-existent node");
2403 pa = start_node_geom->
point;
2408 lwerror(
"SQL/MM Spatial exception"
2409 " - start node not geometry start point."
2416 if ( ! end_node_geom )
2419 lwerror(
"SQL/MM Spatial exception - non-existent node");
2424 pa = end_node_geom->
point;
2429 lwerror(
"SQL/MM Spatial exception"
2430 " - end node not geometry end point."
2449 if ( newedge.
edge_id == -1 ) {
2455 int isclosed = start_node == end_node;
2458 isclosed ? &epan : NULL, -1 );
2463 LWDEBUGF(1,
"New edge %d is connected on start node, "
2464 "next_right is %d, prev_left is %d",
2476 LWDEBUGF(1,
"New edge %d is isolated on start node, "
2477 "next_right is %d, prev_left is %d",
2482 isclosed ? &span : NULL, -1 );
2487 LWDEBUGF(1,
"New edge %d is connected on end node, "
2488 "next_left is %d, prev_right is %d",
2494 lwerror(
"Side-location conflict: "
2495 "new edge starts in face"
2506 lwerror(
"Side-location conflict: "
2507 "new edge starts in face"
2518 LWDEBUGF(1,
"New edge %d is isolated on end node, "
2519 "next_left is %d, prev_right is %d",
2531 "faces mismatch: invalid topology ?",
2535 else if ( newedge.
face_left == -1 && modFace > -1 )
2537 lwerror(
"Could not derive edge face from linked primitives:"
2538 " invalid topology ?");
2550 }
else if ( ret == 0 ) {
2551 lwerror(
"Insertion of split edge failed (no reason)");
2559 if ( llabs(prev_left) != newedge.
edge_id )
2561 if ( prev_left > 0 )
2578 &updedge, updfields,
2588 if ( llabs(prev_right) != newedge.
edge_id )
2590 if ( prev_right > 0 )
2602 seledge.
edge_id = -prev_right;
2607 &updedge, updfields,
2649 if ( modFace > -1 ) {
2653 LWDEBUG(1,
"New edge is dangling, so it cannot split any face");
2665 if ( newface1 == 0 ) {
2666 LWDEBUG(1,
"New edge does not split any face");
2675 if ( newface == 0 ) {
2676 LWDEBUG(1,
"New edge does not split any face");
2686 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)
LWT_ISO_NODE * lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int *numelems, int fields)
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)
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, int numelems)
static int lwt_be_deleteFacesById(const LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, int 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