PostGIS  3.0.6dev-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 517 of file lwgeom_topo.c.

519 {
520  LWT_ELEMID foundInFace = -1;
521 
522  if ( lwpoint_is_empty(pt) )
523  {
524  lwerror("Cannot add empty point as isolated node");
525  return -1;
526  }
527 
528 
529  if ( ! skipISOChecks )
530  {
531  if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
532  {
533  lwerror("SQL/MM Spatial exception - coincident node");
534  return -1;
535  }
536  if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) ) /*x*/
537  {
538  lwerror("SQL/MM Spatial exception - edge crosses node.");
539  return -1;
540  }
541  }
542 
543  if ( checkFace && ( face == -1 || ! skipISOChecks ) )
544  {
545  foundInFace = lwt_be_getFaceContainingPoint(topo, pt); /*x*/
546  if ( foundInFace == -2 ) {
547  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
548  return -1;
549  }
550  if ( foundInFace == -1 ) foundInFace = 0;
551  }
552 
553  if ( face == -1 ) {
554  face = foundInFace;
555  }
556  else if ( ! skipISOChecks && foundInFace != face ) {
557 #if 0
558  lwerror("SQL/MM Spatial exception - within face %d (not %d)",
559  foundInFace, face);
560 #else
561  lwerror("SQL/MM Spatial exception - not within face");
562 #endif
563  return -1;
564  }
565 
566  LWT_ISO_NODE node;
567  node.node_id = -1;
568  node.containing_face = face;
569  node.geom = pt;
570  if ( ! lwt_be_insertNodes(topo, &node, 1) )
571  {
572  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
573  return -1;
574  }
575 
576  return node.node_id;
577 }
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:395
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:119
LWT_ELEMID lwt_be_getFaceContainingPoint(LWT_TOPOLOGY *topo, LWPOINT *pt)
Definition: lwgeom_topo.c:323
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:382
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: