PostGIS  3.7.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 526 of file lwgeom_topo.c.

528 {
529  LWT_ELEMID foundInFace = -1;
530 
531  if ( lwpoint_is_empty(pt) )
532  {
533  lwerror("Cannot add empty point as isolated node");
534  return -1;
535  }
536 
537 
538  if ( ! skipISOChecks )
539  {
540  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
541  {
542  lwerror("SQL/MM Spatial exception - coincident node");
543  return -1;
544  }
545  if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) ) /*x*/
546  {
547  lwerror("SQL/MM Spatial exception - edge crosses node.");
548  return -1;
549  }
550  }
551 
552  if ( checkFace && ( face == -1 || ! skipISOChecks ) )
553  {
554  foundInFace = lwt_GetFaceContainingPoint(topo, pt); /*x*/
555  if ( foundInFace == -1 ) {
556  PGTOPO_BE_ERROR();
557  return -1;
558  }
559  if ( foundInFace == -1 ) foundInFace = 0;
560  }
561 
562  if ( face == -1 ) {
563  face = foundInFace;
564  }
565  else if ( ! skipISOChecks && foundInFace != face ) {
566 #if 0
567  lwerror("SQL/MM Spatial exception - within face %d (not %d)",
568  foundInFace, face);
569 #else
570  lwerror("SQL/MM Spatial exception - not within face");
571 #endif
572  return -1;
573  }
574 
575  LWT_ISO_NODE node;
576  node.node_id = -1;
577  node.containing_face = face;
578  node.geom = pt;
579  if ( ! lwt_be_insertNodes(topo, &node, 1) )
580  {
581  PGTOPO_BE_ERROR();
582  return -1;
583  }
584 
585  return node.node_id;
586 }
int lwpoint_is_empty(const LWPOINT *point)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define PGTOPO_BE_ERROR()
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_ELEMID lwt_be_ExistsCoincidentNode(LWT_TOPOLOGY *topo, const LWPOINT *pt)
Definition: lwgeom_topo.c:379
LWT_ELEMID lwt_be_ExistsEdgeIntersectingPoint(LWT_TOPOLOGY *topo, const LWPOINT *pt)
Definition: lwgeom_topo.c:392
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:7669
int lwt_be_insertNodes(LWT_TOPOLOGY *topo, LWT_ISO_NODE *node, uint64_t numelems)
Definition: lwgeom_topo.c:185
LWT_ELEMID node_id
LWT_ELEMID containing_face
LWPOINT * geom

References LWT_ISO_NODE::containing_face, LWT_ISO_NODE::geom, lwerror(), lwpoint_is_empty(), lwt_be_ExistsCoincidentNode(), lwt_be_ExistsEdgeIntersectingPoint(), lwt_be_insertNodes(), lwt_GetFaceContainingPoint(), LWT_ISO_NODE::node_id, and PGTOPO_BE_ERROR.

Referenced by _lwt_AddPoint(), and lwt_AddIsoNode().

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