PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ _lwt_EdgeSplit()

static LWCOLLECTION* _lwt_EdgeSplit ( LWT_TOPOLOGY topo,
LWT_ELEMID  edge,
LWPOINT pt,
int  skipISOChecks,
LWT_ISO_EDGE **  oldedge 
)
static

Definition at line 952 of file lwgeom_topo.c.

953 {
954  LWGEOM *split;
955  LWCOLLECTION *split_col;
956  uint64_t i;
957 
958  /* Get edge */
959  i = 1;
960  LWDEBUG(1, "calling lwt_be_getEdgeById");
961  *oldedge = lwt_be_getEdgeById(topo, &edge, &i, LWT_COL_EDGE_ALL);
962  LWDEBUGF(1, "lwt_be_getEdgeById returned %p", *oldedge);
963  if ( ! *oldedge )
964  {
965  LWDEBUGF(1, "lwt_be_getEdgeById returned NULL and set i=%d", i);
966  if (i == UINT64_MAX)
967  {
968  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
969  return NULL;
970  }
971  else if ( i == 0 )
972  {
973  lwerror("SQL/MM Spatial exception - non-existent edge");
974  return NULL;
975  }
976  else
977  {
978  lwerror("Backend coding error: getEdgeById callback returned NULL "
979  "but numelements output parameter has value %d "
980  "(expected 0 or 1)", i);
981  return NULL;
982  }
983  }
984 
985 
986  /*
987  * - check if a coincident node already exists
988  */
989  if ( ! skipISOChecks )
990  {
991  LWDEBUG(1, "calling lwt_be_ExistsCoincidentNode");
992  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
993  {
994  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
995  _lwt_release_edges(*oldedge, 1);
996  lwerror("SQL/MM Spatial exception - coincident node");
997  return NULL;
998  }
999  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
1000  }
1001 
1002  /* Split edge */
1003  split = lwgeom_split((LWGEOM*)(*oldedge)->geom, (LWGEOM*)pt);
1004  if ( ! split )
1005  {
1006  _lwt_release_edges(*oldedge, 1);
1007  lwerror("could not split edge by point ?");
1008  return NULL;
1009  }
1010  split_col = lwgeom_as_lwcollection(split);
1011  if ( ! split_col ) {
1012  _lwt_release_edges(*oldedge, 1);
1013  lwgeom_free(split);
1014  lwerror("lwgeom_as_lwcollection returned NULL");
1015  return NULL;
1016  }
1017  if (split_col->ngeoms < 2) {
1018  _lwt_release_edges(*oldedge, 1);
1019  lwgeom_free(split);
1020  lwerror("SQL/MM Spatial exception - point not on edge");
1021  return NULL;
1022  }
1023 
1024 #if 0
1025  {
1026  size_t sz;
1027  char *wkt = lwgeom_to_wkt((LWGEOM*)split_col, WKT_EXTENDED, 2, &sz);
1028  LWDEBUGF(1, "returning split col: %s", wkt);
1029  lwfree(wkt);
1030  }
1031 #endif
1032  return split_col;
1033 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
#define WKT_EXTENDED
Definition: liblwgeom.h:2186
void lwfree(void *mem)
Definition: lwutil.c:242
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:708
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:233
#define LWT_COL_EDGE_ALL
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:125
LWT_ISO_EDGE * lwt_be_getEdgeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
Definition: lwgeom_topo.c:226
int lwt_be_ExistsCoincidentNode(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:390
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:471
uint32_t ngeoms
Definition: liblwgeom.h:580
const LWT_BE_IFACE * be_iface

References _lwt_release_edges(), LWT_TOPOLOGY_T::be_iface, LWDEBUG, LWDEBUGF, lwerror(), lwfree(), lwgeom_as_lwcollection(), lwgeom_free(), lwgeom_split(), lwgeom_to_wkt(), lwt_be_ExistsCoincidentNode(), lwt_be_getEdgeById(), lwt_be_lastErrorMessage(), LWT_COL_EDGE_ALL, LWCOLLECTION::ngeoms, and WKT_EXTENDED.

Referenced by lwt_ModEdgeSplit(), and lwt_NewEdgesSplit().

Here is the call graph for this function:
Here is the caller graph for this function: