QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
16 #ifndef QGSPOINTLOCATOR_H
17 #define QGSPOINTLOCATOR_H
25 #include "qgis_core.h"
85 class IStorageManager;
162 MiddleOfSegment = 1 << 4,
163 LineEndpoint = 1 << 5,
164 All = Vertex | Edge | Area | Centroid | MiddleOfSegment
167 Q_DECLARE_FLAGS( Types, Type )
182 bool init(
int maxFeaturesToIndex = -1,
bool relaxed =
false );
185 bool hasIndex()
const;
198 , mVertexIndex( vertexIndex )
202 mEdgePoints[0] = edgePoints[0];
203 mEdgePoints[1] = edgePoints[1];
209 bool isValid()
const {
return mType != Invalid; }
213 bool hasEdge()
const {
return mType == Edge; }
217 bool hasArea()
const {
return mType == Area; }
257 pt1 = mEdgePoints[0];
258 pt2 = mEdgePoints[1];
274 const QgsGeometry geom = mLayer->getGeometry( mFid );
280 snappedPoint = transform.
transform( snappedPoint );
284 QgsDebugMsg( QStringLiteral(
"transformation to layer coordinate failed" ) );
299 point.
transform( transform, Qgis::TransformDirection::Reverse );
303 QgsDebugMsg( QStringLiteral(
"transformation to destination coordinate failed" ) );
314 return mType == other.
mType &&
315 mDist == other.
mDist &&
318 mFid == other.
mFid &&
332 int mVertexIndex = 0;
341 typedef QList<QgsPointLocator::Match>
MatchList;
462 void waitForIndexingFinished();
471 void initFinished(
bool ok );
474 bool rebuildIndex(
int maxFeaturesToIndex = -1 );
479 void onInitTaskFinished();
483 void onAttributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
491 bool prepare(
bool relaxed );
494 std::unique_ptr< SpatialIndex::IStorageManager > mStorage;
496 QHash<QgsFeatureId, QgsGeometry *> mGeoms;
497 std::unique_ptr< SpatialIndex::ISpatialIndex > mRTree;
500 bool mIsEmptyLayer =
false;
506 std::unique_ptr< QgsRectangle > mExtent;
508 std::unique_ptr<QgsRenderContext> mContext;
509 std::unique_ptr<QgsFeatureRenderer> mRenderer;
510 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
511 int mMaxFeaturesToIndex = -1;
512 bool mIsIndexing =
false;
513 bool mIsDestroying =
false;
516 QPointer<QgsPointLocatorInitTask> mInitTask;
525 friend class QgsPointLocatorInitTask;
526 friend class TestQgsPointLocator;
533 #endif // QGSPOINTLOCATOR_H
bool operator==(const QgsPointLocator::Match &other) const
Helper class used when traversing the index with areas - builds a list of matches.
Contains information about the context in which a coordinate transform is executed.
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.
Contains information about the context of a rendering operation.
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,...
Helper class used when traversing the index looking for vertices - builds a list of matches.
Line string geometry type, with support for z-dimension and m-values.
Helper class used when traversing the index looking for centroid - builds a list of matches.
A rectangle specified with double values.
bool hasVertex() const
Returns true if the Match is a vertex.
QgsPoint interpolatedPoint(const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem()) const
Convenient method to return a point on an edge with linear interpolation of the Z value.
Helper class used when traversing the index looking for middle segment - builds a list of matches.
Helper class used when traversing the index looking for centroid - builds a list of matches.
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.
Custom exception class for Coordinate Reference System related exceptions.
Helper class used when traversing the index looking for line endpoints (start or end vertex) - builds...
void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false) override SIP_THROW(QgsCsException)
Transforms the geometry using a coordinate transform.
class QList< QgsPointLocator::Match > MatchList
bool hasLineEndpoint() const
Returns true if the Match is a line endpoint (start or end vertex).
Helper class used when traversing the index looking for edges - builds a list of matches.
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 looking for vertices - builds a list of matches.
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.
Helper class used when traversing the index looking for middle segment - builds a list of matches.
QSet< QgsFeatureId > QgsFeatureIds
This class represents a coordinate reference system (CRS).
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
A class to represent a 2D point.
Helper class used when traversing the index looking for edges - builds a list of matches.
QgsFeatureId featureId() const
The id of the feature to which the snapped geometry belongs.
A geometry is the spatial representation of a feature.
Represents a vector layer which manages a vector based data sets.
QgsPointLocator::Type type() const
Partial snapshot of vector layer's state (only the members necessary for access to features)
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.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
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,...