PostGIS  3.2.2dev-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 973 of file lwgeom_topo.c.

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