QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
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
324 static QgsGeometry fromBox3D( const QgsBox3D &box ) SIP_HOLDGIL;
325
326
328 static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
329
345 static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
346 double outerRadius, double innerRadius = 0 );
347
353 void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
354
358 void fromWkb( const QByteArray &wkb );
359
364 Qgis::WkbType wkbType() const SIP_HOLDGIL;
365
370 Qgis::GeometryType type() const SIP_HOLDGIL;
371
378 bool isEmpty() const SIP_HOLDGIL;
379
381 bool isMultipart() const SIP_HOLDGIL;
382
396 bool equals( const QgsGeometry &geometry ) const;
397
413 bool isGeosEqual( const QgsGeometry & ) const;
414
421 bool isGeosValid( Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
422
430 bool isSimple() const;
431
445 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
446
458 double area() const;
459
473 double length() const;
474
482 double distance( const QgsGeometry &geom ) const;
483
484#ifndef SIP_RUN
485
486 // TODO QGIS 4: consider renaming vertices_begin, vertices_end, parts_begin, parts_end, etc
487 // to camelCase
488
492 QgsAbstractGeometry::vertex_iterator vertices_begin() const;
493
497 QgsAbstractGeometry::vertex_iterator vertices_end() const;
498#endif
499
522 QgsVertexIterator vertices() const;
523
524#ifndef SIP_RUN
525
535
545
554 QgsAbstractGeometry::const_part_iterator const_parts_begin() const;
555
564 QgsAbstractGeometry::const_part_iterator const_parts_end() const;
565#endif
566
605
638 QgsGeometryConstPartIterator constParts() const;
639
656 double hausdorffDistance( const QgsGeometry &geom ) const;
657
675 double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
676
691 double frechetDistance( const QgsGeometry &geom ) const SIP_THROW( QgsNotSupportedException );
692
715 double frechetDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const SIP_THROW( QgsNotSupportedException );
716
729 QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;
730
738 double distanceToVertex( int vertex ) const;
739
746 double angleAtVertex( int vertex ) const;
747
760 void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
761
774 bool insertVertex( double x, double y, int beforeVertex );
775
788 bool insertVertex( const QgsPoint &point, int beforeVertex );
789
797 bool addTopologicalPoint( const QgsPoint &point, double snappingTolerance = 1e-8, double segmentSearchEpsilon = 1e-12 );
798
806 bool moveVertex( double x, double y, int atVertex );
807
815 bool moveVertex( const QgsPoint &p, int atVertex );
816
828 bool deleteVertex( int atVertex );
829
837 bool toggleCircularAtVertex( int atVertex );
838
844 QgsPoint vertexAt( int atVertex ) const;
845
851 double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
852
857 QgsGeometry nearestPoint( const QgsGeometry &other ) const;
858
868 QgsGeometry shortestLine( const QgsGeometry &other ) const;
869
876 double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
877
889 double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
890
896 Qgis::GeometryOperationResult addRing( const QVector<QgsPointXY> &ring );
897
904
912 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY ) SIP_DEPRECATED;
913
921 Qgis::GeometryOperationResult addPartV2( const QVector<QgsPointXY> &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsXYV2 );
922
930 Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart( const QgsPointSequence &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPoints ) SIP_DEPRECATED;
931
939 Qgis::GeometryOperationResult addPartV2( const QgsPointSequence &points, Qgis::WkbType wkbType = Qgis::WkbType::Unknown ) SIP_PYNAME( addPointsV2 );
940
949
958
964 Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
965
971 QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
972
977 Qgis::GeometryOperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
978
994
1003 Qgis::GeometryOperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
1004
1011 Qgis::GeometryOperationResult rotate( double rotation, const QgsPointXY &center );
1012
1023 Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints, bool splitFeature = true ) SIP_SKIP;
1024
1046 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;
1047
1048
1049 /*
1050 This SIP code is to support overloaded methods of splitGeometry.
1051 When the deprecated method is removed in QGIS 4.0 this code can be dropped
1052 TODO QGIS 4 remove MethodCode
1053 */
1054#ifdef SIP_RUN
1055
1074 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]]] );
1075 % MethodCode
1076 {
1077 int sipIsErr = 0;
1078 int state;
1079
1080 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1081 {
1082 PyObject *p0 = PyList_GetItem( a0, 0 );
1083 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1084 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1085 {
1086 QVector<QgsGeometry> newGeometries;
1087 QVector<QgsPointXY> topologyTestPoints;
1088
1089 QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1090 if ( sipIsErr )
1091 {
1092 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1093 }
1094 else
1095 {
1096 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1097
1098 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1099 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1100 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1101
1102 sipRes = PyTuple_New( 3 );
1103 PyTuple_SET_ITEM( sipRes, 0, o0 );
1104 PyTuple_SET_ITEM( sipRes, 1, o1 );
1105 PyTuple_SET_ITEM( sipRes, 2, o2 );
1106 }
1107 }
1108
1109 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1110 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1111 {
1112 QVector<QgsGeometry> newGeometries;
1113 QVector<QgsPoint> topologyTestPoints;
1114
1115 QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1116 if ( sipIsErr )
1117 {
1118 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1119 }
1120 else
1121 {
1122 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1123
1124 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1125 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1126 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1127
1128 sipRes = PyTuple_New( 3 );
1129 PyTuple_SET_ITEM( sipRes, 0, o0 );
1130 PyTuple_SET_ITEM( sipRes, 1, o1 );
1131 PyTuple_SET_ITEM( sipRes, 2, o2 );
1132 }
1133 }
1134 else
1135 {
1136 sipIsErr = 1;
1137 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1138 }
1139 }
1140 else
1141 {
1142 sipIsErr = 1;
1143 PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1144 }
1145 }
1146 % End
1147#endif
1148
1160 Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1161
1166 Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1167
1173 int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1174
1181 QgsGeometry makeDifference( const QgsGeometry &other ) const;
1182
1187 QgsRectangle boundingBox() const;
1188
1194 QgsBox3D boundingBox3D() const;
1195
1206 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1207
1216 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1217
1225 QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1226
1231 QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1232
1240 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
1241
1254 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1255
1274 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1275
1288 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1289
1308 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1309
1322 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1323
1342 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1343
1357 QgsGeometry applyDashPattern( const QVector< double > &pattern,
1358 Qgis::DashPatternLineEndingRule startRule = Qgis::DashPatternLineEndingRule::NoRule,
1359 Qgis::DashPatternLineEndingRule endRule = Qgis::DashPatternLineEndingRule::NoRule,
1360 Qgis::DashPatternSizeAdjustment adjustment = Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1361 double patternOffset = 0 ) const;
1362
1374 QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1375
1395 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1396
1406 bool intersects( const QgsRectangle &rectangle ) const;
1407
1422 bool intersects( const QgsGeometry &geometry ) const;
1423
1432 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1433
1442 bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1443
1447 bool contains( const QgsPointXY *p ) const;
1448
1454 bool contains( double x, double y ) const;
1455
1465 bool contains( const QgsGeometry &geometry ) const;
1466
1476 bool disjoint( const QgsGeometry &geometry ) const;
1477
1487 bool touches( const QgsGeometry &geometry ) const;
1488
1498 bool overlaps( const QgsGeometry &geometry ) const;
1499
1509 bool within( const QgsGeometry &geometry ) const;
1510
1520 bool crosses( const QgsGeometry &geometry ) const;
1521
1529 QgsGeometry buffer( double distance, int segments ) const;
1530
1542 QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1543
1551 QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1552
1567 QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1568 Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1569 double miterLimit = 2.0 ) const;
1570
1588 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1589
1604 QgsGeometry variableWidthBufferByM( int segments ) const;
1605
1611 QgsGeometry extendLine( double startDistance, double endDistance ) const;
1612
1614 QgsGeometry simplify( double tolerance ) const;
1615
1624 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1625
1639 QgsGeometry densifyByDistance( double distance ) const;
1640
1656 QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1657
1671 QgsGeometry centroid() const;
1672
1686 QgsGeometry pointOnSurface() const;
1687
1699 QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1700
1724 QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1725
1740 QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1741
1763 double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1764
1776 QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1777
1786 QgsGeometry convexHull() const;
1787
1801 QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1802
1817 QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1818
1829 QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1830
1843 QgsGeometry constrainedDelaunayTriangulation() const SIP_THROW( QgsNotSupportedException );
1844
1862 Qgis::CoverageValidityResult validateCoverage( double gapWidth, QgsGeometry *invalidEdges SIP_OUT = nullptr ) const SIP_THROW( QgsNotSupportedException );
1863
1884 QgsGeometry simplifyCoverageVW( double tolerance, bool preserveBoundary ) const SIP_THROW( QgsNotSupportedException );
1885
1897 QgsGeometry unionCoverage() const;
1898
1909 QgsGeometry node() const;
1910
1925 QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1926
1948 QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1949
1964 QgsGeometry interpolate( double distance ) const;
1965
1976 double lineLocatePoint( const QgsGeometry &point ) const;
1977
1986 double interpolateAngle( double distance ) const;
1987
1999 QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2000
2007 QgsGeometry clipped( const QgsRectangle &rectangle );
2008
2023 QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2024
2032 QgsGeometry mergeLines() const;
2033
2045 QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2046
2058 QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2059
2061 QgsGeometry extrude( double x, double y );
2062
2063#ifndef SIP_RUN
2064
2086 QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2087
2101 QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2103#else
2104
2118 SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2119 % MethodCode
2120 const Qgis::GeometryType type = sipCpp->type();
2121 if ( sipCpp->isNull() )
2122 {
2123 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2124 sipIsErr = 1;
2125 }
2126 else if ( type != Qgis::GeometryType::Polygon )
2127 {
2128 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2129 sipIsErr = 1;
2130 }
2131 else
2132 {
2133 const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2134 sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2135 }
2136 % End
2137
2138
2139#endif
2141
2149 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2150
2157 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2158
2164 Q_INVOKABLE QString asWkt( int precision = 17 ) const;
2165
2166#ifdef SIP_RUN
2167 SIP_PYOBJECT __repr__();
2168 % MethodCode
2169 QString str;
2170 if ( sipCpp->isNull() )
2171 str = QStringLiteral( "<QgsGeometry: null>" );
2172 else
2173 {
2174 QString wkt = sipCpp->asWkt();
2175 if ( wkt.length() > 1000 )
2176 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2177 str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2178 }
2179 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2180 % End
2181#endif
2182
2186 QString asJson( int precision = 17 ) const;
2187
2193 virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2194
2221 QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0 ) const;
2222
2234 QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2235
2236 /* Accessor functions for getting geometry data */
2237
2238#ifndef SIP_RUN
2239
2248 QgsPointXY asPoint() const;
2249#else
2250
2261 SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2262 % MethodCode
2263 if ( sipCpp->isNull() )
2264 {
2265 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2266 sipIsErr = 1;
2267 }
2268 else
2269 {
2270 const QgsAbstractGeometry *geom = sipCpp->constGet();
2272 {
2273 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() );
2274 sipIsErr = 1;
2275 }
2276 else
2277 {
2278 sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2279 }
2280 }
2281 % End
2282#endif
2283
2284#ifndef SIP_RUN
2285
2294 QgsPolylineXY asPolyline() const;
2295#else
2296
2308 SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2309 % MethodCode
2310 const Qgis::WkbType type = sipCpp->wkbType();
2311 if ( sipCpp->isNull() )
2312 {
2313 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2314 sipIsErr = 1;
2315 }
2317 {
2318 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() );
2319 sipIsErr = 1;
2320 }
2321 else
2322 {
2323 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2324 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2325 }
2326 % End
2327#endif
2328
2329#ifndef SIP_RUN
2330
2339 QgsPolygonXY asPolygon() const;
2340#else
2341
2353 SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
2354 % MethodCode
2355 const Qgis::WkbType type = sipCpp->wkbType();
2356 if ( sipCpp->isNull() )
2357 {
2358 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2359 sipIsErr = 1;
2360 }
2362 {
2363 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() );
2364 sipIsErr = 1;
2365 }
2366 else
2367 {
2368 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2369 sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2370 }
2371 % End
2372#endif
2373
2374#ifndef SIP_RUN
2375
2383 QgsMultiPointXY asMultiPoint() const;
2384#else
2385
2396 SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2397 % MethodCode
2398 const Qgis::WkbType type = sipCpp->wkbType();
2399 if ( sipCpp->isNull() )
2400 {
2401 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2402 sipIsErr = 1;
2403 }
2405 {
2406 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2407 sipIsErr = 1;
2408 }
2409 else
2410 {
2411 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2412 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2413 }
2414 % End
2415#endif
2416
2417#ifndef SIP_RUN
2418
2427 QgsMultiPolylineXY asMultiPolyline() const;
2428#else
2429
2441 SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2442 % MethodCode
2443 const Qgis::WkbType type = sipCpp->wkbType();
2444 if ( sipCpp->isNull() )
2445 {
2446 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2447 sipIsErr = 1;
2448 }
2450 {
2451 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() );
2452 sipIsErr = 1;
2453 }
2454 else
2455 {
2456 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2457 sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2458 }
2459 % End
2460#endif
2461
2462#ifndef SIP_RUN
2463
2472 QgsMultiPolygonXY asMultiPolygon() const;
2473#else
2474
2486 SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2487 % MethodCode
2488 const Qgis::WkbType type = sipCpp->wkbType();
2489 if ( sipCpp->isNull() )
2490 {
2491 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2492 sipIsErr = 1;
2493 }
2495 {
2496 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() );
2497 sipIsErr = 1;
2498 }
2499 else
2500 {
2501 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2502 sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2503 }
2504 % End
2505#endif
2506
2510 QVector<QgsGeometry> asGeometryCollection() const;
2511
2516 QPointF asQPointF() const SIP_HOLDGIL;
2517
2529 QPolygonF asQPolygonF() const SIP_HOLDGIL;
2530
2536 bool deleteRing( int ringNum, int partNum = 0 );
2537
2542 bool deletePart( int partNum );
2543
2552 bool convertToMultiType();
2553
2569 bool convertToCurvedMultiType();
2570
2580 bool convertToSingleType();
2581
2591 bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2592
2604 Q_DECL_DEPRECATED int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2605 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) ) SIP_DEPRECATED;
2606
2618 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2619 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2620
2641 QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2642
2652 Qgis::AngularDirection polygonOrientation() const;
2653
2667 bool isPolygonCounterClockwise() const { return polygonOrientation() == Qgis::AngularDirection::CounterClockwise; }
2668
2682 bool isPolygonClockwise() const { return polygonOrientation() == Qgis::AngularDirection::Clockwise; }
2683
2684
2699 QgsGeometry forceRHR() const;
2700
2711 QgsGeometry forcePolygonClockwise() const;
2712
2723 QgsGeometry forcePolygonCounterClockwise() const;
2724
2729 class CORE_EXPORT Error
2730 {
2731 public:
2733 : mMessage( QStringLiteral( "none" ) )
2734 {}
2735
2736 explicit Error( const QString &m )
2737 : mMessage( m )
2738 {}
2739
2740 Error( const QString &m, const QgsPointXY &p )
2741 : mMessage( m )
2742 , mLocation( p )
2743 , mHasLocation( true ) {}
2744
2748 QString what() const;
2749
2753 QgsPointXY where() const;
2754
2758 bool hasWhere() const;
2759
2760#ifdef SIP_RUN
2761 SIP_PYOBJECT __repr__();
2762 % MethodCode
2763 QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2764 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2765 % End
2766#endif
2767
2768 // TODO c++20 - replace with = default
2769 bool operator==( const QgsGeometry::Error &other ) const
2770 {
2771 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2772 }
2773
2774 private:
2775 QString mMessage;
2776 QgsPointXY mLocation;
2777 bool mHasLocation = false;
2778 };
2779
2787 void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2788
2798 void normalize();
2799
2808 static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2809
2817 static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2818
2825 void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2826
2832 bool requiresConversionToStraightSegments() const;
2833
2838 void mapToPixel( const QgsMapToPixel &mtp );
2839
2844 void draw( QPainter &p ) const;
2845
2855 bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2856
2867 int vertexNrFromVertexId( QgsVertexId id ) const;
2868
2875 QString lastError() const SIP_HOLDGIL;
2876
2886 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2887
2902 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2903
2908 static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2909
2916 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2917
2925 Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2926
2934 Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2935
2936#ifndef SIP_RUN
2937
2946 static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2947 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2948
2957 static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2958 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2959
2969 static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
2970 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2971#else
2972
2991 static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2992 % MethodCode
2993 {
2994 sipRes = false;
2995 int state0;
2996 int state1;
2997 int sipIsErr = 0;
2998
2999 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3000 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3001 {
3002 PyObject *o0 = PyList_GetItem( a0, 0 );
3003 PyObject *o1 = PyList_GetItem( a1, 0 );
3004 if ( o0 && o1 )
3005 {
3006 // compare polyline - polyline
3007 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3008 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3009 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3010 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3011 {
3012 QgsPolylineXY *p0;
3013 QgsPolylineXY *p1;
3014 p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3015 p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3016 if ( sipIsErr )
3017 {
3018 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3019 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3020 }
3021 else
3022 {
3023 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3024 }
3025 }
3026 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3027 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3028 {
3029 PyObject *oo0 = PyList_GetItem( o0, 0 );
3030 PyObject *oo1 = PyList_GetItem( o1, 0 );
3031 if ( oo0 && oo1 )
3032 {
3033 // compare polygon - polygon
3034 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3035 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3036 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3037 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3038 {
3039 QgsPolygonXY *p0;
3040 QgsPolygonXY *p1;
3041 p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3042 p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3043 if ( sipIsErr )
3044 {
3045 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3046 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3047 }
3048 else
3049 {
3050 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3051 }
3052 }
3053 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3054 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3055 {
3056 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3057 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3058 if ( ooo0 && ooo1 )
3059 {
3060 // compare multipolygon - multipolygon
3061 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3062 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3063 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3064 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3065 {
3068 p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3069 p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3070 if ( sipIsErr )
3071 {
3072 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3073 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3074 }
3075 else
3076 {
3077 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3078 }
3079 }
3080 }
3081 }
3082 }
3083 }
3084 }
3085 }
3086 }
3087 % End
3088#endif
3089
3105 QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
3106 double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
3107
3145 static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry, double precision = 0.0 ) SIP_FACTORY;
3146
3152 static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3153
3159 static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3160
3162 operator QVariant() const
3163 {
3164 return QVariant::fromValue( *this );
3165 }
3166
3167 private:
3168
3169 QgsGeometryPrivate *d; //implicitly shared data pointer
3170
3172 mutable QString mLastError;
3173
3178 void detach();
3179
3184 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3185
3186 static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3187
3189 QgsGeometry convertToPoint( bool destMultipart ) const;
3191 QgsGeometry convertToLine( bool destMultipart ) const;
3193 QgsGeometry convertToPolygon( bool destMultipart ) const;
3194
3206 std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3207 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3208
3220 std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3221 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3222
3223
3225
3226}; // class QgsGeometry
3227
3229
3230
3231CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3233CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3234
3235#endif
The Qgis class provides global constants 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:1792
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
Definition qgis.h:1825
GeometryValidationEngine
Available engines for validating geometries.
Definition qgis.h:1834
@ QgisInternal
Use internal QgsGeometryValidator method.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:274
@ Polygon
Polygons.
@ Unknown
Unknown types.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:201
@ Unknown
Unknown.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
Definition qgis.h:2369
@ Forward
Forward transform (from source to destination)
The part_iterator class provides STL-style iterator for const references to geometry parts.
The part_iterator class provides STL-style iterator for geometry parts.
The vertex_iterator class provides 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
Class for doing transforms between two map 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.
This class 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.
A class to represent 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 data sets.
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 bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
static 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.
#define str(x)
Definition qgis.cpp:38
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition qgis.h:6188
#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