QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsgeometryengine.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometryengine.h
3  -------------------------------------------------------------------
4 Date : 22 Sept 2014
5 Copyright : (C) 2014 by Marco Hugentobler
6 email : marco.hugentobler at sourcepole dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSGEOMETRYENGINE_H
17 #define QGSGEOMETRYENGINE_H
18 
19 #include "qgis_core.h"
20 #include "qgslinestring.h"
21 #include "qgsgeometry.h"
22 
23 #include <QVector>
24 
26 
33 class CORE_EXPORT QgsGeometryEngine
34 {
35  public:
36 
42  {
43  Success = 0,
44  NothingHappened = 1000,
50  /* split */
52  };
53 
54  virtual ~QgsGeometryEngine() = default;
55 
60  virtual void geometryChanged() = 0;
61 
71  virtual void prepareGeometry() = 0;
72 
78  virtual QgsAbstractGeometry *intersection( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
79 
85  virtual QgsAbstractGeometry *difference( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
86 
92  virtual QgsAbstractGeometry *combine( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
93 
99  virtual QgsAbstractGeometry *combine( const QVector<QgsAbstractGeometry *> &geomList, QString *errorMsg ) const = 0 SIP_FACTORY;
100 
106  virtual QgsAbstractGeometry *combine( const QVector< QgsGeometry > &geometries, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
107 
113  virtual QgsAbstractGeometry *symDifference( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
114  virtual QgsAbstractGeometry *buffer( double distance, int segments, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
115  virtual QgsAbstractGeometry *buffer( double distance, int segments, int endCapStyle, int joinStyle, double miterLimit, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
116  virtual QgsAbstractGeometry *simplify( double tolerance, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
117  virtual QgsAbstractGeometry *interpolate( double distance, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
118  virtual QgsAbstractGeometry *envelope( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
119 
126  virtual QgsPoint *centroid( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
127 
134  virtual QgsPoint *pointOnSurface( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
135 
139  virtual QgsAbstractGeometry *convexHull( QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
140 
146  virtual double distance( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
147 
153  virtual bool intersects( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
154 
160  virtual bool touches( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
161 
167  virtual bool crosses( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
168 
174  virtual bool within( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
175 
181  virtual bool overlaps( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
182 
188  virtual bool contains( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
189 
195  virtual bool disjoint( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
196 
205  virtual QString relate( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
206 
216  virtual bool relatePattern( const QgsAbstractGeometry *geom, const QString &pattern, QString *errorMsg = nullptr ) const = 0;
217 
218  virtual double area( QString *errorMsg = nullptr ) const = 0;
219  virtual double length( QString *errorMsg = nullptr ) const = 0;
220 
232  virtual bool isValid( QString *errorMsg = nullptr, bool allowSelfTouchingHoles = false, QgsGeometry *errorLoc = nullptr ) const = 0;
233 
240  virtual bool isEqual( const QgsAbstractGeometry *geom, QString *errorMsg = nullptr ) const = 0;
241  virtual bool isEmpty( QString *errorMsg ) const = 0;
242 
247  virtual bool isSimple( QString *errorMsg = nullptr ) const = 0;
248 
259  QVector<QgsGeometry > &newGeometries SIP_OUT,
260  bool topological,
261  QgsPointSequence &topologyTestPoints, QString *errorMsg = nullptr ) const
262  {
263  Q_UNUSED( splitLine )
264  Q_UNUSED( newGeometries )
265  Q_UNUSED( topological )
266  Q_UNUSED( topologyTestPoints )
267  Q_UNUSED( errorMsg )
268  return MethodNotImplemented;
269  }
270 
271  virtual QgsAbstractGeometry *offsetCurve( double distance, int segments, int joinStyle, double miterLimit, QString *errorMsg = nullptr ) const = 0 SIP_FACTORY;
272 
273  protected:
274  const QgsAbstractGeometry *mGeometry = nullptr;
275 
277  : mGeometry( geometry )
278  {}
279 };
280 
281 #endif // QGSGEOMETRYENGINE_H
QgsGeometryEngine::InvalidInput
@ InvalidInput
The input is not valid.
Definition: qgsgeometryengine.h:49
qgslinestring.h
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsGeometryEngine::EngineError
@ EngineError
Error occurred in the geometry engine.
Definition: qgsgeometryengine.h:46
QgsGeometryEngine::MethodNotImplemented
@ MethodNotImplemented
Method not implemented in geometry engine.
Definition: qgsgeometryengine.h:45
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:43
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsGeometryEngine::NodedGeometryError
@ NodedGeometryError
Error occurred while creating a noded geometry.
Definition: qgsgeometryengine.h:47
QgsGeometryEngine::InvalidBaseGeometry
@ InvalidBaseGeometry
The geometry on which the operation occurs is not valid.
Definition: qgsgeometryengine.h:48
QgsGeometryEngine::splitGeometry
virtual QgsGeometryEngine::EngineOperationResult splitGeometry(const QgsLineString &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QgsPointSequence &topologyTestPoints, QString *errorMsg=nullptr) const
Splits this geometry according to a given line.
Definition: qgsgeometryengine.h:258
QgsGeometryEngine::QgsGeometryEngine
QgsGeometryEngine(const QgsAbstractGeometry *geometry)
Definition: qgsgeometryengine.h:276
QgsAbstractGeometry
Abstract base class for all geometries.
Definition: qgsabstractgeometry.h:71
QgsGeometryEngine::SplitCannotSplitPoint
@ SplitCannotSplitPoint
Points cannot be split.
Definition: qgsgeometryengine.h:51
qgsgeometry.h
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:44
QgsGeometry
Definition: qgsgeometry.h:122
QgsGeometryEngine::EngineOperationResult
EngineOperationResult
Success or failure of a geometry operation.
Definition: qgsgeometryengine.h:41
QgsGeometryEngine
Contains geometry relation and modification algorithms.
Definition: qgsgeometryengine.h:33