PostGIS  3.3.9dev-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 979 of file lwgeom_topo.c.

980 {
981  LWGEOM *split;
982  LWCOLLECTION *split_col;
983  uint64_t i;
984 
985  /* Get edge */
986  i = 1;
987  LWDEBUG(1, "calling lwt_be_getEdgeById");
988  *oldedge = lwt_be_getEdgeById(topo, &edge, &i, LWT_COL_EDGE_ALL);
989  LWDEBUGF(1, "lwt_be_getEdgeById returned %p", *oldedge);
990  if ( ! *oldedge )
991  {
992  LWDEBUGF(1, "lwt_be_getEdgeById returned NULL and set i=%d", i);
993  if (i == UINT64_MAX)
994  {
995  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
996  return NULL;
997  }
998  else if ( i == 0 )
999  {
1000  lwerror("SQL/MM Spatial exception - non-existent edge");
1001  return NULL;
1002  }
1003  else
1004  {
1005  lwerror("Backend coding error: getEdgeById callback returned NULL "
1006  "but numelements output parameter has value %d "
1007  "(expected 0 or 1)", i);
1008  return NULL;
1009  }
1010  }
1011 
1012 
1013  /*
1014  * - check if a coincident node already exists
1015  */
1016  if ( ! skipISOChecks )
1017  {
1018  LWDEBUG(1, "calling lwt_be_ExistsCoincidentNode");
1019  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
1020  {
1021  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
1022  _lwt_release_edges(*oldedge, 1);
1023  lwerror("SQL/MM Spatial exception - coincident node");
1024  return NULL;
1025  }
1026  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
1027  }
1028 
1029  /* Split edge */
1030  split = lwgeom_split((LWGEOM*)(*oldedge)->geom, (LWGEOM*)pt);
1031  if ( ! split )
1032  {
1033  _lwt_release_edges(*oldedge, 1);
1034  lwerror("could not split edge by point ?");
1035  return NULL;
1036  }
1037  split_col = lwgeom_as_lwcollection(split);
1038  if ( ! split_col ) {
1039  _lwt_release_edges(*oldedge, 1);
1040  lwgeom_free(split);
1041  lwerror("lwgeom_as_lwcollection returned NULL");
1042  return NULL;
1043  }
1044  if (split_col->ngeoms < 2) {
1045  _lwt_release_edges(*oldedge, 1);
1046  lwgeom_free(split);
1047  lwerror("SQL/MM Spatial exception - point not on edge");
1048  return NULL;
1049  }
1050 
1051 #if 0
1052  {
1053  size_t sz;
1054  char *wkt = lwgeom_to_wkt((LWGEOM*)split_col, WKT_EXTENDED, 2, &sz);
1055  LWDEBUGF(1, "returning split col: %s", wkt);
1056  lwfree(wkt);
1057  }
1058 #endif
1059  return split_col;
1060 }
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:2168
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:119
LWT_ISO_EDGE * lwt_be_getEdgeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
Definition: lwgeom_topo.c:220
int lwt_be_ExistsCoincidentNode(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:384
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:465
uint32_t ngeoms
Definition: liblwgeom.h:595
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: