QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
A geometry engine is a low-level representation of a QgsAbstractGeometry object, optimised for use with external geometry libraries such as GEOS. More...
#include <qgsgeometryengine.h>
Public Types | |
enum | EngineOperationResult { Success = 0 , NothingHappened = 1000 , MethodNotImplemented , EngineError , NodedGeometryError , InvalidBaseGeometry , InvalidInput , SplitCannotSplitPoint } |
Success or failure of a geometry operation. More... | |
Public Member Functions | |
virtual | ~QgsGeometryEngine ()=default |
virtual double | area (QString *errorMsg=nullptr) const =0 |
virtual QgsAbstractGeometry * | buffer (double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit, QString *errorMsg=nullptr) const =0 |
Buffers a geometry. | |
virtual QgsAbstractGeometry * | buffer (double distance, int segments, QString *errorMsg=nullptr) const =0 |
virtual QgsPoint * | centroid (QString *errorMsg=nullptr) const =0 |
Calculates the centroid of this. | |
virtual QgsAbstractGeometry * | combine (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the combination of this and geom. | |
virtual QgsAbstractGeometry * | combine (const QVector< QgsAbstractGeometry * > &geomList, QString *errorMsg, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the combination of this and geometries. | |
virtual QgsAbstractGeometry * | combine (const QVector< QgsGeometry > &geometries, QString *errorMsg=nullptr, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the combination of this and geometries. | |
virtual bool | contains (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom contains this. | |
virtual QgsAbstractGeometry * | convexHull (QString *errorMsg=nullptr) const =0 |
Calculate the convex hull of this. | |
virtual bool | crosses (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom crosses this. | |
virtual QgsAbstractGeometry * | difference (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the difference of this and geom. | |
virtual bool | disjoint (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom is disjoint from this. | |
virtual double | distance (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Calculates the distance between this and geom. | |
virtual bool | distanceWithin (const QgsAbstractGeometry *geom, double maxdistance, QString *errorMsg=nullptr) const =0 |
Checks if geom is within maxdistance distance from this geometry. | |
virtual QgsAbstractGeometry * | envelope (QString *errorMsg=nullptr) const =0 |
virtual void | geometryChanged ()=0 |
Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit. | |
virtual QgsAbstractGeometry * | interpolate (double distance, QString *errorMsg=nullptr) const =0 |
virtual QgsAbstractGeometry * | intersection (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the intersection of this and geom. | |
virtual bool | intersects (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom intersects this. | |
virtual bool | isEmpty (QString *errorMsg) const =0 |
virtual bool | isEqual (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if this is equal to geom. | |
virtual bool | isSimple (QString *errorMsg=nullptr) const =0 |
Determines whether the geometry is simple (according to OGC definition). | |
virtual bool | isValid (QString *errorMsg=nullptr, bool allowSelfTouchingHoles=false, QgsGeometry *errorLoc=nullptr) const =0 |
Returns true if the geometry is valid. | |
virtual double | length (QString *errorMsg=nullptr) const =0 |
virtual QgsAbstractGeometry * | offsetCurve (double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit, QString *errorMsg=nullptr) const =0 |
Offsets a curve. | |
virtual bool | overlaps (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom overlaps this. | |
virtual QgsPoint * | pointOnSurface (QString *errorMsg=nullptr) const =0 |
Calculate a point that is guaranteed to be on the surface of this. | |
virtual void | prepareGeometry ()=0 |
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster. | |
virtual QString | relate (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries. | |
virtual bool | relatePattern (const QgsAbstractGeometry *geom, const QString &pattern, QString *errorMsg=nullptr) const =0 |
Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern. | |
void | setLogErrors (bool enabled) |
Sets whether warnings and errors encountered during the geometry operations should be logged. | |
virtual QgsAbstractGeometry * | simplify (double tolerance, QString *errorMsg=nullptr) const =0 |
virtual QgsGeometryEngine::EngineOperationResult | splitGeometry (const QgsLineString &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QgsPointSequence &topologyTestPoints, QString *errorMsg=nullptr, bool skipIntersectionCheck=false) const |
Splits this geometry according to a given line. | |
virtual QgsAbstractGeometry * | symDifference (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const =0 |
Calculate the symmetric difference of this and geom. | |
virtual bool | touches (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom touches this. | |
virtual bool | within (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const =0 |
Checks if geom is within this. | |
Protected Member Functions | |
QgsGeometryEngine (const QgsAbstractGeometry *geometry) | |
void | logError (const QString &engineName, const QString &message) const |
Logs an error message encountered during an operation. | |
Protected Attributes | |
const QgsAbstractGeometry * | mGeometry = nullptr |
bool | mLogErrors = true |
A geometry engine is a low-level representation of a QgsAbstractGeometry object, optimised for use with external geometry libraries such as GEOS.
QgsGeometryEngine objects provide a mechanism for optimized evaluation of geometric algorithms, including spatial relationships between geometries and operations such as buffers or clipping.
QgsGeometryEngine objects are not created directly, but are instead created by calling QgsGeometry::createGeometryEngine().
Many methods available in the QgsGeometryEngine class can benefit from pre-preparing geometries. For instance, whenever a large number of spatial relationships will be tested (such as calling intersects(), within(), etc) then the geometry should first be prepared by calling prepareGeometry() before performing the tests.
QgsGeometryEngine operations are backed by the GEOS library (https://trac.osgeo.org/geos/).
Definition at line 67 of file qgsgeometryengine.h.
Success or failure of a geometry operation.
This gives details about cause of failure.
Definition at line 75 of file qgsgeometryengine.h.
|
virtualdefault |
|
inlineprotected |
Definition at line 361 of file qgsgeometryengine.h.
|
pure virtual |
Implemented in QgsGeos.
|
pure virtual |
Buffers a geometry.
Implemented in QgsGeos.
|
pure virtual |
Implemented in QgsGeos.
|
pure virtual |
|
pure virtual |
Calculate the combination of this and geom.
geom | geometry to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the union results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Calculate the combination of this and geometries.
geomList | list of geometries to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the combination results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Calculate the combination of this and geometries.
geometries | list of geometries to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the combination results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Checks if geom contains this.
Implemented in QgsGeos.
|
pure virtual |
Calculate the convex hull of this.
Implemented in QgsGeos.
|
pure virtual |
Checks if geom crosses this.
Implemented in QgsGeos.
|
pure virtual |
Calculate the difference of this and geom.
geom | geometry to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the difference results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Checks if geom is disjoint from this.
Implemented in QgsGeos.
|
pure virtual |
Calculates the distance between this and geom.
Implemented in QgsGeos.
|
pure virtual |
Checks if geom is within maxdistance distance from this geometry.
Implemented in QgsGeos.
|
pure virtual |
Implemented in QgsGeos.
|
pure virtual |
Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit.
Implemented in QgsGeos.
|
pure virtual |
Implemented in QgsGeos.
|
pure virtual |
Calculate the intersection of this and geom.
geom | geometry to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the intersection results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Checks if geom intersects this.
Implemented in QgsGeos.
|
pure virtual |
Implemented in QgsGeos.
|
pure virtual |
Checks if this is equal to geom.
If both are Null geometries, \c false
is returned.
Implemented in QgsGeos.
|
pure virtual |
Determines whether the geometry is simple (according to OGC definition).
Implemented in QgsGeos.
|
pure virtual |
Returns true
if the geometry is valid.
If the geometry is invalid, errorMsg will be filled with the reported geometry error.
The allowSelfTouchingHoles argument specifies whether self-touching holes are permitted. OGC validity states that self-touching holes are NOT permitted, whilst other vendor validity checks (e.g. ESRI) permit self-touching holes.
If errorLoc is specified, it will be set to the geometry of the error location.
Implemented in QgsGeos.
|
pure virtual |
Implemented in QgsGeos.
|
inlineprotected |
Logs an error message encountered during an operation.
Definition at line 352 of file qgsgeometryengine.h.
|
pure virtual |
Offsets a curve.
Implemented in QgsGeos.
|
pure virtual |
Checks if geom overlaps this.
Implemented in QgsGeos.
|
pure virtual |
Calculate a point that is guaranteed to be on the surface of this.
May return a \c nullptr
.
Implemented in QgsGeos.
|
pure virtual |
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.
This should be called for any geometry which is used for multiple relation tests against other geometries.
Implemented in QgsGeos.
|
pure virtual |
Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.
geom | geometry to relate to |
errorMsg | destination storage for any error message |
Implemented in QgsGeos.
|
pure virtual |
Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.
geom | geometry to relate to |
pattern | DE-9IM pattern for match |
errorMsg | destination storage for any error message |
true
if geometry relationship matches with pattern Implemented in QgsGeos.
|
inline |
Sets whether warnings and errors encountered during the geometry operations should be logged.
By default these errors are logged to the console and in the QGIS UI. But for some operations errors are expected and logging these just results in noise. In this case setting enabled to false
will avoid the automatic error reporting.
Definition at line 339 of file qgsgeometryengine.h.
|
pure virtual |
Implemented in QgsGeos.
|
inlinevirtual |
Splits this geometry according to a given line.
splitLine | the line that splits the geometry | |
[out] | newGeometries | list of new geometries that have been created with the split |
topological | true if topological editing is enabled | |
[out] | topologyTestPoints | points that need to be tested for topological completeness in the dataset |
[out] | errorMsg | error messages emitted, if any |
skipIntersectionCheck | set to true to skip the potentially expensive initial intersection check. Only set this flag if an intersection test has already been performed by the caller! |
Reimplemented in QgsGeos.
Definition at line 312 of file qgsgeometryengine.h.
|
pure virtual |
Calculate the symmetric difference of this and geom.
geom | geometry to perform the operation |
errorMsg | Error message returned by GEOS |
parameters | can be used to specify parameters which control the difference results (since QGIS 3.28) |
Implemented in QgsGeos.
|
pure virtual |
Checks if geom touches this.
Implemented in QgsGeos.
|
pure virtual |
Checks if geom is within this.
Implemented in QgsGeos.
|
protected |
Definition at line 342 of file qgsgeometryengine.h.
|
protected |
Definition at line 343 of file qgsgeometryengine.h.