PostGIS  2.2.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 529 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().

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

Here is the call graph for this function:

Here is the caller graph for this function: