PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ _lwt_AddIsoNode()

static LWT_ELEMID _lwt_AddIsoNode ( LWT_TOPOLOGY topo,
LWT_ELEMID  face,
LWPOINT pt,
int  skipISOChecks,
int  checkFace 
)
static
Parameters
checkFaceif non zero will check the given face for really containing the point or determine the face when given face is -1. Use 0 to simply use the given face value, no matter what (effectively allowing adding a non-isolated point when used with face=-1).

Definition at line 523 of file lwgeom_topo.c.

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

References LWT_TOPOLOGY_T::be_iface, LWT_ISO_NODE::containing_face, LWT_ISO_NODE::geom, lwerror(), lwpoint_is_empty(), 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(), and lwt_AddIsoNode().

Here is the call graph for this function:
Here is the caller graph for this function: