Class: QgsGeometrySnapper¶
- class qgis.analysis.QgsGeometrySnapper¶
Bases:
PyQt5.QtCore.QObject
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.New in version 3.0.
QgsGeometrySnapper(referenceSource:
QgsFeatureSource
) Constructor forQgsGeometrySnapper
. 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).Methods
Snaps a set of features to the reference layer and returns the result.
Snaps a geometry to the reference layer and returns the result.
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
Attributes
- EndPointPreferClosest = 5¶
- EndPointPreferNodes = 4¶
- EndPointToEndPoint = 6¶
- PreferClosest = 1¶
- PreferClosestNoExtraVertices = 3¶
- PreferNodes = 0¶
- PreferNodesNoExtraVertices = 2¶
- class SnapMode¶
Bases:
int
- childEvent(self, QChildEvent)¶
- connectNotify(self, QMetaMethod)¶
- customEvent(self, QEvent)¶
- disconnectNotify(self, QMetaMethod)¶
- featureSnapped¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- isSignalConnected(self, QMetaMethod) bool ¶
- receivers(self, PYQT_SIGNAL) int ¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- snapFeatures(self, features: Iterable[QgsFeature], snapTolerance: float, mode: QgsGeometrySnapper.SnapMode = QgsGeometrySnapper.PreferNodes) List[QgsFeature] ¶
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.- Parameters:
features (Iterable[QgsFeature]) –
snapTolerance (float) –
mode (QgsGeometrySnapper.SnapMode = QgsGeometrySnapper.PreferNodes) –
- Return type:
List[QgsFeature]
- snapGeometry(self, geometry: QgsGeometry, snapTolerance: float, mode: QgsGeometrySnapper.SnapMode = QgsGeometrySnapper.PreferNodes) QgsGeometry ¶
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.
snapGeometry(geometry:
QgsGeometry
, snapTolerance: float, referenceGeometries: Iterable[QgsGeometry], mode: QgsGeometrySnapper.SnapMode = QgsGeometrySnapper.PreferNodes) -> QgsGeometry Snaps a single geometry against a list of reference geometries.- Parameters:
geometry (QgsGeometry) –
snapTolerance (float) –
mode (QgsGeometrySnapper.SnapMode = QgsGeometrySnapper.PreferNodes) –
- Return type:
- timerEvent(self, QTimerEvent)¶