PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWT_ELEMID lwt_AddIsoNode ( LWT_TOPOLOGY topo,
LWT_ELEMID  face,
LWPOINT pt,
int  skipChecks 
)

Add an isolated node.

For ST_AddIsoNode

Parameters
topothe topology to operate on
facethe identifier of containing face or -1 for "unknown"
ptthe node position
skipChecksif non-zero skips consistency checks (coincident nodes, crossing edges, actual face containement)
Returns
ID of the newly added node, or -1 on error (liblwgeom error handler will be invoked with error message)

Definition at line 525 of file lwgeom_topo.c.

References LWT_TOPOLOGY_T::be_iface, LWT_ISO_NODE::containing_face, LWT_ISO_NODE::geom, lwerror(), lwt_be_ExistsCoincidentNode(), lwt_be_ExistsEdgeIntersectingPoint(), lwt_be_getFaceContainingPoint(), lwt_be_insertNodes(), lwt_be_lastErrorMessage(), and LWT_ISO_NODE::node_id.

Referenced by lwt_AddPoint().

527 {
528  LWT_ELEMID foundInFace = -1;
529 
530  if ( ! skipISOChecks )
531  {
532  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
533  {
534  lwerror("SQL/MM Spatial exception - coincident node");
535  return -1;
536  }
537  if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) ) /*x*/
538  {
539  lwerror("SQL/MM Spatial exception - edge crosses node.");
540  return -1;
541  }
542  }
543 
544  if ( face == -1 || ! skipISOChecks )
545  {
546  foundInFace = lwt_be_getFaceContainingPoint(topo, pt); /*x*/
547  if ( foundInFace == -2 ) {
548  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
549  return -1;
550  }
551  if ( foundInFace == -1 ) foundInFace = 0;
552  }
553 
554  if ( face == -1 ) {
555  face = foundInFace;
556  }
557  else if ( ! skipISOChecks && foundInFace != face ) {
558 #if 0
559  lwerror("SQL/MM Spatial exception - within face %d (not %d)",
560  foundInFace, face);
561 #else
562  lwerror("SQL/MM Spatial exception - not within face");
563 #endif
564  return -1;
565  }
566 
567  LWT_ISO_NODE node;
568  node.node_id = -1;
569  node.containing_face = face;
570  node.geom = pt;
571  if ( ! lwt_be_insertNodes(topo, &node, 1) )
572  {
573  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
574  return -1;
575  }
576 
577  return node.node_id;
578 }
LWT_ELEMID containing_face
LWPOINT * geom
int lwt_be_ExistsEdgeIntersectingPoint(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:402
int lwt_be_insertNodes(LWT_TOPOLOGY *topo, LWT_ISO_NODE *node, int numelems)
Definition: lwgeom_topo.c:195
const LWT_BE_IFACE * be_iface
int lwt_be_ExistsCoincidentNode(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:390
LWT_ELEMID node_id
LWT_INT64 LWT_ELEMID
Identifier of topology element.
LWT_ELEMID lwt_be_getFaceContainingPoint(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:330
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:120
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102

Here is the call graph for this function:

Here is the caller graph for this function: