PostGIS  3.7.0dev-r@@SVN_REVISION@@

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

3723 {
3724  LWT_ISO_NODE *node;
3725  int ret;
3726  int newPointFace;
3727 
3728  node = _lwt_GetIsoNode( topo, nid );
3729  if ( ! node ) return -1;
3730 
3731  if ( lwt_be_ExistsCoincidentNode(topo, pt) )
3732  {
3733  lwfree(node);
3734  lwerror("SQL/MM Spatial exception - coincident node");
3735  return -1;
3736  }
3737 
3738  if ( lwt_be_ExistsEdgeIntersectingPoint(topo, pt) )
3739  {
3740  lwfree(node);
3741  lwerror("SQL/MM Spatial exception - edge crosses node.");
3742  return -1;
3743  }
3744 
3745  /* Check that the new point is in the same containing face !
3746  * See https://trac.osgeo.org/postgis/ticket/3232 */
3747  newPointFace = lwt_GetFaceContainingPoint(topo, pt);
3748  if ( newPointFace == -1 ) {
3749  PGTOPO_BE_ERROR();
3750  return -1;
3751  }
3752  if ( node->containing_face != newPointFace )
3753  {
3754  lwfree(node);
3755  lwerror("Cannot move isolated node across faces");
3756  return -1;
3757  }
3758 
3759  node->node_id = nid;
3760  node->geom = pt;
3761  ret = lwt_be_updateNodesById(topo, node, 1,
3763  if ( ret == -1 ) {
3764  lwfree(node);
3765  PGTOPO_BE_ERROR();
3766  return -1;
3767  }
3768 
3769  lwfree(node);
3770  return 0;
3771 }
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)
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
static LWT_ISO_NODE * _lwt_GetIsoNode(LWT_TOPOLOGY *topo, LWT_ELEMID nid)
Definition: lwgeom_topo.c:3696
static int lwt_be_updateNodesById(LWT_TOPOLOGY *topo, const LWT_ISO_NODE *nodes, int numnodes, int upd_fields)
Definition: lwgeom_topo.c:302
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: