PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _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 586 of file lwgeom_topo.c.

588{
589 LWT_ELEMID foundInFace = -1;
590 char locinfo[128] = "";
591 const char *locsuffix = _lwt_describe_point(pt, locinfo, sizeof(locinfo)) ? locinfo : "";
592
593 if ( lwpoint_is_empty(pt) )
594 {
595 lwerror("Cannot add empty point as isolated node");
596 return -1;
597 }
598
599
600 if ( ! skipISOChecks )
601 {
602 if ( lwt_be_ExistsCoincidentNode(topo, pt) ) /*x*/
603 {
604 lwerror("SQL/MM Spatial exception - coincident node%s", locsuffix);
605 return -1;
606 }
607 if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) ) /*x*/
608 {
609 lwerror("SQL/MM Spatial exception - edge crosses node.%s", locsuffix);
610 return -1;
611 }
612 }
613
614 if ( checkFace && ( face == -1 || ! skipISOChecks ) )
615 {
616 foundInFace = lwt_GetFaceContainingPoint(topo, pt); /*x*/
617 if ( foundInFace == -1 ) {
619 return -1;
620 }
621 if ( foundInFace == -1 ) foundInFace = 0;
622 }
623
624 if ( face == -1 ) {
625 face = foundInFace;
626 }
627 else if ( ! skipISOChecks && foundInFace != face ) {
628#if 0
629 lwerror("SQL/MM Spatial exception - within face %d (not %d)",
630 foundInFace, face);
631#else
632 lwerror("SQL/MM Spatial exception - not within face");
633#endif
634 return -1;
635 }
636
637 LWT_ISO_NODE node;
638 node.node_id = -1;
639 node.containing_face = face;
640 node.geom = pt;
641 if ( ! lwt_be_insertNodes(topo, &node, 1) )
642 {
644 return -1;
645 }
646
647 return node.node_id;
648}
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)
LWT_ELEMID lwt_be_ExistsEdgeIntersectingPoint(LWT_TOPOLOGY *topo, const LWPOINT *pt)
LWT_ELEMID lwt_GetFaceContainingPoint(LWT_TOPOLOGY *topo, const LWPOINT *pt)
Find the face-id of the face properly containing a given point.
int lwt_be_insertNodes(LWT_TOPOLOGY *topo, LWT_ISO_NODE *node, uint64_t numelems)
static bool _lwt_describe_point(const LWPOINT *pt, char *buf, size_t bufsize)
Definition lwgeom_topo.c:89
LWT_ELEMID node_id
LWT_ELEMID containing_face
LWPOINT * geom

References _lwt_describe_point(), 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: