QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
16 #ifndef QGSPOINTLOCATOR_H
17 #define QGSPOINTLOCATOR_H
25 #include "qgis_core.h"
83 class IStorageManager;
160 MiddleOfSegment = 16,
161 All = Vertex | Edge | Area | Centroid | MiddleOfSegment
164 Q_DECLARE_FLAGS( Types, Type )
179 bool init(
int maxFeaturesToIndex = -1,
bool relaxed =
false );
182 bool hasIndex()
const;
195 , mVertexIndex( vertexIndex )
199 mEdgePoints[0] = edgePoints[0];
200 mEdgePoints[1] = edgePoints[1];
206 bool isValid()
const {
return mType != Invalid; }
210 bool hasEdge()
const {
return mType == Edge; }
214 bool hasArea()
const {
return mType == Area; }
247 pt1 = mEdgePoints[0];
248 pt2 = mEdgePoints[1];
259 const QgsGeometry geom = mLayer->getGeometry( mFid );
271 return mType == other.
mType &&
272 mDist == other.
mDist &&
275 mFid == other.
mFid &&
288 int mVertexIndex = 0;
297 typedef QList<QgsPointLocator::Match>
MatchList;
410 void waitForIndexingFinished();
419 void initFinished(
bool ok );
422 bool rebuildIndex(
int maxFeaturesToIndex = -1 );
427 void onInitTaskFinished();
431 void onAttributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
439 bool prepare(
bool relaxed );
442 std::unique_ptr< SpatialIndex::IStorageManager > mStorage;
444 QHash<QgsFeatureId, QgsGeometry *> mGeoms;
445 std::unique_ptr< SpatialIndex::ISpatialIndex > mRTree;
448 bool mIsEmptyLayer =
false;
454 std::unique_ptr< QgsRectangle > mExtent;
456 std::unique_ptr<QgsRenderContext> mContext;
457 std::unique_ptr<QgsFeatureRenderer> mRenderer;
458 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
459 int mMaxFeaturesToIndex = -1;
460 bool mIsIndexing =
false;
461 bool mIsDestroying =
false;
464 QPointer<QgsPointLocatorInitTask> mInitTask;
473 friend class QgsPointLocatorInitTask;
474 friend class TestQgsPointLocator;
480 #endif // QGSPOINTLOCATOR_H
bool operator==(const QgsPointLocator::Match &other) const
bool hasMiddleSegment() const
Returns true if the Match is the middle of a segment.
Point geometry type, with support for z-dimension and m-values.
bool isIndexing() const
Returns true if the point locator is currently indexing the data.
Match(QgsPointLocator::Type t, QgsVectorLayer *vl, QgsFeatureId fid, double dist, const QgsPointXY &pt, int vertexIndex=0, QgsPointXY *edgePoints=nullptr)
void edgePoints(QgsPointXY &pt1, QgsPointXY &pt2) const
Only for a valid edge match - obtain endpoints of the edge.
int cachedGeometryCount() const
Returns how many geometries are cached in the index.
static QgsPoint closestPoint(const QgsAbstractGeometry &geometry, const QgsPoint &point)
Returns the nearest point on a segment of a geometry for the specified point.
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords,...
Line string geometry type, with support for z-dimension and m-values.
bool hasVertex() const
Returns true if the Match is a vertex.
QgsPointXY mEdgePoints[2]
bool hasCentroid() const
Returns true if the Match is a centroid.
int vertexIndex() const
for vertex / edge match (first vertex of the edge)
QgsPointXY mMiddleOfSegment
bool hasEdge() const
Returns true if the Match is an edge.
class QList< QgsPointLocator::Match > MatchList
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsVectorLayer * layer() const
The vector layer where the snap occurred.
const QgsRectangle * extent() const
Gets extent of the area point locator covers - if nullptr then it caches the whole layer.
QSet< QgsFeatureId > QgsFeatureIds
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QgsFeatureId featureId() const
The id of the feature to which the snapped geometry belongs.
QgsPointLocator::Type type() const
QgsPoint interpolatedPoint() const
Convenient method to return a point on an edge with linear interpolation of the Z value.
The class defines interface for querying point location:
QgsVectorLayer * layer() const
Gets associated layer.
Interface that allows rejection of some matches in intersection queries (e.g.
Type
The type of a snap result or the filter type for a snap request.
bool hasArea() const
Returns true if the Match is an area.
double distance() const
for vertex / edge match units depending on what class returns it (geom.cache: layer units,...