QgsGeometryEngine class

Contains geometry relation and modification algorithms.

Derived classes

class QgsGeos
Does vector analysis using the geos library and handles import, export, exception handling*.

Public types

enum EngineOperationResult { Success = 0, NothingHappened = 1000, MethodNotImplemented, EngineError, NodedGeometryError, InvalidBaseGeometry, InvalidInput, SplitCannotSplitPoint }
Success or failure of a geometry operation.

Public functions

auto centroid(QString* errorMsg = nullptr) const -> QgsPoint* pure virtual
Calculates the centroid of this.
auto combine(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the combination of this and geom.
auto combine(const QVector<QgsAbstractGeometry*>& geomList, QString* errorMsg) const -> QgsAbstractGeometry* pure virtual
Calculate the combination of this and geometries.
auto combine(const QVector<QgsGeometry>& geometries, QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the combination of this and geometries.
auto contains(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom contains this.
auto convexHull(QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the convex hull of this.
auto crosses(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom crosses this.
auto difference(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the difference of this and geom.
auto disjoint(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom is disjoint from this.
auto distance(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> double pure virtual
Calculates the distance between this and geom.
void geometryChanged() pure virtual
Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit.
auto intersection(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the intersection of this and geom.
auto intersects(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom intersects this.
auto isEqual(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if this is equal to geom.
auto isSimple(QString* errorMsg = nullptr) const -> bool pure virtual
Determines whether the geometry is simple (according to OGC definition).
auto overlaps(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom overlaps this.
auto pointOnSurface(QString* errorMsg = nullptr) const -> QgsPoint* pure virtual
Calculate a point that is guaranteed to be on the surface of this.
void prepareGeometry() pure virtual
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.
auto relate(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> QString pure virtual
Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.
auto relatePattern(const QgsAbstractGeometry* geom, const QString& pattern, QString* errorMsg = nullptr) const -> bool pure virtual
Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.
auto splitGeometry(const QgsLineString& splitLine, QVector<QgsGeometry>& newGeometries, bool topological, QgsPointSequence& topologyTestPoints, QString* errorMsg = nullptr) const -> QgsGeometryEngine::EngineOperationResult virtual
Splits this geometry according to a given line.
auto symDifference(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> QgsAbstractGeometry* pure virtual
Calculate the symmetric difference of this and geom.
auto touches(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom touches this.
auto within(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const -> bool pure virtual
Checks if geom is within this.

Enum documentation

enum QgsGeometryEngine::EngineOperationResult

Success or failure of a geometry operation.

This gives details about cause of failure.

Enumerators
Success

Operation succeeded.

NothingHappened

Nothing happened, without any error.

MethodNotImplemented

Method not implemented in geometry engine.

EngineError

Error occurred in the geometry engine.

NodedGeometryError

Error occurred while creating a noded geometry.

InvalidBaseGeometry

The geometry on which the operation occurs is not valid.

InvalidInput

The input is not valid.

SplitCannotSplitPoint

Points cannot be split.

Function documentation

QgsPoint* QgsGeometryEngine::centroid(QString* errorMsg = nullptr) const pure virtual

Calculates the centroid of this.

May return a nullptr.

QgsAbstractGeometry* QgsGeometryEngine::combine(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Calculate the combination of this and geom.

QgsAbstractGeometry* QgsGeometryEngine::combine(const QVector<QgsAbstractGeometry*>& geomList, QString* errorMsg) const pure virtual

Calculate the combination of this and geometries.

QgsAbstractGeometry* QgsGeometryEngine::combine(const QVector<QgsGeometry>& geometries, QString* errorMsg = nullptr) const pure virtual

Calculate the combination of this and geometries.

bool QgsGeometryEngine::contains(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom contains this.

bool QgsGeometryEngine::crosses(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom crosses this.

QgsAbstractGeometry* QgsGeometryEngine::difference(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Calculate the difference of this and geom.

bool QgsGeometryEngine::disjoint(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom is disjoint from this.

double QgsGeometryEngine::distance(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Calculates the distance between this and geom.

QgsAbstractGeometry* QgsGeometryEngine::intersection(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Calculate the intersection of this and geom.

bool QgsGeometryEngine::intersects(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom intersects this.

bool QgsGeometryEngine::isEqual(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if this is equal to geom.

If both are Null geometries, false is returned.

bool QgsGeometryEngine::isSimple(QString* errorMsg = nullptr) const pure virtual

Determines whether the geometry is simple (according to OGC definition).

bool QgsGeometryEngine::overlaps(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom overlaps this.

QgsPoint* QgsGeometryEngine::pointOnSurface(QString* errorMsg = nullptr) const pure virtual

Calculate a point that is guaranteed to be on the surface of this.

May return a nullptr.

void QgsGeometryEngine::prepareGeometry() 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.

QString QgsGeometryEngine::relate(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.

Parameters
geom geometry to relate to
errorMsg destination storage for any error message
Returns DE-9IM string for relationship, or an empty string if an error occurred

bool QgsGeometryEngine::relatePattern(const QgsAbstractGeometry* geom, const QString& pattern, QString* errorMsg = nullptr) const pure virtual

Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.

Parameters
geom geometry to relate to
pattern DE-9IM pattern for match
errorMsg destination storage for any error message
Returns true if geometry relationship matches with pattern

QgsGeometryEngine::EngineOperationResult QgsGeometryEngine::splitGeometry(const QgsLineString& splitLine, QVector<QgsGeometry>& newGeometries, bool topological, QgsPointSequence& topologyTestPoints, QString* errorMsg = nullptr) const virtual

Splits this geometry according to a given line.

Parameters
splitLine the line that splits the geometry
newGeometries out list of new geometries that have been created with the split
topological true if topological editing is enabled
topologyTestPoints out points that need to be tested for topological completeness in the dataset
errorMsg out error messages emitted, if any
Returns 0 in case of success, 1 if geometry has not been split, error else

QgsAbstractGeometry* QgsGeometryEngine::symDifference(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Calculate the symmetric difference of this and geom.

bool QgsGeometryEngine::touches(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom touches this.

bool QgsGeometryEngine::within(const QgsAbstractGeometry* geom, QString* errorMsg = nullptr) const pure virtual

Checks if geom is within this.