QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Utility class that construct a planar graph from the input vector layers and provides shortest path search for tracing of existing features. More...
#include <qgstracer.h>
Public Types | |
enum | PathError { ErrNone , ErrTooManyFeatures , ErrPoint1 , ErrPoint2 , ErrNoPath } |
Possible errors that may happen when calling findShortestPath() More... | |
Public Member Functions | |
QgsTracer () | |
Constructor for QgsTracer. | |
~QgsTracer () override | |
bool | addPointsOnIntersectionsEnabled () const |
Returns whether the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers. | |
QgsCoordinateReferenceSystem | destinationCrs () const |
Returns the CRS used for tracing. | |
QgsRectangle | extent () const |
Gets extent to which graph's features will be limited (empty extent means no limit) | |
QVector< QgsPointXY > | findShortestPath (const QgsPointXY &p1, const QgsPointXY &p2, PathError *error=nullptr) |
Given two points, find the shortest path and return points on the way. | |
bool | hasTopologyProblem () const |
Whether there was an error during graph creation due to noding exception, indicating some input data topology problems. | |
bool | init () |
Build the internal data structures. | |
bool | isInitialized () const |
Whether the internal data structures have been initialized. | |
bool | isPointSnapped (const QgsPointXY &pt) |
Find out whether the point is snapped to a vertex or edge (i.e. it can be used for tracing start/stop) | |
QList< QgsVectorLayer * > | layers () const |
Gets layers used for tracing. | |
int | maxFeatureCount () const |
Gets maximum possible number of features in graph. If the number is exceeded, graph is not created. | |
double | offset () const |
Gets offset in map units that should be applied to the traced paths returned from findShortestPath(). | |
void | offsetParameters (int &quadSegments, int &joinStyle, double &miterLimit) |
Gets extra parameters for offset curve algorithm (used when offset is non-zero) | |
void | setAddPointsOnIntersectionsEnabled (bool enable) |
When enable is true , the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers. | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context) |
Sets the crs and transform context used for tracing. | |
void | setExtent (const QgsRectangle &extent) |
Sets extent to which graph's features will be limited (empty extent means no limit) | |
void | setLayers (const QList< QgsVectorLayer * > &layers) |
Sets layers used for tracing. | |
void | setMaxFeatureCount (int count) |
Gets maximum possible number of features in graph. If the number is exceeded, graph is not created. | |
void | setOffset (double offset) |
Set offset in map units that should be applied to the traced paths returned from findShortestPath(). | |
void | setOffsetParameters (int quadSegments, int joinStyle, double miterLimit) |
Set extra parameters for offset curve algorithm (used when offset is non-zero) | |
void | setRenderContext (const QgsRenderContext *renderContext) |
Sets the renderContext used for tracing only on visible features. | |
Protected Slots | |
void | invalidateGraph () |
Destroy the existing graph structure if any (de-initialize) | |
Protected Member Functions | |
virtual void | configure () |
Allows derived classes to setup the settings just before the tracer is initialized. | |
Utility class that construct a planar graph from the input vector layers and provides shortest path search for tracing of existing features.
Definition at line 43 of file qgstracer.h.
enum QgsTracer::PathError |
Possible errors that may happen when calling findShortestPath()
Definition at line 131 of file qgstracer.h.
|
default |
Constructor for QgsTracer.
|
override |
Definition at line 611 of file qgstracer.cpp.
|
inline |
Returns whether the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers.
Definition at line 162 of file qgstracer.h.
|
inlineprotectedvirtual |
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.
Reimplemented in QgsMapCanvasTracer.
Definition at line 170 of file qgstracer.h.
|
inline |
Returns the CRS used for tracing.
Definition at line 63 of file qgstracer.h.
|
inline |
Gets extent to which graph's features will be limited (empty extent means no limit)
Definition at line 78 of file qgstracer.h.
QVector< QgsPointXY > QgsTracer::findShortestPath | ( | const QgsPointXY & | p1, |
const QgsPointXY & | p2, | ||
PathError * | error = nullptr |
||
) |
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 nullptr
Definition at line 750 of file qgstracer.cpp.
|
inline |
Whether there was an error during graph creation due to noding exception, indicating some input data topology problems.
Definition at line 128 of file qgstracer.h.
bool QgsTracer::init | ( | ) |
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.
Definition at line 689 of file qgstracer.cpp.
|
protectedslot |
Destroy the existing graph structure if any (de-initialize)
Definition at line 701 of file qgstracer.cpp.
|
inline |
Whether the internal data structures have been initialized.
Definition at line 122 of file qgstracer.h.
bool QgsTracer::isPointSnapped | ( | const QgsPointXY & | pt | ) |
Find out whether the point is snapped to a vertex or edge (i.e. it can be used for tracing start/stop)
Definition at line 844 of file qgstracer.cpp.
|
inline |
Gets layers used for tracing.
Definition at line 55 of file qgstracer.h.
|
inline |
Gets maximum possible number of features in graph. If the number is exceeded, graph is not created.
Definition at line 109 of file qgstracer.h.
|
inline |
Gets 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.
Definition at line 86 of file qgstracer.h.
void QgsTracer::offsetParameters | ( | int & | quadSegments, |
int & | joinStyle, | ||
double & | miterLimit | ||
) |
Gets extra parameters for offset curve algorithm (used when offset is non-zero)
Definition at line 675 of file qgstracer.cpp.
void QgsTracer::setAddPointsOnIntersectionsEnabled | ( | bool | enable | ) |
When enable is true
, the shortest path's straight segments will include vertices where the input layers intersect, even if no such vertex existed on the input layers.
Definition at line 858 of file qgstracer.cpp.
void QgsTracer::setDestinationCrs | ( | const QgsCoordinateReferenceSystem & | crs, |
const QgsCoordinateTransformContext & | context | ||
) |
Sets the crs and transform context used for tracing.
Definition at line 648 of file qgstracer.cpp.
void QgsTracer::setExtent | ( | const QgsRectangle & | extent | ) |
Sets extent to which graph's features will be limited (empty extent means no limit)
Definition at line 661 of file qgstracer.cpp.
void QgsTracer::setLayers | ( | const QList< QgsVectorLayer * > & | layers | ) |
Sets layers used for tracing.
Definition at line 616 of file qgstracer.cpp.
|
inline |
Gets maximum possible number of features in graph. If the number is exceeded, graph is not created.
Definition at line 111 of file qgstracer.h.
void QgsTracer::setOffset | ( | double | offset | ) |
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.
Definition at line 670 of file qgstracer.cpp.
void QgsTracer::setOffsetParameters | ( | int | quadSegments, |
int | joinStyle, | ||
double | miterLimit | ||
) |
Set extra parameters for offset curve algorithm (used when offset is non-zero)
Definition at line 682 of file qgstracer.cpp.
void QgsTracer::setRenderContext | ( | const QgsRenderContext * | renderContext | ) |
Sets the renderContext used for tracing only on visible features.
Definition at line 655 of file qgstracer.cpp.