Subgroup: Point

Class: QgsPointLocator

class qgis.core.QgsPointLocator

Bases: PyQt5.QtCore.QObject

The class defines interface for querying point location: - query nearest vertices / edges to a point - query vertices / edges in rectangle - query areas covering a point

Works with one layer.

New in version 2.8: Methods

blockSignals
cachedGeometryCount Return how many geometries are cached in the index
childEvent
children
connectNotify
customEvent
deleteLater
destinationCrs Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection
destroyIndex
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
edgesInRect Find edges within a specified recangle Optional filter may discard unwanted matches.
event
eventFilter
extent Get extent of the area point locator covers - if null then it caches the whole layer
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
hasIndex Indicate whether the data have been already indexed
inherits
init Prepare the index for queries.
installEventFilter
isSignalConnected
isWidgetType
isWindowType
killTimer
layer Get associated layer
metaObject
moveToThread
nearestEdge Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
nearestVertex Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.
objectName
parent
pointInPolygon find out if the point is in any polygons
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
rebuildIndex
receivers
removeEventFilter
sender
senderSignalIndex
setExtent Configure extent - if not null, it will index only that area
setObjectName
setParent
setProperty
signalsBlocked
startTimer
thread
timerEvent
tr

Attributes

All
Area
Edge
Invalid
Vertex
destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
staticMetaObject
All = 7
Area = 4
Edge = 2
Invalid = 0
class Match

Bases: sip.wrapper

construct invalid match

QgsPointLocator.Match(t: QgsPointLocator.Type, vl: QgsVectorLayer, fid: int, dist: float, pt: QgsPointXY, vertexIndex: int = 0, edgePoints: QgsPointXY = None)

QgsPointLocator.Match(QgsPointLocator.Match)

distance(self) → float

for vertex / edge match units depending on what class returns it (geom.cache: layer units, map canvas snapper: dest crs units)

edgePoints(self) → Tuple[QgsPointXY, QgsPointXY]

Only for a valid edge match - obtain endpoints of the edge

featureId(self) → int

The id of the feature to which the snapped geometry belongs.

hasArea(self) → bool
hasEdge(self) → bool
hasVertex(self) → bool
isValid(self) → bool
layer(self) → QgsVectorLayer

The vector layer where the snap occurred. Will be null if the snap happened on an intersection.

point(self) → QgsPointXY

for vertex / edge match coords depending on what class returns it (geom.cache: layer coords, map canvas snapper: dest coords)

type(self) → QgsPointLocator.Type
vertexIndex(self) → int

for vertex / edge match (first vertex of the edge)

class MatchFilter

Bases: sip.wrapper

QgsPointLocator.MatchFilter(QgsPointLocator.MatchFilter)

acceptMatch(self, match: QgsPointLocator.Match) → bool
class Type

Bases: int

class Types

Bases: sip.wrapper

QgsPointLocator.Types(Union[QgsPointLocator.Types, QgsPointLocator.Type]) QgsPointLocator.Types(QgsPointLocator.Types)

Vertex = 1
cachedGeometryCount(self) → int

Return how many geometries are cached in the index

New in version 2.14.

childEvent()
connectNotify()
customEvent()
destinationCrs(self) → QgsCoordinateReferenceSystem

Get destination CRS - may be an invalid QgsCoordinateReferenceSystem if not doing OTF reprojection

New in version 2.14.

destroyIndex(self)
disconnectNotify()
edgesInRect(self, rect: QgsRectangle, filter: QgsPointLocator.MatchFilter = None) → object

Find edges within a specified recangle Optional filter may discard unwanted matches.

edgesInRect(self, point: QgsPointXY, tolerance: float, filter: QgsPointLocator.MatchFilter = None) -> object Override of edgesInRect that construct rectangle from a center point and tolerance

extent(self) → QgsRectangle

Get extent of the area point locator covers - if null then it caches the whole layer

New in version 2.14.

hasIndex(self) → bool

Indicate whether the data have been already indexed

init(self, maxFeaturesToIndex: int = -1) → bool

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 *

isSignalConnected()
layer(self) → QgsVectorLayer

Get associated layer

New in version 2.14.

nearestEdge(self, point: QgsPointXY, tolerance: float, filter: QgsPointLocator.MatchFilter = None) → QgsPointLocator.Match

Find nearest edge to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.

nearestVertex(self, point: QgsPointXY, tolerance: float, filter: QgsPointLocator.MatchFilter = None) → QgsPointLocator.Match

Find nearest vertex to the specified point - up to distance specified by tolerance Optional filter may discard unwanted matches.

pointInPolygon(self, point: QgsPointXY) → object

find out if the point is in any polygons

rebuildIndex(self, maxFeaturesToIndex: int = -1) → bool
receivers()
sender()
senderSignalIndex()
setExtent(self, extent: QgsRectangle)

Configure extent - if not null, it will index only that area

New in version 2.14.

timerEvent()