QGIS API Documentation 3.99.0-Master (a26b91b364d)
qgsgeometry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometry.h - Geometry (stored as Open Geospatial Consortium WKB)
3 -------------------------------------------------------------------
4Date : 02 May 2005
5Copyright : (C) 2005 by Brendan Morley
6email : morb at ozemail dot com dot au
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 QGSGEOMETRY_H
17#define QGSGEOMETRY_H
18
19#include <functional>
20
21#include <QDomDocument>
22#include <QJsonObject>
23#include <QSet>
24#include <QString>
25#include <QVector>
26
27#include <climits>
28#include <limits>
29#include <memory>
30
31#include "qgis_core.h"
32#include "qgis_sip.h"
33
34#include "qgsabstractgeometry.h"
35#include "qgspointxy.h"
36#include "qgspoint.h"
37#include "qgsfeatureid.h"
38#include "qgsvertexid.h"
39
40#ifndef SIP_RUN
41#include <nlohmann/json_fwd.hpp>
42using namespace nlohmann;
43#endif
44
46class QgsVectorLayer;
47class QgsMapToPixel;
48class QPainter;
49class QgsPolygon;
50class QgsLineString;
51class QgsCurve;
52class QgsFeedback;
53
62typedef QVector<QgsPointXY> QgsPolylineXY;
63
70#ifndef SIP_RUN
72#else
73typedef QVector<QgsPoint> QgsPolyline;
74#endif
75
83#ifndef SIP_RUN
84typedef QVector<QgsPolyline> QgsMultiPolyline;
85#else
86typedef QVector<QVector< QgsPoint >> QgsMultiPolyline;
87#endif
88
90#ifndef SIP_RUN
91typedef QVector<QgsPolylineXY> QgsPolygonXY;
92#else
93typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
94#endif
95
97typedef QVector<QgsPointXY> QgsMultiPointXY;
98
100#ifndef SIP_RUN
101typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
102#else
103typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
104#endif
105
107#ifndef SIP_RUN
108typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
109#else
110typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
111#endif
112
113class QgsRectangle;
114
115class QgsConstWkbPtr;
116
117struct QgsGeometryPrivate;
118
125class CORE_EXPORT QgsGeometryParameters
126{
127 public:
128
139 double gridSize() const { return mGridSize; }
140
151 void setGridSize( double size ) { mGridSize = size; }
152
153 private:
154
155 double mGridSize = -1;
156};
157
178class CORE_EXPORT QgsGeometry
179{
180 Q_GADGET
181 Q_PROPERTY( bool isNull READ isNull )
182 Q_PROPERTY( Qgis::GeometryType type READ type )
183
184 public:
185
187
189 QgsGeometry( const QgsGeometry & );
190
195 QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
196
202
208 explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
209
210 virtual ~QgsGeometry();
211
222 const QgsAbstractGeometry *constGet() const SIP_HOLDGIL;
223
235 QgsAbstractGeometry *get();
236
248 void set( QgsAbstractGeometry *geometry SIP_TRANSFER ) SIP_DEPRECATED;
249
257 bool isNull() const SIP_HOLDGIL;
258
260 Q_INVOKABLE static QgsGeometry fromWkt( const QString &wkt );
262 static QgsGeometry fromPointXY( const QgsPointXY &point ) SIP_HOLDGIL;
263
269 static QgsGeometry fromPoint( const QgsPoint &point ) SIP_HOLDGIL;
270
272 static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
273
284 static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
285
294 static QgsGeometry fromPolyline( const QgsPolyline &polyline );
295
299 static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
300
301#ifndef SIP_RUN
302
306#else
307
325#endif
326 static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
327
331 static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
332
334 static QgsGeometry fromRect( const QgsRectangle &rect ) SIP_HOLDGIL;
335
343 static QgsGeometry fromBox3D( const QgsBox3D &box ) SIP_HOLDGIL;
344
345
347 static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
348
364 static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
365 double outerRadius, double innerRadius = 0 );
366
380 static QgsGeometry createWedgeBufferFromAngles( const QgsPoint &center, double startAngle, double endAngle,
381 double outerRadius, double innerRadius = 0 );
382
388 void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
389
393 void fromWkb( const QByteArray &wkb );
394
399 Qgis::WkbType wkbType() const SIP_HOLDGIL;
400
405 Qgis::GeometryType type() const SIP_HOLDGIL;
406
413 bool isEmpty() const SIP_HOLDGIL;
414
416 bool isMultipart() const SIP_HOLDGIL;
417
431 bool equals( const QgsGeometry &geometry ) const;
432
448 bool isGeosEqual( const QgsGeometry & ) const;
449
456 bool isGeosValid( Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
457
465 bool isSimple() const;
466
480 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
481
493 double area() const;
494
508 double length() const;
509
517 double distance( const QgsGeometry &geom ) const;
518
519#ifndef SIP_RUN
520
521 // TODO QGIS 4: consider renaming vertices_begin, vertices_end, parts_begin, parts_end, etc
522 // to camelCase
523
527 QgsAbstractGeometry::vertex_iterator vertices_begin() const;
528
532 QgsAbstractGeometry::vertex_iterator vertices_end() const;
533#endif
534
557 QgsVertexIterator vertices() const;
558
559#ifndef SIP_RUN
560
570
580
589 QgsAbstractGeometry::const_part_iterator const_parts_begin() const;
590
599 QgsAbstractGeometry::const_part_iterator const_parts_end() const;
600#endif
601
640
673 QgsGeometryConstPartIterator constParts() const;
674
691 double hausdorffDistance( const QgsGeometry &geom ) const;
692
710 double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
711
726 double frechetDistance( const QgsGeometry &geom ) const SIP_THROW( QgsNotSupportedException );
727
750 double frechetDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const SIP_THROW( QgsNotSupportedException );
751
764 QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;
765
773 double distanceToVertex( int vertex ) const;
774
781 double angleAtVertex( int vertex ) const;
782
795 void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
796
809 bool insertVertex( double x, double y, int beforeVertex );
810
823 bool insertVertex( const QgsPoint &point, int beforeVertex );
824
832 bool addTopologicalPoint( const QgsPoint &point, double snappingTolerance = 1e-8, double segmentSearchEpsilon = 1e-12 );
833
841 bool moveVertex( double x, double y, int atVertex );
842
850 bool moveVertex( const QgsPoint &p, int atVertex );
851
863 bool deleteVertex( int atVertex );
864
872 bool toggleCircularAtVertex( int atVertex );
873
879 QgsPoint vertexAt( int atVertex ) const;
880
886 double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
887
892 QgsGeometry nearestPoint( const QgsGeometry &other ) const;
893
903 QgsGeometry shortestLine( const QgsGeometry &other ) const;
904
911 double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
912
924 double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = Qgis::DEFAULT_SEGMENT_EPSILON ) const;
925
931 Qgis::GeometryOperationResult addRing( const QVector<QgsPointXY> &ring );
932
939
947 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY ) SIP_DEPRECATED;
948
956 Qgis::GeometryOperationResult addPartV2( const QVector<QgsPointXY> &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsXYV2 );
957
965 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QgsPointSequence &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPoints ) SIP_DEPRECATED;
966
974 Qgis::GeometryOperationResult addPartV2( const QgsPointSequence &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsV2 );
975
984
993
999 Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
1000
1006 QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
1007
1012 Qgis::GeometryOperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
1013
1029
1038 Qgis::GeometryOperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
1039
1046 Qgis::GeometryOperationResult rotate( double rotation, const QgsPointXY &center );
1047
1058 Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints, bool splitFeature = true ) SIP_SKIP;
1059
1081 Qgis::GeometryOperationResult splitGeometry( const QgsPointSequence &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true, bool skipIntersectionTest SIP_PYARGREMOVE = false ) SIP_SKIP;
1082
1083
1084 /*
1085 This SIP code is to support overloaded methods of splitGeometry.
1086 When the deprecated method is removed in QGIS 4.0 this code can be dropped
1087 TODO QGIS 4 remove MethodCode
1088 */
1089#ifdef SIP_RUN
1090
1109 SIP_PYOBJECT splitGeometry( SIP_PYOBJECT splitLine SIP_TYPEHINT( List[Union[QgsPoint, QgsPointXY]] ), bool topological, bool splitFeature = true ) SIP_TYPEHINT( Tuple[Qgis.GeometryOperationResult, Union[List[QgsPoint], List[QgsPointXY]], Union[List[QgsPoint], List[QgsPointXY]]] );
1110 % MethodCode
1111 {
1112 int sipIsErr = 0;
1113 int state;
1114
1115 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1116 {
1117 PyObject *p0 = PyList_GetItem( a0, 0 );
1118 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1119 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1120 {
1121 QVector<QgsGeometry> newGeometries;
1122 QVector<QgsPointXY> topologyTestPoints;
1123
1124 QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1125 if ( !sipIsErr )
1126 {
1127 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1128
1129 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1130 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1131 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1132
1133 sipRes = PyTuple_New( 3 );
1134 PyTuple_SET_ITEM( sipRes, 0, o0 );
1135 PyTuple_SET_ITEM( sipRes, 1, o1 );
1136 PyTuple_SET_ITEM( sipRes, 2, o2 );
1137 }
1138 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1139 }
1140
1141 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1142 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1143 {
1144 QVector<QgsGeometry> newGeometries;
1145 QVector<QgsPoint> topologyTestPoints;
1146
1147 QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1148 if ( !sipIsErr )
1149 {
1150 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1151
1152 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1153 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1154 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1155
1156 sipRes = PyTuple_New( 3 );
1157 PyTuple_SET_ITEM( sipRes, 0, o0 );
1158 PyTuple_SET_ITEM( sipRes, 1, o1 );
1159 PyTuple_SET_ITEM( sipRes, 2, o2 );
1160 }
1161 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1162 }
1163 else
1164 {
1165 sipIsErr = 1;
1166 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1167 }
1168 }
1169 else
1170 {
1171 sipIsErr = 1;
1172 PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1173 }
1174 }
1175 % End
1176#endif
1177
1189 Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1190
1195 Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1196
1202 int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1203
1210 QgsGeometry makeDifference( const QgsGeometry &other ) const;
1211
1216 QgsRectangle boundingBox() const;
1217
1223 QgsBox3D boundingBox3D() const;
1224
1237 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1238
1248 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1249
1257 QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1258
1263 QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1264
1272 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
1273
1286 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1287
1306 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1307
1320 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1321
1340 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1341
1354 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1355
1374 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1375
1389 QgsGeometry applyDashPattern( const QVector< double > &pattern,
1390 Qgis::DashPatternLineEndingRule startRule = Qgis::DashPatternLineEndingRule::NoRule,
1391 Qgis::DashPatternLineEndingRule endRule = Qgis::DashPatternLineEndingRule::NoRule,
1392 Qgis::DashPatternSizeAdjustment adjustment = Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1393 double patternOffset = 0 ) const;
1394
1406 QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1407
1427 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1428
1438 bool intersects( const QgsRectangle &rectangle ) const;
1439
1454 bool intersects( const QgsGeometry &geometry ) const;
1455
1464 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1465
1474 bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1475
1479 bool contains( const QgsPointXY *p ) const;
1480
1486 bool contains( double x, double y ) const;
1487
1497 bool contains( const QgsGeometry &geometry ) const;
1498
1508 bool disjoint( const QgsGeometry &geometry ) const;
1509
1519 bool touches( const QgsGeometry &geometry ) const;
1520
1530 bool overlaps( const QgsGeometry &geometry ) const;
1531
1541 bool within( const QgsGeometry &geometry ) const;
1542
1552 bool crosses( const QgsGeometry &geometry ) const;
1553
1561 QgsGeometry buffer( double distance, int segments ) const;
1562
1574 QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1575
1583 QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1584
1599 QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1600 Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1601 double miterLimit = 2.0 ) const;
1602
1620 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1621
1636 QgsGeometry variableWidthBufferByM( int segments ) const;
1637
1643 QgsGeometry extendLine( double startDistance, double endDistance ) const;
1644
1646 QgsGeometry simplify( double tolerance ) const;
1647
1656 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1657
1671 QgsGeometry densifyByDistance( double distance ) const;
1672
1688 QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1689
1703 QgsGeometry centroid() const;
1704
1718 QgsGeometry pointOnSurface() const;
1719
1731 QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1732
1756 QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1757
1772 QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1773
1795 double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1796
1808 QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1809
1818 QgsGeometry convexHull() const;
1819
1833 QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1834
1849 QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1850
1861 QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1862
1875 QgsGeometry constrainedDelaunayTriangulation() const SIP_THROW( QgsNotSupportedException );
1876
1894 Qgis::CoverageValidityResult validateCoverage( double gapWidth, QgsGeometry *invalidEdges SIP_OUT = nullptr ) const SIP_THROW( QgsNotSupportedException );
1895
1916 QgsGeometry simplifyCoverageVW( double tolerance, bool preserveBoundary ) const SIP_THROW( QgsNotSupportedException );
1917
1929 QgsGeometry unionCoverage() const;
1930
1941 QgsGeometry node() const;
1942
1957 QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1958
1980 QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1981
1996 QgsGeometry interpolate( double distance ) const;
1997
2008 double lineLocatePoint( const QgsGeometry &point ) const;
2009
2018 double interpolateAngle( double distance ) const;
2019
2031 QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2032
2039 QgsGeometry clipped( const QgsRectangle &rectangle );
2040
2055 QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2056
2067 QgsGeometry mergeLines( const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2068
2080 QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2081
2093 QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2094
2096 QgsGeometry extrude( double x, double y );
2097
2098#ifndef SIP_RUN
2099
2121 QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2122
2136 QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2138#else
2139
2153 SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2154 % MethodCode
2155 const Qgis::GeometryType type = sipCpp->type();
2156 if ( sipCpp->isNull() )
2157 {
2158 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2159 sipIsErr = 1;
2160 }
2161 else if ( type != Qgis::GeometryType::Polygon )
2162 {
2163 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2164 sipIsErr = 1;
2165 }
2166 else
2167 {
2168 const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2169 sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2170 }
2171 % End
2172
2173
2174#endif
2176
2184 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2185
2192 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2193
2199 Q_INVOKABLE QString asWkt( int precision = 17 ) const;
2200
2201#ifdef SIP_RUN
2202 SIP_PYOBJECT __repr__();
2203 % MethodCode
2204 QString str;
2205 if ( sipCpp->isNull() )
2206 str = QStringLiteral( "<QgsGeometry: null>" );
2207 else
2208 {
2209 QString wkt = sipCpp->asWkt();
2210 if ( wkt.length() > 1000 )
2211 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2212 str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2213 }
2214 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2215 % End
2216#endif
2217
2221 QString asJson( int precision = 17 ) const;
2222
2228 virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2229
2260 QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0, bool avoidDuplicates = true ) const;
2261
2273 QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2274
2275 /* Accessor functions for getting geometry data */
2276
2277#ifndef SIP_RUN
2278
2287 QgsPointXY asPoint() const;
2288#else
2289
2300 SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2301 % MethodCode
2302 if ( sipCpp->isNull() )
2303 {
2304 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2305 sipIsErr = 1;
2306 }
2307 else
2308 {
2309 const QgsAbstractGeometry *geom = sipCpp->constGet();
2311 {
2312 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a point. Only Point types are permitted." ).arg( QgsWkbTypes::displayString( geom->wkbType() ) ).toUtf8().constData() );
2313 sipIsErr = 1;
2314 }
2315 else
2316 {
2317 sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2318 }
2319 }
2320 % End
2321#endif
2322
2323#ifndef SIP_RUN
2324
2333 QgsPolylineXY asPolyline() const;
2334#else
2335
2347 SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2348 % MethodCode
2349 const Qgis::WkbType type = sipCpp->wkbType();
2350 if ( sipCpp->isNull() )
2351 {
2352 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2353 sipIsErr = 1;
2354 }
2356 {
2357 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a polyline. Only single line or curve types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2358 sipIsErr = 1;
2359 }
2360 else
2361 {
2362 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2363 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2364 }
2365 % End
2366#endif
2367
2368#ifndef SIP_RUN
2369
2378 QgsPolygonXY asPolygon() const;
2379#else
2380
2392 SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
2393 % MethodCode
2394 const Qgis::WkbType type = sipCpp->wkbType();
2395 if ( sipCpp->isNull() )
2396 {
2397 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2398 sipIsErr = 1;
2399 }
2401 {
2402 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a polygon. Only single polygon or curve polygon types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2403 sipIsErr = 1;
2404 }
2405 else
2406 {
2407 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2408 sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2409 }
2410 % End
2411#endif
2412
2413#ifndef SIP_RUN
2414
2422 QgsMultiPointXY asMultiPoint() const;
2423#else
2424
2435 SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2436 % MethodCode
2437 const Qgis::WkbType type = sipCpp->wkbType();
2438 if ( sipCpp->isNull() )
2439 {
2440 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2441 sipIsErr = 1;
2442 }
2444 {
2445 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2446 sipIsErr = 1;
2447 }
2448 else
2449 {
2450 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2451 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2452 }
2453 % End
2454#endif
2455
2456#ifndef SIP_RUN
2457
2466 QgsMultiPolylineXY asMultiPolyline() const;
2467#else
2468
2480 SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2481 % MethodCode
2482 const Qgis::WkbType type = sipCpp->wkbType();
2483 if ( sipCpp->isNull() )
2484 {
2485 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2486 sipIsErr = 1;
2487 }
2489 {
2490 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multilinestring. Only multi linestring or curves are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2491 sipIsErr = 1;
2492 }
2493 else
2494 {
2495 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2496 sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2497 }
2498 % End
2499#endif
2500
2501#ifndef SIP_RUN
2502
2511 QgsMultiPolygonXY asMultiPolygon() const;
2512#else
2513
2525 SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2526 % MethodCode
2527 const Qgis::WkbType type = sipCpp->wkbType();
2528 if ( sipCpp->isNull() )
2529 {
2530 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2531 sipIsErr = 1;
2532 }
2534 {
2535 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipolygon. Only multi polygon or curves are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2536 sipIsErr = 1;
2537 }
2538 else
2539 {
2540 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2541 sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2542 }
2543 % End
2544#endif
2545
2549 QVector<QgsGeometry> asGeometryCollection() const;
2550
2555 QPointF asQPointF() const SIP_HOLDGIL;
2556
2568 QPolygonF asQPolygonF() const SIP_HOLDGIL;
2569
2575 bool deleteRing( int ringNum, int partNum = 0 );
2576
2581 bool deletePart( int partNum );
2582
2591 bool convertToMultiType();
2592
2608 bool convertToCurvedMultiType();
2609
2619 bool convertToSingleType();
2620
2630 bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2631
2643 Q_DECL_DEPRECATED int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2644 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) ) SIP_DEPRECATED;
2645
2657 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2658 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2659
2680 QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2681
2691 Qgis::AngularDirection polygonOrientation() const;
2692
2706 bool isPolygonCounterClockwise() const { return polygonOrientation() == Qgis::AngularDirection::CounterClockwise; }
2707
2721 bool isPolygonClockwise() const { return polygonOrientation() == Qgis::AngularDirection::Clockwise; }
2722
2723
2738 QgsGeometry forceRHR() const;
2739
2750 QgsGeometry forcePolygonClockwise() const;
2751
2762 QgsGeometry forcePolygonCounterClockwise() const;
2763
2768 class CORE_EXPORT Error
2769 {
2770 public:
2772 : mMessage( QStringLiteral( "none" ) )
2773 {}
2774
2775 explicit Error( const QString &m )
2776 : mMessage( m )
2777 {}
2778
2779 Error( const QString &m, const QgsPointXY &p )
2780 : mMessage( m )
2781 , mLocation( p )
2782 , mHasLocation( true ) {}
2783
2787 QString what() const;
2788
2792 QgsPointXY where() const;
2793
2797 bool hasWhere() const;
2798
2799#ifdef SIP_RUN
2800 SIP_PYOBJECT __repr__();
2801 % MethodCode
2802 QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2803 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2804 % End
2805#endif
2806
2807 // TODO c++20 - replace with = default
2808 bool operator==( const QgsGeometry::Error &other ) const
2809 {
2810 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2811 }
2812
2813 private:
2814 QString mMessage;
2815 QgsPointXY mLocation;
2816 bool mHasLocation = false;
2817 };
2818
2826 void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2827
2837 void normalize();
2838
2847 static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2848
2856 static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2857
2864 void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2865
2871 bool requiresConversionToStraightSegments() const;
2872
2877 void mapToPixel( const QgsMapToPixel &mtp );
2878
2883 void draw( QPainter &p ) const;
2884
2894 bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2895
2906 int vertexNrFromVertexId( QgsVertexId id ) const;
2907
2914 QString lastError() const SIP_HOLDGIL;
2915
2925 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2926
2941 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2942
2947 static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2948
2955 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2956
2964 Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2965
2973 Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2974
2975#ifndef SIP_RUN
2976
2985 static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2986 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2987
2996 static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2997 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2998
3008 static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
3009 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3010#else
3011
3030 static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3031 % MethodCode
3032 {
3033 sipRes = false;
3034 int state0;
3035 int state1;
3036 int sipIsErr = 0;
3037
3038 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3039 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3040 {
3041 PyObject *o0 = PyList_GetItem( a0, 0 );
3042 PyObject *o1 = PyList_GetItem( a1, 0 );
3043 if ( o0 && o1 )
3044 {
3045 // compare polyline - polyline
3046 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3047 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3048 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3049 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3050 {
3051 QgsPolylineXY *p0;
3052 QgsPolylineXY *p1;
3053 p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3054 p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3055 if ( !sipIsErr )
3056 {
3057 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3058 }
3059 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3060 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3061 }
3062 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3063 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3064 {
3065 PyObject *oo0 = PyList_GetItem( o0, 0 );
3066 PyObject *oo1 = PyList_GetItem( o1, 0 );
3067 if ( oo0 && oo1 )
3068 {
3069 // compare polygon - polygon
3070 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3071 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3072 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3073 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3074 {
3075 QgsPolygonXY *p0;
3076 QgsPolygonXY *p1;
3077 p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3078 p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3079 if ( !sipIsErr )
3080 {
3081 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3082 }
3083 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3084 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3085 }
3086 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3087 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3088 {
3089 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3090 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3091 if ( ooo0 && ooo1 )
3092 {
3093 // compare multipolygon - multipolygon
3094 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3095 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3096 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3097 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3098 {
3101 p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3102 p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3103 if ( !sipIsErr )
3104 {
3105 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3106 }
3107 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3108 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3109 }
3110 }
3111 }
3112 }
3113 }
3114 }
3115 }
3116 }
3117 % End
3118#endif
3119
3135 QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
3136 double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
3137
3178
3184 static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3185
3191 static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3192
3194 operator QVariant() const
3195 {
3196 return QVariant::fromValue( *this );
3197 }
3198
3199 private:
3200
3201 QgsGeometryPrivate *d; //implicitly shared data pointer
3202
3204 mutable QString mLastError;
3205
3210 void detach();
3211
3216 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3217
3218 static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3219
3221 QgsGeometry convertToPoint( bool destMultipart ) const;
3223 QgsGeometry convertToLine( bool destMultipart ) const;
3225 QgsGeometry convertToPolygon( bool destMultipart ) const;
3226
3238 std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3239 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3240
3252 std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3253 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3254
3255
3257
3258}; // class QgsGeometry
3259
3261
3262
3263CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3265CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3266
3267#endif
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:54
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
GeometryOperationResult
Success or failure of a geometry operation.
Definition qgis.h:2005
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
Definition qgis.h:2038
GeometryValidationEngine
Available engines for validating geometries.
Definition qgis.h:2047
@ QgisInternal
Use internal QgsGeometryValidator method.
@ SkipEmptyInteriorRings
Skip any empty polygon interior ring.
QFlags< GeosCreationFlag > GeosCreationFlags
Geos geometry creation behavior flags.
Definition qgis.h:2108
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ Polygon
Polygons.
@ Unknown
Unknown types.
static const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition qgis.h:6059
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ Unknown
Unknown.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
Definition qgis.h:2621
@ Forward
Forward transform (from source to destination)
The part_iterator class provides an STL-style iterator for const references to geometry parts.
The part_iterator class provides an STL-style iterator for geometry parts.
The vertex_iterator class provides an STL-style iterator for vertices.
Abstract base class for all geometries.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices)
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
QFlags< WkbFlag > WkbFlags
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:43
A const WKB pointer.
Definition qgswkbptr.h:138
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:35
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.
A geometry engine is a low-level representation of a QgsAbstractGeometry object, optimised for use wi...
Encapsulates parameters under which a geometry operation is performed.
double gridSize() const
Returns the grid size which will be used to snap vertices of a geometry.
void setGridSize(double size)
Sets the grid size which will be used to snap vertices of a geometry.
Java-style iterator for traversal of parts of a geometry.
A geometry error.
Error(const QString &m)
Error(const QString &m, const QgsPointXY &p)
bool operator==(const QgsGeometry::Error &other) const
A geometry is the spatial representation of a feature.
QVector< QgsPointXY > randomPointsInPolygon(int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr, int maxTriesPerPoint=0) const
Returns a list of count random points generated inside a (multi)polygon geometry (if acceptPoint is s...
QVector< QgsPointXY > randomPointsInPolygon(int count, unsigned long seed=0, QgsFeedback *feedback=nullptr) const
Returns a list of count random points generated inside a (multi)polygon geometry.
static bool compare(const QgsPolylineXY &p1, const QgsPolylineXY &p2, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compares two polylines for equality within a specified tolerance.
bool isPolygonClockwise() const
Returns True if the Polygon is clockwise.
Offers geometry processing methods.
Line string geometry type, with support for z-dimension and m-values.
Perform transforms between map coordinates and device coordinates.
Custom exception class which is raised when an operation is not supported.
Represents a 2D point.
Definition qgspointxy.h:60
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Polygon geometry type.
Definition qgspolygon.h:33
A rectangle specified with double values.
Represents a vector layer which manages a vector based dataset.
Java-style iterator for traversal of vertices of a geometry.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:232
#define SIP_IN
Definition qgis_sip.h:63
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_PYNAME(name)
Definition qgis_sip.h:81
#define SIP_PYARGREMOVE
Definition qgis_sip.h:151
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_HOLDGIL
Definition qgis_sip.h:171
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_THROW(name,...)
Definition qgis_sip.h:203
QVector< QgsPoint > QgsPointSequence
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition qgsgeometry.h:91
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition qgsgeometry.h:97
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition qgsgeometry.h:62
QVector< QgsPolyline > QgsMultiPolyline
Multi polyline represented as a vector of polylines.
Definition qgsgeometry.h:84
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
QgsPointSequence QgsPolyline
Polyline as represented as a vector of points.
Definition qgsgeometry.h:71
int precision
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:30