QGIS API Documentation
3.0.2-Girona (307d082)
|
The class defines interface for querying point location: More...
#include <qgspointlocator.h>
Classes | |
struct | Match |
struct | MatchFilter |
Interface that allows rejection of some matches in intersection queries (e.g. More... | |
Public Types | |
typedef class QList< QgsPointLocator::Match > | MatchList |
enum | Type { Invalid = 0, Vertex = 1, Edge = 2, Area = 4, All = Vertex | Edge | Area } |
The type of a snap result or the filter type for a snap request. More... | |
Public Member Functions | |
QgsPointLocator (QgsVectorLayer *layer, const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem(), const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext(), const QgsRectangle *extent=nullptr) | |
Construct point locator for a layer. More... | |
~QgsPointLocator () override | |
int | cachedGeometryCount () const |
Return how many geometries are cached in the index. More... | |
QgsCoordinateReferenceSystem | destinationCrs () const |
Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection. More... | |
MatchList | edgesInRect (const QgsRectangle &rect, QgsPointLocator::MatchFilter *filter=nullptr) |
Find edges within a specified recangle Optional filter may discard unwanted matches. More... | |
MatchList | edgesInRect (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr) |
Override of edgesInRect that construct rectangle from a center point and tolerance. More... | |
const QgsRectangle * | extent () const |
Get extent of the area point locator covers - if null then it caches the whole layer. More... | |
bool | hasIndex () const |
Indicate whether the data have been already indexed. More... | |
bool | init (int maxFeaturesToIndex=-1) |
Prepare the index for queries. More... | |
QgsVectorLayer * | layer () const |
Get associated layer. More... | |
Match | nearestArea (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr) |
Find nearest area to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. More... | |
Match | nearestEdge (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr) |
Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. More... | |
Match | nearestVertex (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr) |
Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. More... | |
MatchList | pointInPolygon (const QgsPointXY &point) |
find out if the point is in any polygons More... | |
void | setExtent (const QgsRectangle *extent) |
Configure extent - if not null, it will index only that area. More... | |
Protected Slots | |
void | destroyIndex () |
Protected Member Functions | |
bool | rebuildIndex (int maxFeaturesToIndex=-1) |
Friends | |
class | QgsPointLocator_VisitorArea |
class | QgsPointLocator_VisitorEdgesInRect |
class | QgsPointLocator_VisitorNearestEdge |
class | QgsPointLocator_VisitorNearestVertex |
The class defines interface for querying point location:
Works with one layer.
Definition at line 50 of file qgspointlocator.h.
typedef class QList< QgsPointLocator::Match > QgsPointLocator::MatchList |
Definition at line 201 of file qgspointlocator.h.
The type of a snap result or the filter type for a snap request.
Enumerator | |
---|---|
Invalid | Invalid. |
Vertex | Snapped to a vertex. Can be a vertex of the geometry or an intersection. |
Edge | Snapped to an edge. |
Area | Snapped to an area. |
All | Combination of vertex, edge and area. |
Definition at line 98 of file qgspointlocator.h.
|
explicit |
Construct point locator for a layer.
If a valid QgsCoordinateReferenceSystem is passed for destinationCrs then the locator will do the searches on data reprojected to the given CRS. For accurate reprojection it is important to set the correct transformContext if a destinationCrs is specified. This is usually taken from the current QgsProject::transformContext().
If extent is not null, the locator will index only a subset of the layer which falls within that extent.
Definition at line 622 of file qgspointlocator.cpp.
|
override |
Definition at line 642 of file qgspointlocator.cpp.
|
inline |
Return how many geometries are cached in the index.
Definition at line 260 of file qgspointlocator.h.
QgsCoordinateReferenceSystem QgsPointLocator::destinationCrs | ( | ) | const |
Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection.
Definition at line 649 of file qgspointlocator.cpp.
|
protectedslot |
Definition at line 768 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::edgesInRect | ( | const QgsRectangle & | rect, |
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Find edges within a specified recangle Optional filter may discard unwanted matches.
Definition at line 919 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::edgesInRect | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Override of edgesInRect that construct rectangle from a center point and tolerance.
Definition at line 939 of file qgspointlocator.cpp.
|
inline |
Get extent of the area point locator covers - if null then it caches the whole layer.
Definition at line 87 of file qgspointlocator.h.
bool QgsPointLocator::hasIndex | ( | ) | const |
Indicate whether the data have been already indexed.
Definition at line 671 of file qgspointlocator.cpp.
bool QgsPointLocator::init | ( | int | maxFeaturesToIndex = -1 | ) |
Prepare the index for queries.
Does nothing if the index already exists. If the number of features is greater than the value of maxFeaturesToIndex, creation of index is stopped to make sure we do not run out of memory. If maxFeaturesToIndex is -1, no limits are used. Returns false if the creation of index has been prematurely stopped due to the limit of features, otherwise true
Definition at line 665 of file qgspointlocator.cpp.
|
inline |
QgsPointLocator::Match QgsPointLocator::nearestArea | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Find nearest area to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This will first perform a pointInPolygon and return first result. If no match is found and tolerance is not 0, it will return nearestEdge.
Definition at line 885 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestEdge | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
Definition at line 863 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestVertex | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
Definition at line 845 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::pointInPolygon | ( | const QgsPointXY & | point | ) |
find out if the point is in any polygons
Definition at line 946 of file qgspointlocator.cpp.
|
protected |
Definition at line 677 of file qgspointlocator.cpp.
void QgsPointLocator::setExtent | ( | const QgsRectangle * | extent | ) |
Configure extent - if not null, it will index only that area.
Definition at line 654 of file qgspointlocator.cpp.
|
friend |
Definition at line 288 of file qgspointlocator.h.
|
friend |
Definition at line 289 of file qgspointlocator.h.
|
friend |
Definition at line 287 of file qgspointlocator.h.
|
friend |
Definition at line 286 of file qgspointlocator.h.