PostGIS  2.5.7dev-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 935 of file lwgeom_topo.c.

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