QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
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 << 0 , Edge = 1 << 1 , Area = 1 << 2 , Centroid = 1 << 3 , MiddleOfSegment = 1 << 4 , LineEndpoint = 1 << 5 , All = Vertex | Edge | Area | Centroid | MiddleOfSegment } |
The type of a snap result or the filter type for a snap request. More... | |
typedef QFlags< Type > | Types |
Signals | |
void | initFinished (bool ok) |
Emitted whenever index has been built and initialization is finished. | |
Public Member Functions | |
QgsPointLocator (QgsVectorLayer *layer, const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem(), const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext(), const QgsRectangle *extent=nullptr) | |
Construct point locator for a layer. | |
~QgsPointLocator () override | |
int | cachedGeometryCount () const |
Returns how many geometries are cached in the index. | |
QgsCoordinateReferenceSystem | destinationCrs () const |
Gets destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection. | |
MatchList | edgesInRect (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Override of edgesInRect that construct rectangle from a center point and tolerance This method is either blocking or non blocking according to relaxed parameter passed. | |
MatchList | edgesInRect (const QgsRectangle &rect, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find edges within a specified rectangle Optional filter may discard unwanted matches. | |
const QgsRectangle * | extent () const |
Gets extent of the area point locator covers - if nullptr then it caches the whole layer. | |
bool | hasIndex () const |
Indicate whether the data have been already indexed. | |
bool | init (int maxFeaturesToIndex=-1, bool relaxed=false) |
Prepare the index for queries. | |
bool | isIndexing () const |
Returns true if the point locator is currently indexing the data. | |
QgsVectorLayer * | layer () const |
Gets associated layer. | |
Match | nearestArea (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest area to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
Match | nearestCentroid (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest centroid to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
Match | nearestEdge (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
Match | nearestLineEndpoints (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest line endpoint (start or end vertex) to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
Match | nearestMiddleOfSegment (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest middle of segment to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
Match | nearestVertex (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches. | |
MatchList | pointInPolygon (const QgsPointXY &point, bool relaxed=false, QgsPointLocator::MatchFilter *filter=nullptr) |
Find out if the point is in any polygons. | |
void | setExtent (const QgsRectangle *extent) |
Configure extent - if not nullptr , it will index only that area. | |
void | setRenderContext (const QgsRenderContext *context) |
Configure render context - if not nullptr , it will use to index only visible feature. | |
MatchList | verticesInRect (const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Override of verticesInRect that construct rectangle from a center point and tolerance This method is either blocking or non blocking according to relaxed parameter passed. | |
MatchList | verticesInRect (const QgsRectangle &rect, QgsPointLocator::MatchFilter *filter=nullptr, bool relaxed=false) |
Find vertices within a specified rectangle This method is either blocking or non blocking according to relaxed parameter passed Optional filter may discard unwanted matches. | |
void | waitForIndexingFinished () |
If the point locator has been initialized relaxedly and is currently indexing, this methods waits for the indexing to be finished. | |
Protected Slots | |
void | destroyIndex () |
Protected Member Functions | |
bool | rebuildIndex (int maxFeaturesToIndex=-1) |
The class defines interface for querying point location:
Works with one layer.
Definition at line 100 of file qgspointlocator.h.
typedef class QList< QgsPointLocator::Match > QgsPointLocator::MatchList |
Definition at line 343 of file qgspointlocator.h.
typedef QFlags< Type > QgsPointLocator::Types |
Definition at line 162 of file qgspointlocator.h.
The type of a snap result or the filter type for a snap request.
Definition at line 150 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 nullptr
, the locator will index only a subset of the layer which falls within that extent.
Definition at line 875 of file qgspointlocator.cpp.
|
override |
Definition at line 895 of file qgspointlocator.cpp.
|
inline |
Returns how many geometries are cached in the index.
Definition at line 452 of file qgspointlocator.h.
QgsCoordinateReferenceSystem QgsPointLocator::destinationCrs | ( | ) | const |
Gets destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection.
Definition at line 905 of file qgspointlocator.cpp.
|
protectedslot |
Definition at line 1183 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::edgesInRect | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Override of edgesInRect that construct rectangle from a center point and tolerance This method is either blocking or non blocking according to relaxed parameter passed.
Definition at line 1452 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::edgesInRect | ( | const QgsRectangle & | rect, |
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find edges within a specified rectangle Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1436 of file qgspointlocator.cpp.
|
inline |
Gets extent of the area point locator covers - if nullptr
then it caches the whole layer.
Definition at line 134 of file qgspointlocator.h.
bool QgsPointLocator::hasIndex | ( | ) | const |
Indicate whether the data have been already indexed.
Definition at line 1018 of file qgspointlocator.cpp.
bool QgsPointLocator::init | ( | int | maxFeaturesToIndex = -1 , |
bool | relaxed = false |
||
) |
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.
This method is either blocking or non blocking according to relaxed parameter passed in the constructor. if true
, index building will be done in another thread and init() method returns immediately. initFinished() signal will be emitted once the initialization is over.
Returns false
if the creation of index is blocking and has been prematurely stopped due to the limit of features, otherwise true
Definition at line 968 of file qgspointlocator.cpp.
|
signal |
Emitted whenever index has been built and initialization is finished.
ok | false if the creation of index has been prematurely stopped due to the limit of features, otherwise true |
|
inline |
Returns true
if the point locator is currently indexing the data.
This method is useful if constructor parameter relaxed is true
Definition at line 460 of file qgspointlocator.h.
|
inline |
Gets associated layer.
Definition at line 124 of file qgspointlocator.h.
QgsPointLocator::Match QgsPointLocator::nearestArea | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
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. This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1406 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestCentroid | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find nearest centroid to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1343 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestEdge | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1388 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestLineEndpoints | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find nearest line endpoint (start or end vertex) to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1373 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestMiddleOfSegment | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find nearest middle of segment to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1358 of file qgspointlocator.cpp.
QgsPointLocator::Match QgsPointLocator::nearestVertex | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to relaxed parameter passed
Definition at line 1329 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::pointInPolygon | ( | const QgsPointXY & | point, |
bool | relaxed = false , |
||
QgsPointLocator::MatchFilter * | filter = nullptr |
||
) |
Find out if the point is in any polygons.
point | The point to check polygons against, in map coordinates |
relaxed | true if index build has to be non blocking |
filter | since QGIS 3.36, Optional filter may discard unwanted matches. |
Definition at line 1476 of file qgspointlocator.cpp.
|
protected |
Definition at line 1043 of file qgspointlocator.cpp.
void QgsPointLocator::setExtent | ( | const QgsRectangle * | extent | ) |
Configure extent - if not nullptr
, it will index only that area.
Definition at line 910 of file qgspointlocator.cpp.
void QgsPointLocator::setRenderContext | ( | const QgsRenderContext * | context | ) |
Configure render context - if not nullptr
, it will use to index only visible feature.
Definition at line 921 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::verticesInRect | ( | const QgsPointXY & | point, |
double | tolerance, | ||
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Override of verticesInRect that construct rectangle from a center point and tolerance This method is either blocking or non blocking according to relaxed parameter passed.
Definition at line 1470 of file qgspointlocator.cpp.
QgsPointLocator::MatchList QgsPointLocator::verticesInRect | ( | const QgsRectangle & | rect, |
QgsPointLocator::MatchFilter * | filter = nullptr , |
||
bool | relaxed = false |
||
) |
Find vertices within a specified rectangle This method is either blocking or non blocking according to relaxed parameter passed Optional filter may discard unwanted matches.
Definition at line 1458 of file qgspointlocator.cpp.
void QgsPointLocator::waitForIndexingFinished | ( | ) |
If the point locator has been initialized relaxedly and is currently indexing, this methods waits for the indexing to be finished.
Definition at line 1007 of file qgspointlocator.cpp.
|
friend |
Definition at line 526 of file qgspointlocator.h.
|
friend |
Definition at line 531 of file qgspointlocator.h.
|
friend |
Definition at line 527 of file qgspointlocator.h.
|
friend |
Definition at line 532 of file qgspointlocator.h.
|
friend |
Definition at line 523 of file qgspointlocator.h.
|
friend |
Definition at line 525 of file qgspointlocator.h.
|
friend |
Definition at line 533 of file qgspointlocator.h.
|
friend |
Definition at line 524 of file qgspointlocator.h.
|
friend |
Definition at line 522 of file qgspointlocator.h.
|
friend |
Definition at line 528 of file qgspointlocator.h.
|
friend |
Definition at line 529 of file qgspointlocator.h.
|
friend |
Definition at line 530 of file qgspointlocator.h.