QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsGeometrySnapper Class Reference

#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() More...
 

Public Member Functions

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

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. More...
 

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.

Since
QGIS 3.0

Definition at line 39 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 46 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 460 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 467 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 505 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 481 of file qgsgeometrysnapper.cpp.


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