PostGIS  3.0.6dev-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 932 of file lwgeom_topo.c.

933 {
934  LWGEOM *split;
935  LWCOLLECTION *split_col;
936  uint64_t i;
937 
938  /* Get edge */
939  i = 1;
940  LWDEBUG(1, "calling lwt_be_getEdgeById");
941  *oldedge = lwt_be_getEdgeById(topo, &edge, &i, LWT_COL_EDGE_ALL);
942  LWDEBUGF(1, "lwt_be_getEdgeById returned %p", *oldedge);
943  if ( ! *oldedge )
944  {
945  LWDEBUGF(1, "lwt_be_getEdgeById returned NULL and set i=%d", i);
946  if (i == UINT64_MAX)
947  {
948  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
949  return NULL;
950  }
951  else if ( i == 0 )
952  {
953  lwerror("SQL/MM Spatial exception - non-existent edge");
954  return NULL;
955  }
956  else
957  {
958  lwerror("Backend coding error: getEdgeById callback returned NULL "
959  "but numelements output parameter has value %d "
960  "(expected 0 or 1)", i);
961  return NULL;
962  }
963  }
964 
965 
966  /*
967  * - check if a coincident node already exists
968  */
969  if ( ! skipISOChecks )
970  {
971  LWDEBUG(1, "calling lwt_be_ExistsCoincidentNode");
972  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
973  {
974  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
975  _lwt_release_edges(*oldedge, 1);
976  lwerror("SQL/MM Spatial exception - coincident node");
977  return NULL;
978  }
979  LWDEBUG(1, "lwt_be_ExistsCoincidentNode returned");
980  }
981 
982  /* Split edge */
983  split = lwgeom_split((LWGEOM*)(*oldedge)->geom, (LWGEOM*)pt);
984  if ( ! split )
985  {
986  _lwt_release_edges(*oldedge, 1);
987  lwerror("could not split edge by point ?");
988  return NULL;
989  }
990  split_col = lwgeom_as_lwcollection(split);
991  if ( ! split_col ) {
992  _lwt_release_edges(*oldedge, 1);
993  lwgeom_free(split);
994  lwerror("lwgeom_as_lwcollection returned NULL");
995  return NULL;
996  }
997  if (split_col->ngeoms < 2) {
998  _lwt_release_edges(*oldedge, 1);
999  lwgeom_free(split);
1000  lwerror("SQL/MM Spatial exception - point not on edge");
1001  return NULL;
1002  }
1003 
1004 #if 0
1005  {
1006  size_t sz;
1007  char *wkt = lwgeom_to_wkt((LWGEOM*)split_col, WKT_EXTENDED, 2, &sz);
1008  LWDEBUGF(1, "returning split col: %s", wkt);
1009  lwfree(wkt);
1010  }
1011 #endif
1012  return split_col;
1013 }
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:2132
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:676
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:215
#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:382
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:451
uint32_t ngeoms
Definition: liblwgeom.h:566
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: