PostGIS  3.3.9dev-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 531 of file lwgeom_topo.c.

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