PostGIS  3.4.0dev-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 537 of file lwgeom_topo.c.

539 {
540  LWT_ELEMID foundInFace = -1;
541 
542  if ( lwpoint_is_empty(pt) )
543  {
544  lwerror("Cannot add empty point as isolated node");
545  return -1;
546  }
547 
548 
549  if ( ! skipISOChecks )
550  {
551  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
552  {
553  lwerror("SQL/MM Spatial exception - coincident node");
554  return -1;
555  }
556  if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) ) /*x*/
557  {
558  lwerror("SQL/MM Spatial exception - edge crosses node.");
559  return -1;
560  }
561  }
562 
563  if ( checkFace && ( face == -1 || ! skipISOChecks ) )
564  {
565  foundInFace = lwt_GetFaceContainingPoint(topo, pt); /*x*/
566  if ( foundInFace == -1 ) {
567  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
568  return -1;
569  }
570  if ( foundInFace == -1 ) foundInFace = 0;
571  }
572 
573  if ( face == -1 ) {
574  face = foundInFace;
575  }
576  else if ( ! skipISOChecks && foundInFace != face ) {
577 #if 0
578  lwerror("SQL/MM Spatial exception - within face %d (not %d)",
579  foundInFace, face);
580 #else
581  lwerror("SQL/MM Spatial exception - not within face");
582 #endif
583  return -1;
584  }
585 
586  LWT_ISO_NODE node;
587  node.node_id = -1;
588  node.containing_face = face;
589  node.geom = pt;
590  if ( ! lwt_be_insertNodes(topo, &node, 1) )
591  {
592  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
593  return -1;
594  }
595 
596  return node.node_id;
597 }
int lwpoint_is_empty(const LWPOINT *point)
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:403
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:125
LWT_ELEMID lwt_GetFaceContainingPoint(LWT_TOPOLOGY *topo, const LWPOINT *pt)
Find the face-id of the face properly containing a given point.
Definition: lwgeom_topo.c:7034
int lwt_be_insertNodes(LWT_TOPOLOGY *topo, LWT_ISO_NODE *node, uint64_t numelems)
Definition: lwgeom_topo.c:196
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_insertNodes(), lwt_be_lastErrorMessage(), lwt_GetFaceContainingPoint(), 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: