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

◆ lwt_MoveIsoNode()

int lwt_MoveIsoNode ( LWT_TOPOLOGY topo,
LWT_ELEMID  node,
LWPOINT pt 
)

Move an isolated node.

For ST_MoveIsoNode

Parameters
topothe topology to operate on
nodethe identifier of the nod to be moved
ptthe new node position
Returns
0 on success, -1 on error (liblwgeom error handler will be invoked with error message)

Definition at line 3839 of file lwgeom_topo.c.

3840{
3841 LWT_ISO_NODE *node;
3842 int ret;
3843 int newPointFace;
3844
3845 node = _lwt_GetIsoNode( topo, nid );
3846 if ( ! node ) return -1;
3847
3848 if ( lwt_be_ExistsCoincidentNode(topo, pt) )
3849 {
3850 lwfree(node);
3851 lwerror("SQL/MM Spatial exception - coincident node");
3852 return -1;
3853 }
3854
3855 if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) )
3856 {
3857 lwfree(node);
3858 lwerror("SQL/MM Spatial exception - edge crosses node.");
3859 return -1;
3860 }
3861
3862 /* Check that the new point is in the same containing face !
3863 * See https://trac.osgeo.org/postgis/ticket/3232 */
3864 newPointFace = lwt_GetFaceContainingPoint(topo, pt);
3865 if ( newPointFace == -1 ) {
3867 return -1;
3868 }
3869 if ( node->containing_face != newPointFace )
3870 {
3871 lwfree(node);
3872 lwerror("Cannot move isolated node across faces");
3873 return -1;
3874 }
3875
3876 node->node_id = nid;
3877 node->geom = pt;
3878 ret = lwt_be_updateNodesById(topo, node, 1,
3880 if ( ret == -1 ) {
3881 lwfree(node);
3883 return -1;
3884 }
3885
3886 lwfree(node);
3887 return 0;
3888}
void lwfree(void *mem)
Definition lwutil.c:248
#define LWT_COL_NODE_GEOM
#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.
static LWT_ISO_NODE * _lwt_GetIsoNode(LWT_TOPOLOGY *topo, LWT_ELEMID nid)
static int lwt_be_updateNodesById(LWT_TOPOLOGY *topo, const LWT_ISO_NODE *nodes, int numnodes, int upd_fields)
LWT_ELEMID node_id
LWT_ELEMID containing_face
LWPOINT * geom

References _lwt_GetIsoNode(), LWT_ISO_NODE::containing_face, LWT_ISO_NODE::geom, lwerror(), lwfree(), lwt_be_ExistsCoincidentNode(), lwt_be_ExistsEdgeIntersectingPoint(), lwt_be_updateNodesById(), LWT_COL_NODE_GEOM, lwt_GetFaceContainingPoint(), LWT_ISO_NODE::node_id, and PGTOPO_BE_ERROR.

Here is the call graph for this function: