PostGIS  3.2.2dev-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 525 of file lwgeom_topo.c.

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