16 #ifndef QGSPOINTLOCATOR_H 17 #define QGSPOINTLOCATOR_H 25 #include "qgis_core.h" 44 class IStorageManager;
119 All = Vertex | Edge | Area
122 Q_DECLARE_FLAGS( Types,
Type )
137 bool init(
int maxFeaturesToIndex = -1,
bool relaxed =
false );
140 bool hasIndex()
const;
153 , mVertexIndex( vertexIndex )
157 mEdgePoints[0] = edgePoints[0];
158 mEdgePoints[1] = edgePoints[1];
164 bool isValid()
const {
return mType != Invalid; }
166 bool hasEdge()
const {
return mType == Edge; }
167 bool hasArea()
const {
return mType == Area; }
198 pt1 = mEdgePoints[0];
199 pt2 = mEdgePoints[1];
210 const QgsGeometry geom = mLayer->getGeometry( mFid );
222 return mType == other.
mType &&
223 mDist == other.
mDist &&
226 mFid == other.
mFid &&
237 int mVertexIndex = 0;
244 typedef QList<QgsPointLocator::Match>
MatchList;
341 void waitForIndexingFinished();
350 void initFinished(
bool ok );
353 bool rebuildIndex(
int maxFeaturesToIndex = -1 );
358 void onInitTaskFinished();
362 void onAttributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
370 bool prepare(
bool relaxed );
373 std::unique_ptr< SpatialIndex::IStorageManager > mStorage;
375 QHash<QgsFeatureId, QgsGeometry *> mGeoms;
376 std::unique_ptr< SpatialIndex::ISpatialIndex > mRTree;
379 bool mIsEmptyLayer =
false;
385 std::unique_ptr< QgsRectangle > mExtent;
387 std::unique_ptr<QgsRenderContext> mContext;
388 std::unique_ptr<QgsFeatureRenderer> mRenderer;
389 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
390 int mMaxFeaturesToIndex = -1;
391 bool mIsIndexing =
false;
392 bool mIsDestroying =
false;
395 QPointer<QgsPointLocatorInitTask> mInitTask;
402 friend class QgsPointLocatorInitTask;
403 friend class TestQgsPointLocator;
407 #endif // QGSPOINTLOCATOR_H
The class defines interface for querying point location:
A rectangle specified with double values.
QSet< QgsFeatureId > QgsFeatureIds
QgsVectorLayer * layer() const
The vector layer where the snap occurred.
QgsPointLocator::Type type() const
A class to represent a 2D point.
class QList< QgsPointLocator::Match > MatchList
Helper class used when traversing the index looking for edges - builds a list of matches.
A geometry is the spatial representation of a feature.
Interface that allows rejection of some matches in intersection queries (e.g.
bool operator==(const QgsPointLocator::Match &other) const
QgsPoint interpolatedPoint() const
Convenient method to return a point on an edge with linear interpolation of the Z value...
QgsPointXY mEdgePoints[2]
void edgePoints(QgsPointXY &pt1, QgsPointXY &pt2) const
Only for a valid edge match - obtain endpoints of the edge.
Match(QgsPointLocator::Type t, QgsVectorLayer *vl, QgsFeatureId fid, double dist, const QgsPointXY &pt, int vertexIndex=0, QgsPointXY *edgePoints=nullptr)
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Helper class used when traversing the index with areas - builds a list of matches.
bool isIndexing() const
Returns true if the point locator is currently indexing the data.
Contains information about the context in which a coordinate transform is executed.
Helper class used when traversing the index looking for vertices - builds a list of matches...
Point geometry type, with support for z-dimension and m-values.
const QgsRectangle * extent() const
Gets extent of the area point locator covers - if nullptr then it caches the whole layer...
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
int cachedGeometryCount() const
Returns how many geometries are cached in the index.
QgsPointXY point() const
for vertex / edge match coords depending on what class returns it (geom.cache: layer coords...
Contains information about the context of a rendering operation.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
int vertexIndex() const
for vertex / edge match (first vertex of the edge)
Line string geometry type, with support for z-dimension and m-values.
This class represents a coordinate reference system (CRS).
Helper class used when traversing the index looking for vertices - builds a list of matches...
double distance() const
for vertex / edge match units depending on what class returns it (geom.cache: layer units...
Helper class used when traversing the index looking for edges - builds a list of matches.
static QgsPoint closestPoint(const QgsAbstractGeometry &geometry, const QgsPoint &point)
Returns the nearest point on a segment of a geometry for the specified point.
QgsFeatureId featureId() const
The id of the feature to which the snapped geometry belongs.
Represents a vector layer which manages a vector based data sets.
QgsVectorLayer * layer() const
Gets associated layer.
Type
The type of a snap result or the filter type for a snap request.