QGIS API Documentation 4.1.0-Master (376402f9aeb)
Loading...
Searching...
No Matches
qgsabstractgeometry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractgeometry.h
3 -------------------------------------------------------------------
4Date : 04 Sept 2014
5Copyright : (C) 2014 by Marco Hugentobler
6email : 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 QGSABSTRACTGEOMETRYV2
17#define QGSABSTRACTGEOMETRYV2
18
19#include <array>
20#include <functional>
21#include <type_traits>
22
23#include "qgis.h"
24#include "qgis_core.h"
25#include "qgswkbptr.h"
26#include "qgswkbtypes.h"
27
28#include <QString>
29
30#ifndef SIP_RUN
31#include <nlohmann/json_fwd.hpp>
32using namespace nlohmann;
33#endif
34
35class QgsMapToPixel;
36class QgsCurve;
37class QgsMultiCurve;
38class QgsMultiPoint;
39
40struct QgsVertexId;
42class QPainter;
43class QDomDocument;
44class QDomElement;
47class QgsConstWkbPtr;
48class QPainterPath;
50class QgsFeedback;
52class QgsPoint;
53class QgsRectangle;
54class QgsBox3D;
55
56typedef QVector< QgsPoint > QgsPointSequence;
57#ifndef SIP_RUN
58typedef QVector< QgsPointSequence > QgsRingSequence;
59typedef QVector< QgsRingSequence > QgsCoordinateSequence;
60#else
61typedef QVector< QVector< QgsPoint > > QgsRingSequence;
62typedef QVector< QVector< QVector< QgsPoint > > > QgsCoordinateSequence;
63#endif
64
65
80class CORE_EXPORT QgsAbstractGeometry
81{
82 // clang-format off
83
84#ifdef SIP_RUN
86 if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) != nullptr )
87 sipType = sipType_QgsPoint;
88 else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) != nullptr )
89 sipType = sipType_QgsLineString;
90 else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) != nullptr )
91 sipType = sipType_QgsCircularString;
92 else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) != nullptr )
93 sipType = sipType_QgsCompoundCurve;
94 else if ( qgsgeometry_cast<QgsNurbsCurve *>( sipCpp ) != nullptr )
95 sipType = sipType_QgsNurbsCurve;
96 else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) != nullptr )
97 sipType = sipType_QgsTriangle;
98 else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) != nullptr )
99 sipType = sipType_QgsPolygon;
100 else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) != nullptr )
101 sipType = sipType_QgsCurvePolygon;
102 else if ( qgsgeometry_cast<QgsTriangulatedSurface *>( sipCpp ) != nullptr )
103 sipType = sipType_QgsTriangulatedSurface;
104 else if ( qgsgeometry_cast<QgsPolyhedralSurface *>( sipCpp ) != nullptr )
105 sipType = sipType_QgsPolyhedralSurface;
106 else if ( qgsgeometry_cast<QgsSurface *>( sipCpp ) != nullptr )
107 sipType = sipType_QgsSurface;
108 else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) != nullptr )
109 sipType = sipType_QgsMultiPoint;
110 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) != nullptr )
111 sipType = sipType_QgsMultiLineString;
112 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) != nullptr )
113 sipType = sipType_QgsMultiPolygon;
114 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) != nullptr )
115 sipType = sipType_QgsMultiSurface;
116 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) != nullptr )
117 sipType = sipType_QgsMultiCurve;
118 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) != nullptr )
119 sipType = sipType_QgsGeometryCollection;
120 else
121 sipType = 0;
122 SIP_END
123#endif
124
125 Q_GADGET
126
127 public:
128
145 Q_ENUM( SegmentationToleranceType )
146
147
149 {
150
154 XY = 0,
155
160 };
162
163 // clang-format on
164
166 virtual ~QgsAbstractGeometry() = default;
168 QgsAbstractGeometry &operator=( const QgsAbstractGeometry &geom );
169
170 // === WARNING ===
171 // implementation of `QgsAbstractGeometry::operator==` are mainly delegated to `fuzzyEquals` functions if the default tolerance/epsilon value is changed, documentation must be updaded accordingly and also changed in expression helper files (resources/function_help/json)
172 virtual bool operator==( const QgsAbstractGeometry &other ) const = 0;
173 virtual bool operator!=( const QgsAbstractGeometry &other ) const = 0;
174
185 virtual bool fuzzyEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const = 0;
186
200 virtual bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const = 0;
201
206
212 virtual int compareTo( const QgsAbstractGeometry *other ) const;
213
217 virtual void clear() = 0;
218
222 virtual QgsRectangle boundingBox() const;
223
229 virtual QgsBox3D boundingBox3D() const = 0;
230
231 //mm-sql interface
232
237 virtual int dimension() const = 0;
238
244 virtual QString geometryType() const = 0;
245
246 // clang-format off
252 inline Qgis::WkbType wkbType() const SIP_HOLDGIL { return mWkbType; }
253 // clang-format on
254
260 QString wktTypeStr() const;
261
266 bool is3D() const SIP_HOLDGIL
267 {
268 return QgsWkbTypes::hasZ( mWkbType );
269 }
270
276 {
277 return QgsWkbTypes::hasM( mWkbType );
278 }
279
286
296 virtual void normalize() = 0;
297
298 //import
299
305 virtual bool fromWkb( QgsConstWkbPtr &wkb ) = 0;
306
311 virtual bool fromWkt( const QString &wkt ) = 0;
312
313 //export
314
324 Q_DECLARE_FLAGS( WkbFlags, WkbFlag )
325
326
334
345 virtual QByteArray asWkb( WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const = 0;
346
355 virtual QString asWkt( int precision = 17 ) const = 0;
356
368 virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const = 0;
369
381 virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const = 0;
382
392 QString asJson( int precision = 17 );
393
404 virtual json asJsonObject( int precision = 17 ) SIP_SKIP const;
405
410 virtual QString asKml( int precision = 17 ) const = 0;
411
412
413 //render pipeline
414
425 virtual void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false ) SIP_THROW( QgsCsException ) = 0;
426
433 virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0,
434 double mTranslate = 0.0, double mScale = 1.0 ) = 0;
435
440 virtual void draw( QPainter &p ) const = 0;
441
450 virtual QPainterPath asQPainterPath() const = 0;
451
461 virtual int vertexNumberFromVertexId( QgsVertexId id ) const = 0;
462
470 virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const = 0;
471
475 virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const = 0;
476
482
486 virtual int nCoordinates() const;
487
491 virtual QgsPoint vertexAt( QgsVertexId id ) const = 0;
492
505 virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT,
506 QgsVertexId &vertexAfter SIP_OUT,
507 int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const = 0;
508
509 //low-level editing
510
519 virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) = 0;
520
529 virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) = 0;
530
538 virtual bool deleteVertex( QgsVertexId position ) = 0;
539
552 virtual double length() const;
553
566 virtual double perimeter() const;
567
581 virtual double area() const;
582
593 virtual double area3D() const;
594
602 virtual double segmentLength( QgsVertexId startVertex ) const = 0;
603
605 virtual QgsPoint centroid() const;
606
610 virtual bool isEmpty() const;
611
615 virtual bool hasCurvedSegments() const;
616
625 virtual bool boundingBoxIntersects( const QgsRectangle &rectangle ) const SIP_HOLDGIL;
626
635 virtual bool boundingBoxIntersects( const QgsBox3D &box3d ) const SIP_HOLDGIL;
636
643 virtual QgsAbstractGeometry *segmentize( double tolerance = M_PI / 180., SegmentationToleranceType toleranceType = MaximumAngle ) const SIP_FACTORY;
644
652
675 virtual QgsAbstractGeometry *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0, bool removeRedundantPoints = false ) const = 0 SIP_FACTORY;
676
689 virtual QgsAbstractGeometry *simplifyByDistance( double tolerance ) const = 0 SIP_FACTORY;
690
710 virtual bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) = 0;
711
719 virtual double vertexAngle( QgsVertexId vertex ) const = 0;
720
724 virtual int vertexCount( int part = 0, int ring = 0 ) const = 0;
725
729 virtual int ringCount( int part = 0 ) const = 0;
730
736 virtual int partCount() const = 0;
737
745 virtual bool addZValue( double zValue = 0 ) = 0;
746
754 virtual bool addMValue( double mValue = 0 ) = 0;
755
762 virtual bool dropZValue() = 0;
763
770 virtual bool dropMValue() = 0;
771
778 virtual void swapXy() = 0;
779
784 virtual bool convertTo( Qgis::WkbType type );
785
805
817 virtual bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const = 0;
818
832 virtual bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = nullptr ) = 0;
833
834#ifndef SIP_RUN
835
845 virtual void filterVertices( const std::function< bool( const QgsPoint & ) > &filter );
846
861 virtual void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform );
862
868 class CORE_EXPORT part_iterator
869 {
870 private:
871
872 int mIndex = 0;
873 QgsAbstractGeometry *mGeometry = nullptr;
874
875 public:
877 part_iterator() = default;
878
880 part_iterator( QgsAbstractGeometry *g, int index );
881
887
890
893
895 int partNumber() const;
896
897 bool operator==( part_iterator other ) const;
898 bool operator!=( part_iterator other ) const { return !( *this == other ); }
899 };
900
910 {
911 return part_iterator( this, 0 );
912 }
913
922 part_iterator parts_end();
923
931 QgsGeometryConstPartIterator parts() const;
932
938 class CORE_EXPORT const_part_iterator
939 {
940 private:
941
942 int mIndex = 0;
943 const QgsAbstractGeometry *mGeometry = nullptr;
944
945 public:
948
950 const_part_iterator( const QgsAbstractGeometry *g, int index );
951
957
960
962 const QgsAbstractGeometry *operator*() const;
963
965 int partNumber() const;
966
967 bool operator==( const_part_iterator other ) const;
968 bool operator!=( const_part_iterator other ) const { return !( *this == other ); }
969 };
970
979 {
980 return const_part_iterator( this, 0 );
981 }
982
990 const_part_iterator const_parts_end() const;
991
992
997 class CORE_EXPORT vertex_iterator
998 {
999 private:
1000
1006 struct Level
1007 {
1008 const QgsAbstractGeometry *g = nullptr;
1009 int index = 0;
1010
1011 bool operator==( const Level &other ) const;
1012 };
1013
1014 std::array<Level, 3> levels;
1015 int depth = -1;
1016
1017 void digDown();
1018
1019 public:
1021 vertex_iterator() = default;
1022
1024 vertex_iterator( const QgsAbstractGeometry *g, int index );
1025
1031
1034
1036 QgsPoint operator*() const;
1037
1039 QgsVertexId vertexId() const;
1040
1041 bool operator==( const vertex_iterator &other ) const;
1042 bool operator!=( const vertex_iterator &other ) const { return !( *this == other ); }
1043 };
1044
1053 {
1054 return vertex_iterator( this, 0 );
1055 }
1056
1065 {
1066 return vertex_iterator( this, childCount() );
1067 }
1068#endif
1069
1104
1105
1128 QgsVertexIterator vertices() const;
1129
1136
1137 protected:
1138
1145 int sortIndex() const;
1146
1157 virtual int compareToSameClass( const QgsAbstractGeometry *other ) const = 0;
1158
1163 virtual bool hasChildGeometries() const;
1164
1169 virtual int childCount() const { return 0; }
1170
1175 virtual QgsAbstractGeometry *childGeometry( int index ) const { Q_UNUSED( index ) return nullptr; }
1176
1181 virtual QgsPoint childPoint( int index ) const;
1182
1183 protected:
1185
1189 void setZMTypeFromSubGeometry( const QgsAbstractGeometry *subggeom, Qgis::WkbType baseGeomType );
1190
1195 virtual QgsRectangle calculateBoundingBox() const;
1196
1203 virtual QgsBox3D calculateBoundingBox3D() const;
1204
1208 virtual void clearCache() const;
1209
1210 friend class TestQgsGeometry;
1211};
1212
1213
1214#ifndef SIP_RUN
1215
1216template <class T>
1218{
1219 return std::remove_pointer<T>::type::cast( geom );
1220}
1221
1222template <class T>
1224{
1225 return std::remove_pointer<T>::type::cast( geom );
1226}
1227
1228#endif
1229
1230// clazy:excludeall=qstring-allocations
1231
1236class CORE_EXPORT QgsVertexIterator
1237{
1238 public:
1239
1241
1244 : g( geometry )
1245 , i( g->vertices_begin() )
1246 , n( g->vertices_end() )
1247 {
1248 }
1249
1251 bool hasNext() const
1252 {
1253 return g && g->vertices_end() != i;
1254 }
1255
1257 QgsPoint next();
1258
1259#ifdef SIP_RUN
1260// clang-format off
1261 QgsVertexIterator *__iter__();
1262 % MethodCode
1263 sipRes = sipCpp;
1264 % End
1265
1266 SIP_PYOBJECT __next__() SIP_TYPEHINT( QgsPoint );
1267 % MethodCode
1268 if ( sipCpp->hasNext() )
1269 sipRes = sipConvertFromType( new QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1270 else
1271 PyErr_SetString( PyExc_StopIteration, "" );
1272 % End
1273// clang-format on
1274#endif
1275
1276 private:
1277 const QgsAbstractGeometry *g = nullptr;
1279
1280};
1281
1288{
1289 public:
1290
1292
1295 : g( geometry )
1296 , i( g->parts_begin() )
1297 , n( g->parts_end() )
1298 {
1299 }
1300
1303 {
1304 return g && g->parts_end() != i;
1305 }
1306
1308 QgsAbstractGeometry *next();
1309
1310#ifdef SIP_RUN
1311// clang-format off
1312 QgsGeometryPartIterator *__iter__();
1313 % MethodCode
1314 sipRes = sipCpp;
1315 % End
1316
1317 SIP_PYOBJECT __next__() SIP_TYPEHINT( QgsAbstractGeometry );
1318 % MethodCode
1319 if ( sipCpp->hasNext() )
1320 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1321 else
1322 PyErr_SetString( PyExc_StopIteration, "" );
1323 % End
1324// clang-format on
1325#endif
1326
1327 private:
1328 QgsAbstractGeometry *g = nullptr;
1330
1331};
1332
1333
1340{
1341 public:
1342
1344
1347 : g( geometry )
1348 , i( g->const_parts_begin() )
1349 , n( g->const_parts_end() )
1350 {
1351 }
1352
1355 {
1356 return g && g->const_parts_end() != i;
1357 }
1358
1360 const QgsAbstractGeometry *next();
1361
1362#ifdef SIP_RUN
1363// clang-format off
1364 QgsGeometryConstPartIterator *__iter__();
1365 % MethodCode
1366 sipRes = sipCpp;
1367 % End
1368
1369 SIP_PYOBJECT __next__() SIP_TYPEHINT( QgsAbstractGeometry );
1370 % MethodCode
1371 if ( sipCpp->hasNext() )
1372 sipRes = sipConvertFromType( const_cast< QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1373 else
1374 PyErr_SetString( PyExc_StopIteration, "" );
1375 % End
1376// clang-format on
1377#endif
1378
1379 private:
1380 const QgsAbstractGeometry *g = nullptr;
1382
1383};
1384
1386
1387#endif //QGSABSTRACTGEOMETRYV2
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
@ Unknown
Unknown.
Definition qgis.h:295
An abstract base class for classes which transform geometries by transforming input points to output ...
The part_iterator class provides an STL-style iterator for const references to geometry parts.
const_part_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next part and returns an iterator to the n...
bool operator!=(const_part_iterator other) const
const_part_iterator()=default
Create invalid iterator.
int partNumber() const
Returns the part number of the current item.
The part_iterator class provides an STL-style iterator for geometry parts.
part_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next part and returns an iterator to the n...
part_iterator()=default
Create invalid iterator.
bool operator!=(part_iterator other) const
int partNumber() const
Returns the part number of the current item.
The vertex_iterator class provides an STL-style iterator for vertices.
vertex_iterator()=default
Create invalid iterator.
bool operator!=(const vertex_iterator &other) const
vertex_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next vertex and returns an iterator to the...
QgsVertexId vertexId() const
Returns vertex ID of the current item.
Abstract base class for all geometries.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
virtual QgsAbstractGeometry * snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0, bool removeRedundantPoints=false) const =0
Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
@ MaximumDifference
Maximum distance between an arbitrary point on the original curve and closest point on its approximat...
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices).
virtual int vertexNumberFromVertexId(QgsVertexId id) const =0
Returns the vertex number corresponding to a vertex id.
virtual bool convertTo(Qgis::WkbType type)
Converts the geometry to a specified type.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
virtual QgsBox3D calculateBoundingBox3D() const
Calculates the minimal 3D bounding box for the geometry.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
bool isMeasure() const
Returns true if the geometry contains m values.
QFlags< WkbFlag > WkbFlags
virtual QgsAbstractGeometry * simplifyByDistance(double tolerance) const =0
Simplifies the geometry by applying the Douglas Peucker simplification by distance algorithm.
virtual QgsRectangle calculateBoundingBox() const
Default calculator for the minimal bounding box for the geometry.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
virtual void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
virtual bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const =0
Checks validity of the geometry, and returns true if the geometry is valid.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
AxisOrder
Axis order for GML generation.
@ XY
X comes before Y (or lon before lat).
@ YX
Y comes before X (or lat before lon).
virtual QgsBox3D boundingBox3D() const =0
Returns the 3D bounding box for the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
int sortIndex() const
Returns the sort index for the geometry, used in the compareTo() method to compare geometries of diff...
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual double perimeter() const
Returns the planar, 2-dimensional perimeter of the geometry.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
virtual QByteArray asWkb(WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns a WKB representation of the geometry.
virtual double area3D() const
Returns the 3-dimensional surface area of the geometry.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
virtual QgsAbstractGeometry * toCurveType() const =0
Returns the geometry converted to the more generic curve type.
virtual void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const =0
Returns the vertices adjacent to a specified vertex within a geometry.
virtual QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML2 representation of the geometry.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool insertVertex(QgsVertexId position, const QgsPoint &vertex)=0
Inserts a vertex into the geometry.
virtual void swapXy()=0
Swaps the x and y coordinates from the geometry.
QString asJson(int precision=17)
Returns a GeoJSON representation of the geometry as a QString.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, Qgis::WkbType baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
virtual bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy comparison between this geometry and other using an epsilon.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy distance comparison between this geometry and other using an epsilon.
virtual json asJsonObject(int precision=17) const
Returns a json object representation of the geometry.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual bool hasChildGeometries() const
Returns whether the geometry has any child geometries (false for point / curve, true otherwise).
virtual QPainterPath asQPainterPath() const =0
Returns the geometry represented as a QPainterPath.
virtual void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
virtual bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
virtual void normalize()=0
Reorganizes the geometry into a normalized form (or "canonical" form).
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
virtual void clear()=0
Clears the geometry, ie reset it to a null geometry.
virtual void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
@ FlagExportTrianglesAsPolygons
Triangles should be exported as polygon geometries.
@ FlagExportNanAsDoubleMin
Use -DOUBLE_MAX to represent NaN.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
virtual QgsAbstractGeometry * childGeometry(int index) const
Returns pointer to child geometry (for geometries with child geometries - i.e.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
virtual int compareTo(const QgsAbstractGeometry *other) const
Comparator for sorting of geometry.
virtual QString asKml(int precision=17) const =0
Returns a KML representation of the geometry.
virtual bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)=0
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
virtual int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const =0
Returns the length of the QByteArray returned by asWkb().
const_part_iterator const_parts_begin() const
Returns STL-style iterator pointing to the const first part of the geometry.
QgsAbstractGeometry()=default
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const =0
Searches for the closest segment of the geometry to a given point.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
A const WKB pointer.
Definition qgswkbptr.h:211
Handles coordinate transforms between two coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Java-style iterator for const traversal of parts of a geometry.
QgsGeometryConstPartIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
bool hasNext() const
Find out whether there are more parts.
Java-style iterator for traversal of parts of a geometry.
QgsGeometryPartIterator()=default
bool hasNext() const
Find out whether there are more parts.
QgsGeometryPartIterator(QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
Perform transforms between map coordinates and device coordinates.
Multi curve geometry collection.
Multi point geometry collection.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
A rectangle specified with double values.
Java-style iterator for traversal of vertices of a geometry.
bool hasNext() const
Find out whether there are more vertices.
QgsVertexIterator()=default
QgsVertexIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Q_INVOKABLE bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:239
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:274
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_THROW(name,...)
Definition qgis_sip.h:210
#define SIP_END
Definition qgis_sip.h:215
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Definition qgsmargins.h:245
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34