PostGIS  3.3.9dev-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 3725 of file lwgeom_topo.c.

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

Here is the call graph for this function: