QGIS API Documentation
3.0.2-Girona (307d082)
|
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. More... | |
~QgsTracer () override | |
QgsCoordinateReferenceSystem | destinationCrs () const |
Returns the CRS used for tracing. More... | |
QgsRectangle | extent () const |
Get extent to which graph's features will be limited (empty extent means no limit) More... | |
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. More... | |
bool | hasTopologyProblem () const |
Whether there was an error during graph creation due to noding exception, indicating some input data topology problems. More... | |
bool | init () |
Build the internal data structures. More... | |
bool | isInitialized () const |
Whether the internal data structures have been initialized. More... | |
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) More... | |
QList< QgsVectorLayer * > | layers () const |
Get layers used for tracing. More... | |
int | maxFeatureCount () const |
Get maximum possible number of features in graph. If the number is exceeded, graph is not created. More... | |
double | offset () const |
Get offset in map units that should be applied to the traced paths returned from findShortestPath(). More... | |
void | offsetParameters (int &quadSegments, int &joinStyle, double &miterLimit) |
Get extra parameters for offset curve algorithm (used when offset is non-zero) More... | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context) |
Sets the crs and transform context used for tracing. More... | |
void | setExtent (const QgsRectangle &extent) |
Set extent to which graph's features will be limited (empty extent means no limit) More... | |
void | setLayers (const QList< QgsVectorLayer *> &layers) |
Set layers used for tracing. More... | |
void | setMaxFeatureCount (int count) |
Get maximum possible number of features in graph. If the number is exceeded, graph is not created. More... | |
void | setOffset (double offset) |
Set offset in map units that should be applied to the traced paths returned from findShortestPath(). More... | |
void | setOffsetParameters (int quadSegments, int joinStyle, double miterLimit) |
Set extra parameters for offset curve algorithm (used when offset is non-zero) More... | |
Protected Slots | |
void | invalidateGraph () |
Destroy the existing graph structure if any (de-initialize) More... | |
Protected Member Functions | |
virtual void | configure () |
Allows derived classes to setup the settings just before the tracer is initialized. More... | |
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 40 of file qgstracer.h.
enum QgsTracer::PathError |
Possible errors that may happen when calling findShortestPath()
Definition at line 123 of file qgstracer.h.
|
default |
Constructor for QgsTracer.
|
override |
Definition at line 551 of file qgstracer.cpp.
|
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 149 of file qgstracer.h.
|
inline |
Returns the CRS used for tracing.
Definition at line 60 of file qgstracer.h.
|
inline |
Get extent to which graph's features will be limited (empty extent means no limit)
Definition at line 69 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 null
Definition at line 660 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 120 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 617 of file qgstracer.cpp.
|
protectedslot |
Destroy the existing graph structure if any (de-initialize)
Definition at line 629 of file qgstracer.cpp.
|
inline |
Whether the internal data structures have been initialized.
Definition at line 113 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 727 of file qgstracer.cpp.
|
inline |
Get layers used for tracing.
Definition at line 52 of file qgstracer.h.
|
inline |
Get maximum possible number of features in graph. If the number is exceeded, graph is not created.
Definition at line 100 of file qgstracer.h.
|
inline |
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.
Definition at line 78 of file qgstracer.h.
void QgsTracer::offsetParameters | ( | int & | quadSegments, |
int & | joinStyle, | ||
double & | miterLimit | ||
) |
Get extra parameters for offset curve algorithm (used when offset is non-zero)
Definition at line 603 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 582 of file qgstracer.cpp.
void QgsTracer::setExtent | ( | const QgsRectangle & | extent | ) |
Set extent to which graph's features will be limited (empty extent means no limit)
Definition at line 589 of file qgstracer.cpp.
void QgsTracer::setLayers | ( | const QList< QgsVectorLayer *> & | layers | ) |
Set layers used for tracing.
Definition at line 556 of file qgstracer.cpp.
|
inline |
Get maximum possible number of features in graph. If the number is exceeded, graph is not created.
Definition at line 102 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 598 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 610 of file qgstracer.cpp.