QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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 "json_fwd.hpp"
42using namespace nlohmann;
43#endif
44
46class QgsVectorLayer;
47class QgsMapToPixel;
48class QPainter;
49class QgsPolygon;
50class QgsLineString;
51class QgsCurve;
52class QgsFeedback;
53
63typedef QVector<QgsPointXY> QgsPolylineXY;
64
73
75#ifndef SIP_RUN
76typedef QVector<QgsPolylineXY> QgsPolygonXY;
77#else
78typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
79#endif
80
82typedef QVector<QgsPointXY> QgsMultiPointXY;
83
85#ifndef SIP_RUN
86typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
87#else
88typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
89#endif
90
92#ifndef SIP_RUN
93typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
94#else
95typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
96#endif
97
98class QgsRectangle;
99
100class QgsConstWkbPtr;
101
102struct QgsGeometryPrivate;
103
110class CORE_EXPORT QgsGeometryParameters
111{
112 public:
113
124 double gridSize() const { return mGridSize; }
125
136 void setGridSize( double size ) { mGridSize = size; }
137
138 private:
139
140 double mGridSize = -1;
141};
142
163class CORE_EXPORT QgsGeometry
164{
165 Q_GADGET
166 Q_PROPERTY( bool isNull READ isNull )
167 Q_PROPERTY( Qgis::GeometryType type READ type )
168
169 public:
170
173
175 QgsGeometry( const QgsGeometry & );
176
181 QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
182
189
195 explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
196
197 virtual ~QgsGeometry();
198
210 const QgsAbstractGeometry *constGet() const SIP_HOLDGIL;
211
224 QgsAbstractGeometry *get();
225
238 void set( QgsAbstractGeometry *geometry SIP_TRANSFER ) SIP_DEPRECATED;
239
248 bool isNull() const SIP_HOLDGIL;
249
251 static QgsGeometry fromWkt( const QString &wkt );
253 static QgsGeometry fromPointXY( const QgsPointXY &point ) SIP_HOLDGIL;
255 static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
256
268 static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
269
279 static QgsGeometry fromPolyline( const QgsPolyline &polyline );
280
284 static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
285
286#ifndef SIP_RUN
287
291#else
292
310#endif
311 static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
312
316 static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
317
319 static QgsGeometry fromRect( const QgsRectangle &rect ) SIP_HOLDGIL;
321 static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
322
338 static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
339 double outerRadius, double innerRadius = 0 );
340
346 void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
347
352 void fromWkb( const QByteArray &wkb );
353
358 Qgis::WkbType wkbType() const SIP_HOLDGIL;
359
364 Qgis::GeometryType type() const SIP_HOLDGIL;
365
372 bool isEmpty() const;
373
375 bool isMultipart() const SIP_HOLDGIL;
376
391 bool equals( const QgsGeometry &geometry ) const;
392
409 bool isGeosEqual( const QgsGeometry & ) const;
410
418 bool isGeosValid( Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
419
428 bool isSimple() const;
429
443 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
444
457 double area() const;
458
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
493 QgsAbstractGeometry::vertex_iterator vertices_begin() const;
494
499 QgsAbstractGeometry::vertex_iterator vertices_end() const;
500#endif
501
525 QgsVertexIterator vertices() const;
526
527#ifndef SIP_RUN
528
538
548
557 QgsAbstractGeometry::const_part_iterator const_parts_begin() const;
558
567 QgsAbstractGeometry::const_part_iterator const_parts_end() const;
568#endif
569
608
641 QgsGeometryConstPartIterator constParts() const;
642
660 double hausdorffDistance( const QgsGeometry &geom ) const;
661
680 double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
681
696 double frechetDistance( const QgsGeometry &geom ) const SIP_THROW( QgsNotSupportedException );
697
720 double frechetDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const SIP_THROW( QgsNotSupportedException );
721
734 QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;
735
744 double distanceToVertex( int vertex ) const;
745
753 double angleAtVertex( int vertex ) const;
754
767 void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
768
781 bool insertVertex( double x, double y, int beforeVertex );
782
795 bool insertVertex( const QgsPoint &point, int beforeVertex );
796
804 bool moveVertex( double x, double y, int atVertex );
805
813 bool moveVertex( const QgsPoint &p, int atVertex );
814
826 bool deleteVertex( int atVertex );
827
835 bool toggleCircularAtVertex( int atVertex );
836
842 QgsPoint vertexAt( int atVertex ) const;
843
849 double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
850
856 QgsGeometry nearestPoint( const QgsGeometry &other ) const;
857
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
911 Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY );
912
919 Qgis::GeometryOperationResult addPart( const QgsPointSequence &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPoints );
920
927 Qgis::GeometryOperationResult addPart( QgsAbstractGeometry *part SIP_TRANSFER, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
928
934 Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
935
942 QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
943
948 Qgis::GeometryOperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
949
964 Qgis::GeometryOperationResult transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection direction = Qgis::TransformDirection::Forward, bool transformZ = false ) SIP_THROW( QgsCsException );
965
974 Qgis::GeometryOperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
975
982 Qgis::GeometryOperationResult rotate( double rotation, const QgsPointXY &center );
983
994 Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints, bool splitFeature = true ) SIP_SKIP;
995
1018 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;
1019
1020
1021 /*
1022 This SIP code is to support overloaded methods of splitGeometry.
1023 When the deprecated method is removed in QGIS 4.0 this code can be dropped
1024 TODO QGIS 4 remove MethodCode
1025 */
1026#ifdef SIP_RUN
1027
1046 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]]] );
1047 % MethodCode
1048 {
1049 int sipIsErr = 0;
1050 int state;
1051
1052 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1053 {
1054 PyObject *p0 = PyList_GetItem( a0, 0 );
1055 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1056 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1057 {
1058 QVector<QgsGeometry> newGeometries;
1059 QVector<QgsPointXY> topologyTestPoints;
1060
1061 QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1062 if ( sipIsErr )
1063 {
1064 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1065 }
1066 else
1067 {
1068 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1069
1070 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1071 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1072 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1073
1074 sipRes = PyTuple_New( 3 );
1075 PyTuple_SET_ITEM( sipRes, 0, o0 );
1076 PyTuple_SET_ITEM( sipRes, 1, o1 );
1077 PyTuple_SET_ITEM( sipRes, 2, o2 );
1078 }
1079 }
1080
1081 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1082 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1083 {
1084 QVector<QgsGeometry> newGeometries;
1085 QVector<QgsPoint> topologyTestPoints;
1086
1087 QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1088 if ( sipIsErr )
1089 {
1090 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1091 }
1092 else
1093 {
1094 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1095
1096 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1097 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1098 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1099
1100 sipRes = PyTuple_New( 3 );
1101 PyTuple_SET_ITEM( sipRes, 0, o0 );
1102 PyTuple_SET_ITEM( sipRes, 1, o1 );
1103 PyTuple_SET_ITEM( sipRes, 2, o2 );
1104 }
1105 }
1106 else
1107 {
1108 sipIsErr = 1;
1109 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1110 }
1111 }
1112 else
1113 {
1114 sipIsErr = 1;
1115 PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1116 }
1117 }
1118 % End
1119#endif
1120
1132 Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1133
1138 Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1139
1145 int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1146
1154 QgsGeometry makeDifference( const QgsGeometry &other ) const;
1155
1160 QgsRectangle boundingBox() const;
1161
1173 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1174
1184 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1185
1194 QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1195
1201 QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1202
1211 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
1212
1225 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1226
1245 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1246
1259 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1260
1279 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1280
1293 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1294
1313 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1314
1328 QgsGeometry applyDashPattern( const QVector< double > &pattern,
1329 Qgis::DashPatternLineEndingRule startRule = Qgis::DashPatternLineEndingRule::NoRule,
1330 Qgis::DashPatternLineEndingRule endRule = Qgis::DashPatternLineEndingRule::NoRule,
1331 Qgis::DashPatternSizeAdjustment adjustment = Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1332 double patternOffset = 0 ) const;
1333
1346 QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1347
1368 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1369
1379 bool intersects( const QgsRectangle &rectangle ) const;
1380
1395 bool intersects( const QgsGeometry &geometry ) const;
1396
1406 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1407
1417 bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1418
1422 bool contains( const QgsPointXY *p ) const;
1423
1434 bool contains( const QgsGeometry &geometry ) const;
1435
1446 bool disjoint( const QgsGeometry &geometry ) const;
1447
1458 bool touches( const QgsGeometry &geometry ) const;
1459
1470 bool overlaps( const QgsGeometry &geometry ) const;
1471
1482 bool within( const QgsGeometry &geometry ) const;
1483
1494 bool crosses( const QgsGeometry &geometry ) const;
1495
1503 QgsGeometry buffer( double distance, int segments ) const;
1504
1517 QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1518
1527 QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1528
1544 QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1545 Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1546 double miterLimit = 2.0 ) const;
1547
1565 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1566
1581 QgsGeometry variableWidthBufferByM( int segments ) const;
1582
1589 QgsGeometry extendLine( double startDistance, double endDistance ) const;
1590
1592 QgsGeometry simplify( double tolerance ) const;
1593
1603 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1604
1619 QgsGeometry densifyByDistance( double distance ) const;
1620
1636 QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1637
1651 QgsGeometry centroid() const;
1652
1666 QgsGeometry pointOnSurface() const;
1667
1680 QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1681
1705 QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1706
1721 QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1722
1744 double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1745
1757 QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1758
1767 QgsGeometry convexHull() const;
1768
1782 QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1783
1799 QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1800
1810 QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1811
1822 QgsGeometry node() const;
1823
1838 QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1839
1862 QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1863
1879 QgsGeometry interpolate( double distance ) const;
1880
1892 double lineLocatePoint( const QgsGeometry &point ) const;
1893
1903 double interpolateAngle( double distance ) const;
1904
1916 QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1917
1925 QgsGeometry clipped( const QgsRectangle &rectangle );
1926
1941 QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1942
1951 QgsGeometry mergeLines() const;
1952
1964 QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1965
1977 QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1978
1980 QgsGeometry extrude( double x, double y );
1981
1982#ifndef SIP_RUN
1983
2005 QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2006
2020 QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2022#else
2023
2037 SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2038 % MethodCode
2039 const Qgis::GeometryType type = sipCpp->type();
2040 if ( sipCpp->isNull() )
2041 {
2042 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2043 sipIsErr = 1;
2044 }
2045 else if ( type != Qgis::GeometryType::Polygon )
2046 {
2047 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2048 sipIsErr = 1;
2049 }
2050 else
2051 {
2052 const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2053 sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2054 }
2055 % End
2056
2057
2058#endif
2060
2068 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2069
2077 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2078
2084 QString asWkt( int precision = 17 ) const;
2085
2086#ifdef SIP_RUN
2087 SIP_PYOBJECT __repr__();
2088 % MethodCode
2089 QString str;
2090 if ( sipCpp->isNull() )
2091 str = QStringLiteral( "<QgsGeometry: null>" );
2092 else
2093 {
2094 QString wkt = sipCpp->asWkt();
2095 if ( wkt.length() > 1000 )
2096 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2097 str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2098 }
2099 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2100 % End
2101#endif
2102
2106 QString asJson( int precision = 17 ) const;
2107
2113 virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2114
2141 QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0 ) const;
2142
2155 QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2156
2157 /* Accessor functions for getting geometry data */
2158
2159#ifndef SIP_RUN
2160
2169 QgsPointXY asPoint() const;
2170#else
2171
2182 SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2183 % MethodCode
2184 if ( sipCpp->isNull() )
2185 {
2186 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2187 sipIsErr = 1;
2188 }
2189 else
2190 {
2191 const QgsAbstractGeometry *geom = sipCpp->constGet();
2193 {
2194 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() );
2195 sipIsErr = 1;
2196 }
2197 else
2198 {
2199 sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2200 }
2201 }
2202 % End
2203#endif
2204
2205#ifndef SIP_RUN
2206
2215 QgsPolylineXY asPolyline() const;
2216#else
2217
2229 SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2230 % MethodCode
2231 const Qgis::WkbType type = sipCpp->wkbType();
2232 if ( sipCpp->isNull() )
2233 {
2234 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2235 sipIsErr = 1;
2236 }
2237 else if ( QgsWkbTypes::geometryType( type ) != Qgis::GeometryType::Line || QgsWkbTypes::isMultiType( type ) )
2238 {
2239 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() );
2240 sipIsErr = 1;
2241 }
2242 else
2243 {
2244 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2245 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2246 }
2247 % End
2248#endif
2249
2250#ifndef SIP_RUN
2251
2260 QgsPolygonXY asPolygon() const;
2261#else
2262
2274 SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
2275 % MethodCode
2276 const Qgis::WkbType type = sipCpp->wkbType();
2277 if ( sipCpp->isNull() )
2278 {
2279 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2280 sipIsErr = 1;
2281 }
2282 else if ( QgsWkbTypes::geometryType( type ) != Qgis::GeometryType::Polygon || QgsWkbTypes::isMultiType( type ) )
2283 {
2284 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() );
2285 sipIsErr = 1;
2286 }
2287 else
2288 {
2289 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2290 sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2291 }
2292 % End
2293#endif
2294
2295#ifndef SIP_RUN
2296
2304 QgsMultiPointXY asMultiPoint() const;
2305#else
2306
2317 SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2318 % MethodCode
2319 const Qgis::WkbType type = sipCpp->wkbType();
2320 if ( sipCpp->isNull() )
2321 {
2322 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2323 sipIsErr = 1;
2324 }
2325 else if ( QgsWkbTypes::geometryType( type ) != Qgis::GeometryType::Point || !QgsWkbTypes::isMultiType( type ) )
2326 {
2327 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2328 sipIsErr = 1;
2329 }
2330 else
2331 {
2332 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2333 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2334 }
2335 % End
2336#endif
2337
2338#ifndef SIP_RUN
2339
2348 QgsMultiPolylineXY asMultiPolyline() const;
2349#else
2350
2362 SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2363 % MethodCode
2364 const Qgis::WkbType type = sipCpp->wkbType();
2365 if ( sipCpp->isNull() )
2366 {
2367 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2368 sipIsErr = 1;
2369 }
2370 else if ( QgsWkbTypes::geometryType( type ) != Qgis::GeometryType::Line || !QgsWkbTypes::isMultiType( type ) )
2371 {
2372 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() );
2373 sipIsErr = 1;
2374 }
2375 else
2376 {
2377 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2378 sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2379 }
2380 % End
2381#endif
2382
2383#ifndef SIP_RUN
2384
2393 QgsMultiPolygonXY asMultiPolygon() const;
2394#else
2395
2407 SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2408 % MethodCode
2409 const Qgis::WkbType type = sipCpp->wkbType();
2410 if ( sipCpp->isNull() )
2411 {
2412 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2413 sipIsErr = 1;
2414 }
2415 else if ( QgsWkbTypes::geometryType( type ) != Qgis::GeometryType::Polygon || !QgsWkbTypes::isMultiType( type ) )
2416 {
2417 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() );
2418 sipIsErr = 1;
2419 }
2420 else
2421 {
2422 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2423 sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2424 }
2425 % End
2426#endif
2427
2432 QVector<QgsGeometry> asGeometryCollection() const;
2433
2439 QPointF asQPointF() const SIP_HOLDGIL;
2440
2453 QPolygonF asQPolygonF() const SIP_HOLDGIL;
2454
2461 bool deleteRing( int ringNum, int partNum = 0 );
2462
2468 bool deletePart( int partNum );
2469
2478 bool convertToMultiType();
2479
2495 bool convertToCurvedMultiType();
2496
2506 bool convertToSingleType();
2507
2517 bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2518
2530 int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2531 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2532
2554 QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2555
2568 QgsGeometry forceRHR() const;
2569
2578 QgsGeometry forcePolygonClockwise() const;
2579
2588 QgsGeometry forcePolygonCounterClockwise() const;
2589
2594 class CORE_EXPORT Error
2595 {
2596 public:
2598 : mMessage( QStringLiteral( "none" ) )
2599 {}
2600
2601 explicit Error( const QString &m )
2602 : mMessage( m )
2603 {}
2604
2605 Error( const QString &m, const QgsPointXY &p )
2606 : mMessage( m )
2607 , mLocation( p )
2608 , mHasLocation( true ) {}
2609
2613 QString what() const;
2614
2618 QgsPointXY where() const;
2619
2623 bool hasWhere() const;
2624
2625#ifdef SIP_RUN
2626 SIP_PYOBJECT __repr__();
2627 % MethodCode
2628 QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2629 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2630 % End
2631#endif
2632
2633 // TODO c++20 - replace with = default
2634 bool operator==( const QgsGeometry::Error &other ) const
2635 {
2636 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2637 }
2638
2639 private:
2640 QString mMessage;
2641 QgsPointXY mLocation;
2642 bool mHasLocation = false;
2643 };
2644
2653 void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2654
2664 void normalize();
2665
2674 static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2675
2684 static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2685
2693 void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2694
2701 bool requiresConversionToStraightSegments() const;
2702
2708 void mapToPixel( const QgsMapToPixel &mtp );
2709
2715 void draw( QPainter &p ) const;
2716
2727 bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2728
2740 int vertexNrFromVertexId( QgsVertexId id ) const;
2741
2749 QString lastError() const SIP_HOLDGIL;
2750
2760 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2761
2776 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2777
2783 static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2784
2792 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2793
2801 Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2802
2810 Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2811
2812#ifndef SIP_RUN
2813
2823 static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2824 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2825
2835 static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2836 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2837
2848 static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
2849 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2850#else
2851
2871 static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2872 % MethodCode
2873 {
2874 sipRes = false;
2875 int state0;
2876 int state1;
2877 int sipIsErr = 0;
2878
2879 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2880 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2881 {
2882 PyObject *o0 = PyList_GetItem( a0, 0 );
2883 PyObject *o1 = PyList_GetItem( a1, 0 );
2884 if ( o0 && o1 )
2885 {
2886 // compare polyline - polyline
2887 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2888 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2889 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2890 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2891 {
2892 QgsPolylineXY *p0;
2893 QgsPolylineXY *p1;
2894 p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2895 p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2896 if ( sipIsErr )
2897 {
2898 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2899 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2900 }
2901 else
2902 {
2903 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
2904 }
2905 }
2906 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2907 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2908 {
2909 PyObject *oo0 = PyList_GetItem( o0, 0 );
2910 PyObject *oo1 = PyList_GetItem( o1, 0 );
2911 if ( oo0 && oo1 )
2912 {
2913 // compare polygon - polygon
2914 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2915 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2916 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2917 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2918 {
2919 QgsPolygonXY *p0;
2920 QgsPolygonXY *p1;
2921 p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2922 p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2923 if ( sipIsErr )
2924 {
2925 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
2926 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
2927 }
2928 else
2929 {
2930 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
2931 }
2932 }
2933 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
2934 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
2935 {
2936 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
2937 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
2938 if ( ooo0 && ooo1 )
2939 {
2940 // compare multipolygon - multipolygon
2941 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2942 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2943 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2944 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2945 {
2948 p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2949 p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2950 if ( sipIsErr )
2951 {
2952 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
2953 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
2954 }
2955 else
2956 {
2957 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
2958 }
2959 }
2960 }
2961 }
2962 }
2963 }
2964 }
2965 }
2966 }
2967 % End
2968#endif
2969
2986 QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
2987 double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
2988
3026 static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry ) SIP_FACTORY;
3027
3033 static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3034
3040 static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3041
3043 operator QVariant() const
3044 {
3045 return QVariant::fromValue( *this );
3046 }
3047
3048 private:
3049
3050 QgsGeometryPrivate *d; //implicitly shared data pointer
3051
3053 mutable QString mLastError;
3054
3059 void detach();
3060
3065 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3066
3067 static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3068
3070 QgsGeometry convertToPoint( bool destMultipart ) const;
3072 QgsGeometry convertToLine( bool destMultipart ) const;
3074 QgsGeometry convertToPolygon( bool destMultipart ) const;
3075
3087 std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3088 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3089
3101 std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3102 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3103
3104
3106
3107}; // class QgsGeometry
3108
3110
3111
3112CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3114CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3115
3116#endif
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:54
GeometryOperationResult
Success or failure of a geometry operation.
Definition: qgis.h:1424
GeometryValidationEngine
Available engines for validating geometries.
Definition: qgis.h:1465
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:227
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:154
TransformDirection
Flags for raster layer temporal capabilities.
Definition: qgis.h:1789
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 SIP_HOLDGIL
Returns a reference to the simplest lossless representation of this geometry, e.g.
Qgis::WkbType wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
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.
Definition: qgsexception.h:67
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
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.
Definition: qgsgeometry.h:111
double gridSize() const
Returns the grid size which will be used to snap vertices of a geometry.
Definition: qgsgeometry.h:124
void setGridSize(double size)
Sets the grid size which will be used to snap vertices of a geometry.
Definition: qgsgeometry.h:136
Java-style iterator for traversal of parts of a geometry.
A geometry error.
Definition: qgsgeometry.h:2595
Error(const QString &m)
Definition: qgsgeometry.h:2601
Error(const QString &m, const QgsPointXY &p)
Definition: qgsgeometry.h:2605
bool operator==(const QgsGeometry::Error &other) const
Definition: qgsgeometry.h:2634
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
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.
This class offers geometry processing methods.
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:45
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
Custom exception class which is raised when an operation is not supported.
Definition: qgsexception.h:119
A class to represent a 2D point.
Definition: qgspointxy.h:59
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
Polygon geometry type.
Definition: qgspolygon.h:34
A rectangle specified with double values.
Definition: qgsrectangle.h:42
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) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Definition: qgswkbtypes.h:865
static bool isMultiType(Qgis::WkbType type) SIP_HOLDGIL
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:759
static QString displayString(Qgis::WkbType type) SIP_HOLDGIL
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) SIP_HOLDGIL
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:629
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define str(x)
Definition: qgis.cpp:38
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition: qgis.h:4531
#define SIP_TYPEHINT(type)
Definition: qgis_sip.h:227
#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:166
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_THROW(name,...)
Definition: qgis_sip.h:198
QVector< QgsPoint > QgsPointSequence
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition: qgsgeometry.h:76
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:86
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:82
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:63
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:93
QgsPointSequence QgsPolyline
Polyline as represented as a vector of points.
Definition: qgsgeometry.h:72
int precision
Utility class for identifying a unique vertex within a geometry.
Definition: qgsvertexid.h:31