Add an isolated edge connecting two existing isolated nodes.
920{
921 uint64_t num_nodes;
922 uint64_t i;
928 int skipISOChecks = 0;
930
931
932
933
934 if (startNode == endNode)
935 {
936 lwerror(
"Closed edges would not be isolated, try lwt_AddEdgeNewFaces");
937 return -1;
938 }
939
940 if ( ! skipISOChecks )
941 {
942
944 {
945 lwerror(
"SQL/MM Spatial exception - curve not simple");
946 return -1;
947 }
948 }
949
950
951
952
953
954
955
956
957
958 num_nodes = 2;
959 node_ids[0] = startNode;
960 node_ids[1] = endNode;
963 if (num_nodes == UINT64_MAX)
964 {
966 return -1;
967 }
968 else if ( num_nodes < 2 )
969 {
971 lwerror(
"SQL/MM Spatial exception - non-existent node");
972 return -1;
973 }
974 for ( i=0; i<num_nodes; ++i )
975 {
978 {
980 lwerror(
"SQL/MM Spatial exception - not isolated node");
981 return -1;
982 }
985 {
987 lwerror(
"SQL/MM Spatial exception - nodes in different faces");
988 return -1;
989 }
990
991 if ( ! skipISOChecks )
992 {
994 {
995
999 {
1001 lwerror(
"SQL/MM Spatial exception - "
1002 "start node not geometry start point.");
1003 return -1;
1004 }
1005 }
1006 else
1007 {
1008
1012 {
1014 lwerror(
"SQL/MM Spatial exception - "
1015 "end node not geometry end point.");
1016 return -1;
1017 }
1018 }
1019 }
1020 }
1021
1023
1024 if ( ! skipISOChecks )
1025 {
1027 {
1028
1029 return -1;
1030 }
1031 }
1032
1033
1034
1035
1036
1038 if ( newedge.
edge_id == -1 ) {
1040 return -1;
1041 }
1042
1043
1044 if ( containing_face == -1 ) containing_face = 0;
1045
1052
1054 if ( ret == -1 ) {
1056 return -1;
1057 } else if ( ret == 0 ) {
1058 lwerror(
"Insertion of split edge failed (no reason)");
1059 return -1;
1060 }
1061
1062
1063
1064
1065
1066
1067
1068 updated_nodes[0].
node_id = startNode;
1070 updated_nodes[1].
node_id = endNode;
1074 if ( ret == -1 ) {
1076 return -1;
1077 }
1078
1080}
int lwgeom_is_simple(const LWGEOM *lwgeom)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
#define P2D_SAME_STRICT(a, b)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_NODE_CONTAINING_FACE
#define PGTOPO_BE_ERROR()
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_ELEMID lwt_be_getNextEdgeId(LWT_TOPOLOGY *topo)
static int lwt_be_updateNodesById(LWT_TOPOLOGY *topo, const LWT_ISO_NODE *nodes, int numnodes, int upd_fields)
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_insertEdges(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edge, uint64_t numelems)
LWT_ISO_NODE * lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
LWT_ELEMID containing_face