| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   17 #ifndef QGS_GEOMETRY_SNAPPER_H 
   18 #define QGS_GEOMETRY_SNAPPER_H 
   25 #include "qgis_analysis.h" 
   29 #include <QStringList> 
   72     QgsGeometry snapGeometry( 
const QgsGeometry &geometry, 
double snapTolerance, SnapMode mode = PreferNodes ) 
const;
 
   84     static QgsGeometry snapGeometry( 
const QgsGeometry &geometry, 
double snapTolerance, 
const QList<QgsGeometry> &referenceGeometries, SnapMode mode = PreferNodes );
 
   89     void featureSnapped();
 
   92     struct ProcessFeatureWrapper
 
   97       explicit ProcessFeatureWrapper( 
QgsGeometrySnapper *_instance, 
double snapTolerance, SnapMode mode )
 
   98         : instance( _instance )
 
   99         , snapTolerance( snapTolerance )
 
  102       void operator()( 
QgsFeature &feature ) { instance->processFeature( feature, snapTolerance, mode ); }
 
  105     enum PointFlag { SnappedToRefNode, SnappedToRefSegment, Unsnapped };
 
  108     QHash<QgsFeatureId, QgsGeometry> mCachedReferenceGeometries;
 
  111     mutable QMutex mIndexMutex;
 
  112     mutable QMutex mReferenceLayerMutex;
 
  114     void processFeature( 
QgsFeature &feature, 
double snapTolerance, SnapMode mode );
 
  160     bool mFirstFeature = 
true;
 
  161     double mSnapTolerance = 0;
 
  186     enum SnapType { SnapPoint, SnapEndPoint, SnapSegment };
 
  191         virtual ~SnapItem() = 
default;
 
  196         explicit SnapItem( SnapType _type ) : type( _type ) {}
 
  199     class PointSnapItem : 
public QgsSnapIndex::SnapItem
 
  202         explicit PointSnapItem( 
const CoordIdx *_idx, 
bool isEndPoint );
 
  204         const CoordIdx *idx = 
nullptr;
 
  207     class SegmentSnapItem : 
public QgsSnapIndex::SnapItem
 
  210         SegmentSnapItem( 
const CoordIdx *_idxFrom, 
const CoordIdx *_idxTo );
 
  214         bool withinDistance( 
const QgsPoint &p, 
const double distance );
 
  215         const CoordIdx *idxFrom = 
nullptr;
 
  216         const CoordIdx *idxTo = 
nullptr;
 
  222     QgsSnapIndex( 
const QgsSnapIndex &rh ) = 
delete;
 
  223     QgsSnapIndex &operator=( 
const QgsSnapIndex &rh ) = 
delete;
 
  227     SnapItem *getSnapItem( 
const QgsPoint &pos, 
const double tolerance, PointSnapItem **pSnapPoint = 
nullptr, SegmentSnapItem **pSnapSegment = 
nullptr, 
bool endPointOnly = 
false ) 
const;
 
  230     QList<CoordIdx *> mCoordIdxs;
 
  231     QList<SnapItem *> mSnapItems;
 
  233     void addPoint( 
const CoordIdx *idx, 
bool isEndPoint );
 
  234     void addSegment( 
const CoordIdx *idxFrom, 
const CoordIdx *idxTo );
 
  236     GEOSSTRtree *mSTRTree = 
nullptr;
 
  237     std::vector< geos::unique_ptr > mSTRTreeItems;
 
  244 #endif // QGS_GEOMETRY_SNAPPER_H 
  
@ PreferNodes
Prefer to snap to nodes, even when a segment may be closer than a node. New nodes will be inserted to...
 
@ PreferClosestNoExtraVertices
Snap to closest point, regardless of it is a node or a segment. No new nodes will be inserted.
 
QgsPoint vertexAt(QgsVertexId) const override
Returns the point corresponding to a specified vertex id.
 
Point geometry type, with support for z-dimension and m-values.
 
An interface for objects which provide features via a getFeatures method.
 
@ PreferClosest
Snap to closest point, regardless of it is a node or a segment. New nodes will be inserted to make ge...
 
QgsGeometryMap snappedGeometries() const
Returns a QgsGeometryMap of all feature geometries snapped by this object.
 
@ EndPointToEndPoint
Only snap the start/end points of lines to other start/end points of lines.
 
QList< QgsFeature > QgsFeatureList
 
@ EndPointPreferNodes
Only snap start/end points of lines (point features will also be snapped, polygon features will not b...
 
A spatial index for QgsFeature objects.
 
Abstract base class for all geometries.
 
A geometry is the spatial representation of a feature.
 
Represents a vector layer which manages a vector based data sets.
 
QgsInternalGeometrySnapper allows a set of geometries to be snapped to each other....
 
Utility class for identifying a unique vertex within a geometry.
 
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
QgsGeometrySnapper allows a geometry to be snapped to the geometries within a different reference lay...
 
@ PreferNodesNoExtraVertices
Prefer to snap to nodes, even when a segment may be closer than a node. No new nodes will be inserted...
 
@ EndPointPreferClosest
Only snap start/end points of lines (point features will also be snapped, polygon features will not b...