Subgroup: other

Class: QgsTracer

class qgis.core.QgsTracer

Bases: PyQt5.QtCore.QObject

Utility class that construct a planar graph from the input vector layers and provides shortest path search for tracing of existing features.

New in version 2.14: Methods

blockSignals
childEvent
children
configure Allows derived classes to setup the settings just before the tracer is initialized.
connectNotify
customEvent
deleteLater
destinationCrs Returns the CRS used for tracing.
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
event
eventFilter
extent Get extent to which graph’s features will be limited (empty extent means no limit)
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]
findShortestPath Given two points, find the shortest path and return points on the way.
hasTopologyProblem Whether there was an error during graph creation due to noding exception,
inherits
init Build the internal data structures.
installEventFilter
invalidateGraph Destroy the existing graph structure if any (de-initialize)
isInitialized Whether the internal data structures have been initialized
isPointSnapped Find out whether the point is snapped to a vertex or edge (i.e.
isSignalConnected
isWidgetType
isWindowType
killTimer
layers Get layers used for tracing
maxFeatureCount Get maximum possible number of features in graph.
metaObject
moveToThread
objectName
offset Get offset in map units that should be applied to the traced paths returned from findShortestPath().
offsetParameters Get extra parameters for offset curve algorithm (used when offset is non-zero)
parent
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
receivers
removeEventFilter
sender
senderSignalIndex
setDestinationCrs Sets the crs and transform context used for tracing.
setExtent Set extent to which graph’s features will be limited (empty extent means no limit)
setLayers Set layers used for tracing
setMaxFeatureCount Get maximum possible number of features in graph.
setObjectName
setOffset Set offset in map units that should be applied to the traced paths returned from findShortestPath().
setOffsetParameters Set extra parameters for offset curve algorithm (used when offset is non-zero)
setParent
setProperty
signalsBlocked
startTimer
thread
timerEvent
tr

Attributes

ErrNoPath
ErrNone
ErrPoint1
ErrPoint2
ErrTooManyFeatures
destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
staticMetaObject
ErrNoPath = 4
ErrNone = 0
ErrPoint1 = 2
ErrPoint2 = 3
ErrTooManyFeatures = 1
class PathError

Bases: int

childEvent()
configure(self)

Allows derived classes to setup the settings just before the tracer is initialized. This allows the configuration to be set in a lazy way only when it is really necessary. Default implementation does nothing.

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

Returns the CRS used for tracing.

disconnectNotify()
extent(self) → QgsRectangle

Get extent to which graph’s features will be limited (empty extent means no limit)

findShortestPath(self, p1: QgsPointXY, p2: QgsPointXY) → Tuple[List[QgsPointXY], QgsTracer.PathError]

Given two points, find the shortest path and return points on the way. The optional “error” argument may receive error code (PathError enum) if it is not null

Returns:array of points - trace of linestrings of other features (empty array one error)
hasTopologyProblem(self) → bool

Whether there was an error during graph creation due to noding exception, indicating some input data topology problems

New in version 2.16.

init(self) → bool

Build the internal data structures. This may take some time depending on how big the input layers are. It is not necessary to call this method explicitly - it will be called by findShortestPath() if necessary.

invalidateGraph(self)

Destroy the existing graph structure if any (de-initialize)

isInitialized(self) → bool

Whether the internal data structures have been initialized

isPointSnapped(self, pt: QgsPointXY) → bool

Find out whether the point is snapped to a vertex or edge (i.e. it can be used for tracing start/stop)

isSignalConnected()
layers(self) → object

Get layers used for tracing

maxFeatureCount(self) → int

Get maximum possible number of features in graph. If the number is exceeded, graph is not created.

offset(self) → float

Get offset in map units that should be applied to the traced paths returned from findShortestPath(). Positive offset for right side, negative offset for left side.

New in version 3.0.

offsetParameters(self) → Tuple[int, int, float]

Get extra parameters for offset curve algorithm (used when offset is non-zero)

New in version 3.0.

receivers()
sender()
senderSignalIndex()
setDestinationCrs(self, crs: QgsCoordinateReferenceSystem, context: QgsCoordinateTransformContext)

Sets the crs and transform context used for tracing.

See also

destinationCrs()

setExtent(self, extent: QgsRectangle)

Set extent to which graph’s features will be limited (empty extent means no limit)

setLayers(self, layers: Iterable[QgsVectorLayer])

Set layers used for tracing

setMaxFeatureCount(self, count: int)

Get maximum possible number of features in graph. If the number is exceeded, graph is not created.

setOffset(self, offset: float)

Set offset in map units that should be applied to the traced paths returned from findShortestPath(). Positive offset for right side, negative offset for left side.

New in version 3.0.

setOffsetParameters(self, quadSegments: int, joinStyle: int, miterLimit: float)

Set extra parameters for offset curve algorithm (used when offset is non-zero)

New in version 3.0.

timerEvent()