QGIS API Documentation 3.99.0-Master (e69e8341d6a)
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
71
73#ifndef SIP_RUN
74typedef QVector<QgsPolylineXY> QgsPolygonXY;
75#else
76typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
77#endif
78
80typedef QVector<QgsPointXY> QgsMultiPointXY;
81
83#ifndef SIP_RUN
84typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
85#else
86typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
87#endif
88
90#ifndef SIP_RUN
91typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
92#else
93typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
94#endif
95
96class QgsRectangle;
97
98class QgsConstWkbPtr;
99
100struct QgsGeometryPrivate;
101
108class CORE_EXPORT QgsGeometryParameters
109{
110 public:
111
122 double gridSize() const { return mGridSize; }
123
134 void setGridSize( double size ) { mGridSize = size; }
135
136 private:
137
138 double mGridSize = -1;
139};
140
161class CORE_EXPORT QgsGeometry
162{
163 Q_GADGET
164 Q_PROPERTY( bool isNull READ isNull )
165 Q_PROPERTY( Qgis::GeometryType type READ type )
166
167 public:
168
170
172 QgsGeometry( const QgsGeometry & );
173
178 QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
179
185
191 explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
192
193 virtual ~QgsGeometry();
194
205 const QgsAbstractGeometry *constGet() const SIP_HOLDGIL;
206
218 QgsAbstractGeometry *get();
219
231 void set( QgsAbstractGeometry *geometry SIP_TRANSFER ) SIP_DEPRECATED;
232
240 bool isNull() const SIP_HOLDGIL;
241
243 Q_INVOKABLE static QgsGeometry fromWkt( const QString &wkt );
245 static QgsGeometry fromPointXY( const QgsPointXY &point ) SIP_HOLDGIL;
246
252 static QgsGeometry fromPoint( const QgsPoint &point ) SIP_HOLDGIL;
253
255 static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
256
267 static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
268
277 static QgsGeometry fromPolyline( const QgsPolyline &polyline );
278
282 static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
283
284#ifndef SIP_RUN
285
289#else
290
308#endif
309 static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
310
314 static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
315
317 static QgsGeometry fromRect( const QgsRectangle &rect ) SIP_HOLDGIL;
318
326 static QgsGeometry fromBox3D( const QgsBox3D &box ) SIP_HOLDGIL;
327
328
330 static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
331
347 static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
348 double outerRadius, double innerRadius = 0 );
349
363 static QgsGeometry createWedgeBufferFromAngles( const QgsPoint &center, double startAngle, double endAngle,
364 double outerRadius, double innerRadius = 0 );
365
371 void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
372
376 void fromWkb( const QByteArray &wkb );
377
382 Qgis::WkbType wkbType() const SIP_HOLDGIL;
383
388 Qgis::GeometryType type() const SIP_HOLDGIL;
389
396 bool isEmpty() const SIP_HOLDGIL;
397
399 bool isMultipart() const SIP_HOLDGIL;
400
414 bool equals( const QgsGeometry &geometry ) const;
415
431 bool isGeosEqual( const QgsGeometry & ) const;
432
439 bool isGeosValid( Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
440
448 bool isSimple() const;
449
463 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
464
476 double area() const;
477
491 double length() const;
492
500 double distance( const QgsGeometry &geom ) const;
501
502#ifndef SIP_RUN
503
504 // TODO QGIS 4: consider renaming vertices_begin, vertices_end, parts_begin, parts_end, etc
505 // to camelCase
506
510 QgsAbstractGeometry::vertex_iterator vertices_begin() const;
511
515 QgsAbstractGeometry::vertex_iterator vertices_end() const;
516#endif
517
540 QgsVertexIterator vertices() const;
541
542#ifndef SIP_RUN
543
553
563
572 QgsAbstractGeometry::const_part_iterator const_parts_begin() const;
573
582 QgsAbstractGeometry::const_part_iterator const_parts_end() const;
583#endif
584
623
656 QgsGeometryConstPartIterator constParts() const;
657
674 double hausdorffDistance( const QgsGeometry &geom ) const;
675
693 double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
694
709 double frechetDistance( const QgsGeometry &geom ) const SIP_THROW( QgsNotSupportedException );
710
733 double frechetDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const SIP_THROW( QgsNotSupportedException );
734
747 QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;
748
756 double distanceToVertex( int vertex ) const;
757
764 double angleAtVertex( int vertex ) const;
765
778 void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
779
792 bool insertVertex( double x, double y, int beforeVertex );
793
806 bool insertVertex( const QgsPoint &point, int beforeVertex );
807
815 bool addTopologicalPoint( const QgsPoint &point, double snappingTolerance = 1e-8, double segmentSearchEpsilon = 1e-12 );
816
824 bool moveVertex( double x, double y, int atVertex );
825
833 bool moveVertex( const QgsPoint &p, int atVertex );
834
846 bool deleteVertex( int atVertex );
847
855 bool toggleCircularAtVertex( int atVertex );
856
862 QgsPoint vertexAt( int atVertex ) const;
863
869 double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
870
875 QgsGeometry nearestPoint( const QgsGeometry &other ) const;
876
886 QgsGeometry shortestLine( const QgsGeometry &other ) const;
887
894 double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
895
907 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;
908
914 Qgis::GeometryOperationResult addRing( const QVector<QgsPointXY> &ring );
915
922
930 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY ) SIP_DEPRECATED;
931
939 Qgis::GeometryOperationResult addPartV2( const QVector<QgsPointXY> &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsXYV2 );
940
948 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QgsPointSequence &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPoints ) SIP_DEPRECATED;
949
957 Qgis::GeometryOperationResult addPartV2( const QgsPointSequence &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsV2 );
958
967
976
982 Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
983
989 QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
990
995 Qgis::GeometryOperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
996
1012
1021 Qgis::GeometryOperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
1022
1029 Qgis::GeometryOperationResult rotate( double rotation, const QgsPointXY &center );
1030
1041 Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints, bool splitFeature = true ) SIP_SKIP;
1042
1064 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;
1065
1066
1067 /*
1068 This SIP code is to support overloaded methods of splitGeometry.
1069 When the deprecated method is removed in QGIS 4.0 this code can be dropped
1070 TODO QGIS 4 remove MethodCode
1071 */
1072#ifdef SIP_RUN
1073
1092 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]]] );
1093 % MethodCode
1094 {
1095 int sipIsErr = 0;
1096 int state;
1097
1098 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1099 {
1100 PyObject *p0 = PyList_GetItem( a0, 0 );
1101 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1102 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1103 {
1104 QVector<QgsGeometry> newGeometries;
1105 QVector<QgsPointXY> topologyTestPoints;
1106
1107 QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1108 if ( !sipIsErr )
1109 {
1110 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1111
1112 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1113 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1114 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1115
1116 sipRes = PyTuple_New( 3 );
1117 PyTuple_SET_ITEM( sipRes, 0, o0 );
1118 PyTuple_SET_ITEM( sipRes, 1, o1 );
1119 PyTuple_SET_ITEM( sipRes, 2, o2 );
1120 }
1121 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1122 }
1123
1124 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1125 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1126 {
1127 QVector<QgsGeometry> newGeometries;
1128 QVector<QgsPoint> topologyTestPoints;
1129
1130 QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1131 if ( !sipIsErr )
1132 {
1133 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1134
1135 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1136 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1137 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1138
1139 sipRes = PyTuple_New( 3 );
1140 PyTuple_SET_ITEM( sipRes, 0, o0 );
1141 PyTuple_SET_ITEM( sipRes, 1, o1 );
1142 PyTuple_SET_ITEM( sipRes, 2, o2 );
1143 }
1144 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1145 }
1146 else
1147 {
1148 sipIsErr = 1;
1149 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1150 }
1151 }
1152 else
1153 {
1154 sipIsErr = 1;
1155 PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1156 }
1157 }
1158 % End
1159#endif
1160
1172 Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1173
1178 Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1179
1185 int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1186
1193 QgsGeometry makeDifference( const QgsGeometry &other ) const;
1194
1199 QgsRectangle boundingBox() const;
1200
1206 QgsBox3D boundingBox3D() const;
1207
1220 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1221
1231 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1232
1240 QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1241
1246 QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1247
1255 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
1256
1269 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1270
1289 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1290
1303 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1304
1323 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1324
1337 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1338
1357 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1358
1372 QgsGeometry applyDashPattern( const QVector< double > &pattern,
1373 Qgis::DashPatternLineEndingRule startRule = Qgis::DashPatternLineEndingRule::NoRule,
1374 Qgis::DashPatternLineEndingRule endRule = Qgis::DashPatternLineEndingRule::NoRule,
1375 Qgis::DashPatternSizeAdjustment adjustment = Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1376 double patternOffset = 0 ) const;
1377
1389 QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1390
1410 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1411
1421 bool intersects( const QgsRectangle &rectangle ) const;
1422
1437 bool intersects( const QgsGeometry &geometry ) const;
1438
1447 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1448
1457 bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1458
1462 bool contains( const QgsPointXY *p ) const;
1463
1469 bool contains( double x, double y ) const;
1470
1480 bool contains( const QgsGeometry &geometry ) const;
1481
1491 bool disjoint( const QgsGeometry &geometry ) const;
1492
1502 bool touches( const QgsGeometry &geometry ) const;
1503
1513 bool overlaps( const QgsGeometry &geometry ) const;
1514
1524 bool within( const QgsGeometry &geometry ) const;
1525
1535 bool crosses( const QgsGeometry &geometry ) const;
1536
1544 QgsGeometry buffer( double distance, int segments ) const;
1545
1557 QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1558
1566 QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1567
1582 QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1583 Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1584 double miterLimit = 2.0 ) const;
1585
1603 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1604
1619 QgsGeometry variableWidthBufferByM( int segments ) const;
1620
1626 QgsGeometry extendLine( double startDistance, double endDistance ) const;
1627
1629 QgsGeometry simplify( double tolerance ) const;
1630
1639 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1640
1654 QgsGeometry densifyByDistance( double distance ) const;
1655
1671 QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1672
1686 QgsGeometry centroid() const;
1687
1701 QgsGeometry pointOnSurface() const;
1702
1714 QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1715
1739 QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1740
1755 QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1756
1778 double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1779
1791 QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1792
1801 QgsGeometry convexHull() const;
1802
1816 QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1817
1832 QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1833
1844 QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1845
1858 QgsGeometry constrainedDelaunayTriangulation() const SIP_THROW( QgsNotSupportedException );
1859
1877 Qgis::CoverageValidityResult validateCoverage( double gapWidth, QgsGeometry *invalidEdges SIP_OUT = nullptr ) const SIP_THROW( QgsNotSupportedException );
1878
1899 QgsGeometry simplifyCoverageVW( double tolerance, bool preserveBoundary ) const SIP_THROW( QgsNotSupportedException );
1900
1912 QgsGeometry unionCoverage() const;
1913
1924 QgsGeometry node() const;
1925
1940 QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1941
1963 QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1964
1979 QgsGeometry interpolate( double distance ) const;
1980
1991 double lineLocatePoint( const QgsGeometry &point ) const;
1992
2001 double interpolateAngle( double distance ) const;
2002
2014 QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2015
2022 QgsGeometry clipped( const QgsRectangle &rectangle );
2023
2038 QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2039
2050 QgsGeometry mergeLines( const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2051
2063 QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2064
2076 QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2077
2079 QgsGeometry extrude( double x, double y );
2080
2081#ifndef SIP_RUN
2082
2104 QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2105
2119 QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2121#else
2122
2136 SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2137 % MethodCode
2138 const Qgis::GeometryType type = sipCpp->type();
2139 if ( sipCpp->isNull() )
2140 {
2141 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2142 sipIsErr = 1;
2143 }
2144 else if ( type != Qgis::GeometryType::Polygon )
2145 {
2146 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2147 sipIsErr = 1;
2148 }
2149 else
2150 {
2151 const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2152 sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2153 }
2154 % End
2155
2156
2157#endif
2159
2167 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2168
2175 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2176
2182 Q_INVOKABLE QString asWkt( int precision = 17 ) const;
2183
2184#ifdef SIP_RUN
2185 SIP_PYOBJECT __repr__();
2186 % MethodCode
2187 QString str;
2188 if ( sipCpp->isNull() )
2189 str = QStringLiteral( "<QgsGeometry: null>" );
2190 else
2191 {
2192 QString wkt = sipCpp->asWkt();
2193 if ( wkt.length() > 1000 )
2194 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2195 str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2196 }
2197 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2198 % End
2199#endif
2200
2204 QString asJson( int precision = 17 ) const;
2205
2211 virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2212
2243 QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0, bool avoidDuplicates = true ) const;
2244
2256 QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2257
2258 /* Accessor functions for getting geometry data */
2259
2260#ifndef SIP_RUN
2261
2270 QgsPointXY asPoint() const;
2271#else
2272
2283 SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2284 % MethodCode
2285 if ( sipCpp->isNull() )
2286 {
2287 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2288 sipIsErr = 1;
2289 }
2290 else
2291 {
2292 const QgsAbstractGeometry *geom = sipCpp->constGet();
2294 {
2295 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() );
2296 sipIsErr = 1;
2297 }
2298 else
2299 {
2300 sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2301 }
2302 }
2303 % End
2304#endif
2305
2306#ifndef SIP_RUN
2307
2316 QgsPolylineXY asPolyline() const;
2317#else
2318
2330 SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2331 % MethodCode
2332 const Qgis::WkbType type = sipCpp->wkbType();
2333 if ( sipCpp->isNull() )
2334 {
2335 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2336 sipIsErr = 1;
2337 }
2339 {
2340 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() );
2341 sipIsErr = 1;
2342 }
2343 else
2344 {
2345 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2346 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2347 }
2348 % End
2349#endif
2350
2351#ifndef SIP_RUN
2352
2361 QgsPolygonXY asPolygon() const;
2362#else
2363
2375 SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
2376 % MethodCode
2377 const Qgis::WkbType type = sipCpp->wkbType();
2378 if ( sipCpp->isNull() )
2379 {
2380 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2381 sipIsErr = 1;
2382 }
2384 {
2385 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() );
2386 sipIsErr = 1;
2387 }
2388 else
2389 {
2390 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2391 sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2392 }
2393 % End
2394#endif
2395
2396#ifndef SIP_RUN
2397
2405 QgsMultiPointXY asMultiPoint() const;
2406#else
2407
2418 SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2419 % MethodCode
2420 const Qgis::WkbType type = sipCpp->wkbType();
2421 if ( sipCpp->isNull() )
2422 {
2423 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2424 sipIsErr = 1;
2425 }
2427 {
2428 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2429 sipIsErr = 1;
2430 }
2431 else
2432 {
2433 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2434 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2435 }
2436 % End
2437#endif
2438
2439#ifndef SIP_RUN
2440
2449 QgsMultiPolylineXY asMultiPolyline() const;
2450#else
2451
2463 SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2464 % MethodCode
2465 const Qgis::WkbType type = sipCpp->wkbType();
2466 if ( sipCpp->isNull() )
2467 {
2468 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2469 sipIsErr = 1;
2470 }
2472 {
2473 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() );
2474 sipIsErr = 1;
2475 }
2476 else
2477 {
2478 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2479 sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2480 }
2481 % End
2482#endif
2483
2484#ifndef SIP_RUN
2485
2494 QgsMultiPolygonXY asMultiPolygon() const;
2495#else
2496
2508 SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2509 % MethodCode
2510 const Qgis::WkbType type = sipCpp->wkbType();
2511 if ( sipCpp->isNull() )
2512 {
2513 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2514 sipIsErr = 1;
2515 }
2517 {
2518 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() );
2519 sipIsErr = 1;
2520 }
2521 else
2522 {
2523 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2524 sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2525 }
2526 % End
2527#endif
2528
2532 QVector<QgsGeometry> asGeometryCollection() const;
2533
2538 QPointF asQPointF() const SIP_HOLDGIL;
2539
2551 QPolygonF asQPolygonF() const SIP_HOLDGIL;
2552
2558 bool deleteRing( int ringNum, int partNum = 0 );
2559
2564 bool deletePart( int partNum );
2565
2574 bool convertToMultiType();
2575
2591 bool convertToCurvedMultiType();
2592
2602 bool convertToSingleType();
2603
2613 bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2614
2626 Q_DECL_DEPRECATED int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2627 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) ) SIP_DEPRECATED;
2628
2640 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2641 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2642
2663 QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2664
2674 Qgis::AngularDirection polygonOrientation() const;
2675
2689 bool isPolygonCounterClockwise() const { return polygonOrientation() == Qgis::AngularDirection::CounterClockwise; }
2690
2704 bool isPolygonClockwise() const { return polygonOrientation() == Qgis::AngularDirection::Clockwise; }
2705
2706
2721 QgsGeometry forceRHR() const;
2722
2733 QgsGeometry forcePolygonClockwise() const;
2734
2745 QgsGeometry forcePolygonCounterClockwise() const;
2746
2751 class CORE_EXPORT Error
2752 {
2753 public:
2755 : mMessage( QStringLiteral( "none" ) )
2756 {}
2757
2758 explicit Error( const QString &m )
2759 : mMessage( m )
2760 {}
2761
2762 Error( const QString &m, const QgsPointXY &p )
2763 : mMessage( m )
2764 , mLocation( p )
2765 , mHasLocation( true ) {}
2766
2770 QString what() const;
2771
2775 QgsPointXY where() const;
2776
2780 bool hasWhere() const;
2781
2782#ifdef SIP_RUN
2783 SIP_PYOBJECT __repr__();
2784 % MethodCode
2785 QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2786 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2787 % End
2788#endif
2789
2790 // TODO c++20 - replace with = default
2791 bool operator==( const QgsGeometry::Error &other ) const
2792 {
2793 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2794 }
2795
2796 private:
2797 QString mMessage;
2798 QgsPointXY mLocation;
2799 bool mHasLocation = false;
2800 };
2801
2809 void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2810
2820 void normalize();
2821
2830 static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2831
2839 static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2840
2847 void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2848
2854 bool requiresConversionToStraightSegments() const;
2855
2860 void mapToPixel( const QgsMapToPixel &mtp );
2861
2866 void draw( QPainter &p ) const;
2867
2877 bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2878
2889 int vertexNrFromVertexId( QgsVertexId id ) const;
2890
2897 QString lastError() const SIP_HOLDGIL;
2898
2908 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2909
2924 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2925
2930 static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2931
2938 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2939
2947 Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2948
2956 Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2957
2958#ifndef SIP_RUN
2959
2968 static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2969 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2970
2979 static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2980 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2981
2991 static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
2992 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2993#else
2994
3013 static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3014 % MethodCode
3015 {
3016 sipRes = false;
3017 int state0;
3018 int state1;
3019 int sipIsErr = 0;
3020
3021 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3022 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3023 {
3024 PyObject *o0 = PyList_GetItem( a0, 0 );
3025 PyObject *o1 = PyList_GetItem( a1, 0 );
3026 if ( o0 && o1 )
3027 {
3028 // compare polyline - polyline
3029 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3030 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3031 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3032 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3033 {
3034 QgsPolylineXY *p0;
3035 QgsPolylineXY *p1;
3036 p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3037 p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3038 if ( !sipIsErr )
3039 {
3040 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3041 }
3042 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3043 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3044 }
3045 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3046 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3047 {
3048 PyObject *oo0 = PyList_GetItem( o0, 0 );
3049 PyObject *oo1 = PyList_GetItem( o1, 0 );
3050 if ( oo0 && oo1 )
3051 {
3052 // compare polygon - polygon
3053 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3054 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3055 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3056 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3057 {
3058 QgsPolygonXY *p0;
3059 QgsPolygonXY *p1;
3060 p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3061 p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3062 if ( !sipIsErr )
3063 {
3064 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3065 }
3066 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3067 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3068 }
3069 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3070 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3071 {
3072 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3073 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3074 if ( ooo0 && ooo1 )
3075 {
3076 // compare multipolygon - multipolygon
3077 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3078 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3079 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3080 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3081 {
3084 p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3085 p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3086 if ( !sipIsErr )
3087 {
3088 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3089 }
3090 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3091 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3092 }
3093 }
3094 }
3095 }
3096 }
3097 }
3098 }
3099 }
3100 % End
3101#endif
3102
3118 QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
3119 double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
3120
3161
3167 static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3168
3174 static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3175
3177 operator QVariant() const
3178 {
3179 return QVariant::fromValue( *this );
3180 }
3181
3182 private:
3183
3184 QgsGeometryPrivate *d; //implicitly shared data pointer
3185
3187 mutable QString mLastError;
3188
3193 void detach();
3194
3199 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3200
3201 static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3202
3204 QgsGeometry convertToPoint( bool destMultipart ) const;
3206 QgsGeometry convertToLine( bool destMultipart ) const;
3208 QgsGeometry convertToPolygon( bool destMultipart ) const;
3209
3221 std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3222 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3223
3235 std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3236 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3237
3238
3240
3241}; // class QgsGeometry
3242
3244
3245
3246CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3248CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3249
3250#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:6054
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:74
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.
Definition qgsgeometry.h:84
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition qgsgeometry.h:80
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition qgsgeometry.h:62
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition qgsgeometry.h:91
QgsPointSequence QgsPolyline
Polyline as represented as a vector of points.
Definition qgsgeometry.h:70
int precision
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:30