QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsGeometrySnapper Class Reference

QgsGeometrySnapper allows a geometry to be snapped to the geometries within a different reference layer. More...

#include <qgsgeometrysnapper.h>

Inheritance diagram for QgsGeometrySnapper:
Inheritance graph
[legend]

Public Types

enum  SnapMode {
  PreferNodes = 0 , PreferClosest , PreferNodesNoExtraVertices , PreferClosestNoExtraVertices ,
  EndPointPreferNodes , EndPointPreferClosest , EndPointToEndPoint
}
 Snapping modes. More...
 

Signals

void featureSnapped ()
 Emitted each time a feature has been processed when calling snapFeatures()
 

Public Member Functions

 QgsGeometrySnapper (QgsFeatureSource *referenceSource)
 Constructor for QgsGeometrySnapper.
 
QgsFeatureList snapFeatures (const QgsFeatureList &features, double snapTolerance, SnapMode mode=PreferNodes)
 Snaps a set of features to the reference layer and returns the result.
 
QgsGeometry snapGeometry (const QgsGeometry &geometry, double snapTolerance, SnapMode mode=PreferNodes) const
 Snaps a geometry to the reference layer and returns the result.
 

Static Public Member Functions

static QgsGeometry snapGeometry (const QgsGeometry &geometry, double snapTolerance, const QList< QgsGeometry > &referenceGeometries, SnapMode mode=PreferNodes)
 Snaps a single geometry against a list of reference geometries.
 

Detailed Description

QgsGeometrySnapper allows a geometry to be snapped to the geometries within a different reference layer.

Vertices in the geometries will be modified to match the reference layer features within a specified snap tolerance.

Definition at line 41 of file qgsgeometrysnapper.h.

Member Enumeration Documentation

◆ SnapMode

Snapping modes.

Enumerator
PreferNodes 

Prefer to snap to nodes, even when a segment may be closer than a node. New nodes will be inserted to make geometries follow each other exactly when inside allowable tolerance.

PreferClosest 

Snap to closest point, regardless of it is a node or a segment. New nodes will be inserted to make geometries follow each other exactly when inside allowable tolerance.

PreferNodesNoExtraVertices 

Prefer to snap to nodes, even when a segment may be closer than a node. No new nodes will be inserted.

PreferClosestNoExtraVertices 

Snap to closest point, regardless of it is a node or a segment. No new nodes will be inserted.

EndPointPreferNodes 

Only snap start/end points of lines (point features will also be snapped, polygon features will not be modified), prefer to snap to nodes.

EndPointPreferClosest 

Only snap start/end points of lines (point features will also be snapped, polygon features will not be modified), snap to closest point.

EndPointToEndPoint 

Only snap the start/end points of lines to other start/end points of lines.

Definition at line 47 of file qgsgeometrysnapper.h.

Constructor & Destructor Documentation

◆ QgsGeometrySnapper()

QgsGeometrySnapper::QgsGeometrySnapper ( QgsFeatureSource referenceSource)

Constructor for QgsGeometrySnapper.

A reference feature source which contains geometries to snap to must be set. It is assumed that all geometries snapped using this object will have the same CRS as the reference source (ie, no reprojection is performed).

Definition at line 299 of file qgsgeometrysnapper.cpp.

Member Function Documentation

◆ featureSnapped

void QgsGeometrySnapper::featureSnapped ( )
signal

Emitted each time a feature has been processed when calling snapFeatures()

◆ snapFeatures()

QgsFeatureList QgsGeometrySnapper::snapFeatures ( const QgsFeatureList features,
double  snapTolerance,
SnapMode  mode = PreferNodes 
)

Snaps a set of features to the reference layer and returns the result.

This operation is multithreaded for performance. The featureSnapped() signal will be emitted each time a feature is processed. The snap tolerance is specified in the layer units for the reference layer.

Definition at line 306 of file qgsgeometrysnapper.cpp.

◆ snapGeometry() [1/2]

QgsGeometry QgsGeometrySnapper::snapGeometry ( const QgsGeometry geometry,
double  snapTolerance,
const QList< QgsGeometry > &  referenceGeometries,
QgsGeometrySnapper::SnapMode  mode = PreferNodes 
)
static

Snaps a single geometry against a list of reference geometries.

Definition at line 364 of file qgsgeometrysnapper.cpp.

◆ snapGeometry() [2/2]

QgsGeometry QgsGeometrySnapper::snapGeometry ( const QgsGeometry geometry,
double  snapTolerance,
SnapMode  mode = PreferNodes 
) const

Snaps a geometry to the reference layer and returns the result.

The geometry must be in the same CRS as the reference layer, and must have the same type as the reference layer geometry. The snap tolerance is specified in the layer units for the reference layer.

Definition at line 320 of file qgsgeometrysnapper.cpp.


The documentation for this class was generated from the following files: