QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
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 "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
171
173 QgsGeometry( const QgsGeometry & );
174
179 QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
180
186
192 explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
193
194 virtual ~QgsGeometry();
195
206 const QgsAbstractGeometry *constGet() const SIP_HOLDGIL;
207
219 QgsAbstractGeometry *get();
220
232 void set( QgsAbstractGeometry *geometry SIP_TRANSFER ) SIP_DEPRECATED;
233
241 bool isNull() const SIP_HOLDGIL;
242
244 static QgsGeometry fromWkt( const QString &wkt );
246 static QgsGeometry fromPointXY( const QgsPointXY &point ) SIP_HOLDGIL;
247
253 static QgsGeometry fromPoint( const QgsPoint &point ) SIP_HOLDGIL;
254
256 static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
257
268 static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
269
278 static QgsGeometry fromPolyline( const QgsPolyline &polyline );
279
283 static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
284
285#ifndef SIP_RUN
286
290#else
291
309#endif
310 static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
311
315 static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
316
318 static QgsGeometry fromRect( const QgsRectangle &rect ) SIP_HOLDGIL;
319
325 static QgsGeometry fromBox3D( const QgsBox3D &box ) SIP_HOLDGIL;
326
327
329 static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
330
346 static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
347 double outerRadius, double innerRadius = 0 );
348
354 void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
355
359 void fromWkb( const QByteArray &wkb );
360
365 Qgis::WkbType wkbType() const SIP_HOLDGIL;
366
371 Qgis::GeometryType type() const SIP_HOLDGIL;
372
379 bool isEmpty() const;
380
382 bool isMultipart() const SIP_HOLDGIL;
383
397 bool equals( const QgsGeometry &geometry ) const;
398
414 bool isGeosEqual( const QgsGeometry & ) const;
415
422 bool isGeosValid( Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
423
431 bool isSimple() const;
432
446 bool isAxisParallelRectangle( double maximumDeviation, bool simpleRectanglesOnly = false ) const;
447
459 double area() const;
460
474 double length() const;
475
483 double distance( const QgsGeometry &geom ) const;
484
485#ifndef SIP_RUN
486
487 // TODO QGIS 4: consider renaming vertices_begin, vertices_end, parts_begin, parts_end, etc
488 // to camelCase
489
493 QgsAbstractGeometry::vertex_iterator vertices_begin() const;
494
498 QgsAbstractGeometry::vertex_iterator vertices_end() const;
499#endif
500
523 QgsVertexIterator vertices() const;
524
525#ifndef SIP_RUN
526
536
546
555 QgsAbstractGeometry::const_part_iterator const_parts_begin() const;
556
565 QgsAbstractGeometry::const_part_iterator const_parts_end() const;
566#endif
567
606
639 QgsGeometryConstPartIterator constParts() const;
640
657 double hausdorffDistance( const QgsGeometry &geom ) const;
658
676 double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
677
692 double frechetDistance( const QgsGeometry &geom ) const SIP_THROW( QgsNotSupportedException );
693
716 double frechetDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const SIP_THROW( QgsNotSupportedException );
717
730 QgsPointXY closestVertex( const QgsPointXY &point, int &closestVertexIndex SIP_OUT, int &previousVertexIndex SIP_OUT, int &nextVertexIndex SIP_OUT, double &sqrDist SIP_OUT ) const;
731
739 double distanceToVertex( int vertex ) const;
740
747 double angleAtVertex( int vertex ) const;
748
761 void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
762
775 bool insertVertex( double x, double y, int beforeVertex );
776
789 bool insertVertex( const QgsPoint &point, int beforeVertex );
790
798 bool moveVertex( double x, double y, int atVertex );
799
807 bool moveVertex( const QgsPoint &p, int atVertex );
808
820 bool deleteVertex( int atVertex );
821
829 bool toggleCircularAtVertex( int atVertex );
830
836 QgsPoint vertexAt( int atVertex ) const;
837
843 double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
844
849 QgsGeometry nearestPoint( const QgsGeometry &other ) const;
850
860 QgsGeometry shortestLine( const QgsGeometry &other ) const;
861
868 double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
869
881 double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
882
888 Qgis::GeometryOperationResult addRing( const QVector<QgsPointXY> &ring );
889
896
903 Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY );
904
912
920
926 Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
927
933 QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
934
939 Qgis::GeometryOperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
940
956
965 Qgis::GeometryOperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
966
973 Qgis::GeometryOperationResult rotate( double rotation, const QgsPointXY &center );
974
985 Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries, bool topological, QVector<QgsPointXY> &topologyTestPoints, bool splitFeature = true ) SIP_SKIP;
986
1009 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;
1010
1011
1012 /*
1013 This SIP code is to support overloaded methods of splitGeometry.
1014 When the deprecated method is removed in QGIS 4.0 this code can be dropped
1015 TODO QGIS 4 remove MethodCode
1016 */
1017#ifdef SIP_RUN
1018
1037 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]]] );
1038 % MethodCode
1039 {
1040 int sipIsErr = 0;
1041 int state;
1042
1043 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1044 {
1045 PyObject *p0 = PyList_GetItem( a0, 0 );
1046 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1047 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1048 {
1049 QVector<QgsGeometry> newGeometries;
1050 QVector<QgsPointXY> topologyTestPoints;
1051
1052 QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1053 if ( sipIsErr )
1054 {
1055 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1056 }
1057 else
1058 {
1059 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1060
1061 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1062 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1063 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1064
1065 sipRes = PyTuple_New( 3 );
1066 PyTuple_SET_ITEM( sipRes, 0, o0 );
1067 PyTuple_SET_ITEM( sipRes, 1, o1 );
1068 PyTuple_SET_ITEM( sipRes, 2, o2 );
1069 }
1070 }
1071
1072 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1073 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1074 {
1075 QVector<QgsGeometry> newGeometries;
1076 QVector<QgsPoint> topologyTestPoints;
1077
1078 QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1079 if ( sipIsErr )
1080 {
1081 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1082 }
1083 else
1084 {
1085 Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1086
1087 PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1088 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1089 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1090
1091 sipRes = PyTuple_New( 3 );
1092 PyTuple_SET_ITEM( sipRes, 0, o0 );
1093 PyTuple_SET_ITEM( sipRes, 1, o1 );
1094 PyTuple_SET_ITEM( sipRes, 2, o2 );
1095 }
1096 }
1097 else
1098 {
1099 sipIsErr = 1;
1100 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1101 }
1102 }
1103 else
1104 {
1105 sipIsErr = 1;
1106 PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1107 }
1108 }
1109 % End
1110#endif
1111
1123 Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1124
1129 Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1130
1136 int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1137
1144 QgsGeometry makeDifference( const QgsGeometry &other ) const;
1145
1150 QgsRectangle boundingBox() const;
1151
1157 QgsBox3D boundingBox3D() const;
1158
1169 QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1170
1179 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1180
1188 QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1189
1194 QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1195
1203 QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
1204
1217 QgsGeometry triangularWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1218
1237 QgsGeometry triangularWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1238
1251 QgsGeometry squareWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1252
1271 QgsGeometry squareWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1272
1285 QgsGeometry roundWaves( double wavelength, double amplitude, bool strictWavelength = false ) const;
1286
1305 QgsGeometry roundWavesRandomized( double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed = 0 ) const;
1306
1320 QgsGeometry applyDashPattern( const QVector< double > &pattern,
1321 Qgis::DashPatternLineEndingRule startRule = Qgis::DashPatternLineEndingRule::NoRule,
1322 Qgis::DashPatternLineEndingRule endRule = Qgis::DashPatternLineEndingRule::NoRule,
1323 Qgis::DashPatternSizeAdjustment adjustment = Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1324 double patternOffset = 0 ) const;
1325
1337 QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1338
1358 bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1359
1369 bool intersects( const QgsRectangle &rectangle ) const;
1370
1385 bool intersects( const QgsGeometry &geometry ) const;
1386
1395 bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1396
1405 bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1406
1410 bool contains( const QgsPointXY *p ) const;
1411
1421 bool contains( const QgsGeometry &geometry ) const;
1422
1432 bool disjoint( const QgsGeometry &geometry ) const;
1433
1443 bool touches( const QgsGeometry &geometry ) const;
1444
1454 bool overlaps( const QgsGeometry &geometry ) const;
1455
1465 bool within( const QgsGeometry &geometry ) const;
1466
1476 bool crosses( const QgsGeometry &geometry ) const;
1477
1485 QgsGeometry buffer( double distance, int segments ) const;
1486
1498 QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1499
1507 QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1508
1523 QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1524 Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1525 double miterLimit = 2.0 ) const;
1526
1544 QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1545
1560 QgsGeometry variableWidthBufferByM( int segments ) const;
1561
1567 QgsGeometry extendLine( double startDistance, double endDistance ) const;
1568
1570 QgsGeometry simplify( double tolerance ) const;
1571
1580 QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1581
1595 QgsGeometry densifyByDistance( double distance ) const;
1596
1612 QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1613
1627 QgsGeometry centroid() const;
1628
1642 QgsGeometry pointOnSurface() const;
1643
1655 QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1656
1680 QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1681
1696 QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1697
1719 double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1720
1732 QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1733
1742 QgsGeometry convexHull() const;
1743
1757 QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1758
1773 QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1774
1785 QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1786
1799 QgsGeometry constrainedDelaunayTriangulation() const SIP_THROW( QgsNotSupportedException );
1800
1818 Qgis::CoverageValidityResult validateCoverage( double gapWidth, QgsGeometry *invalidEdges SIP_OUT = nullptr ) const SIP_THROW( QgsNotSupportedException );
1819
1840 QgsGeometry simplifyCoverageVW( double tolerance, bool preserveBoundary ) const SIP_THROW( QgsNotSupportedException );
1841
1853 QgsGeometry unionCoverage() const;
1854
1865 QgsGeometry node() const;
1866
1881 QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1882
1904 QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1905
1920 QgsGeometry interpolate( double distance ) const;
1921
1932 double lineLocatePoint( const QgsGeometry &point ) const;
1933
1942 double interpolateAngle( double distance ) const;
1943
1955 QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1956
1963 QgsGeometry clipped( const QgsRectangle &rectangle );
1964
1979 QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1980
1988 QgsGeometry mergeLines() const;
1989
2001 QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2002
2014 QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2015
2017 QgsGeometry extrude( double x, double y );
2018
2019#ifndef SIP_RUN
2020
2042 QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2043
2057 QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2059#else
2060
2074 SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2075 % MethodCode
2076 const Qgis::GeometryType type = sipCpp->type();
2077 if ( sipCpp->isNull() )
2078 {
2079 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2080 sipIsErr = 1;
2081 }
2082 else if ( type != Qgis::GeometryType::Polygon )
2083 {
2084 PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2085 sipIsErr = 1;
2086 }
2087 else
2088 {
2089 const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2090 sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2091 }
2092 % End
2093
2094
2095#endif
2097
2105 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2106
2113 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2114
2120 QString asWkt( int precision = 17 ) const;
2121
2122#ifdef SIP_RUN
2123 SIP_PYOBJECT __repr__();
2124 % MethodCode
2125 QString str;
2126 if ( sipCpp->isNull() )
2127 str = QStringLiteral( "<QgsGeometry: null>" );
2128 else
2129 {
2130 QString wkt = sipCpp->asWkt();
2131 if ( wkt.length() > 1000 )
2132 wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2133 str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2134 }
2135 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2136 % End
2137#endif
2138
2142 QString asJson( int precision = 17 ) const;
2143
2149 virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2150
2177 QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0 ) const;
2178
2190 QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2191
2192 /* Accessor functions for getting geometry data */
2193
2194#ifndef SIP_RUN
2195
2204 QgsPointXY asPoint() const;
2205#else
2206
2217 SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2218 % MethodCode
2219 if ( sipCpp->isNull() )
2220 {
2221 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2222 sipIsErr = 1;
2223 }
2224 else
2225 {
2226 const QgsAbstractGeometry *geom = sipCpp->constGet();
2228 {
2229 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() );
2230 sipIsErr = 1;
2231 }
2232 else
2233 {
2234 sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2235 }
2236 }
2237 % End
2238#endif
2239
2240#ifndef SIP_RUN
2241
2250 QgsPolylineXY asPolyline() const;
2251#else
2252
2264 SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2265 % MethodCode
2266 const Qgis::WkbType type = sipCpp->wkbType();
2267 if ( sipCpp->isNull() )
2268 {
2269 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2270 sipIsErr = 1;
2271 }
2273 {
2274 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() );
2275 sipIsErr = 1;
2276 }
2277 else
2278 {
2279 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2280 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2281 }
2282 % End
2283#endif
2284
2285#ifndef SIP_RUN
2286
2295 QgsPolygonXY asPolygon() const;
2296#else
2297
2309 SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
2310 % MethodCode
2311 const Qgis::WkbType type = sipCpp->wkbType();
2312 if ( sipCpp->isNull() )
2313 {
2314 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2315 sipIsErr = 1;
2316 }
2318 {
2319 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() );
2320 sipIsErr = 1;
2321 }
2322 else
2323 {
2324 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2325 sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2326 }
2327 % End
2328#endif
2329
2330#ifndef SIP_RUN
2331
2339 QgsMultiPointXY asMultiPoint() const;
2340#else
2341
2352 SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2353 % MethodCode
2354 const Qgis::WkbType type = sipCpp->wkbType();
2355 if ( sipCpp->isNull() )
2356 {
2357 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2358 sipIsErr = 1;
2359 }
2361 {
2362 PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2363 sipIsErr = 1;
2364 }
2365 else
2366 {
2367 const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2368 sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2369 }
2370 % End
2371#endif
2372
2373#ifndef SIP_RUN
2374
2383 QgsMultiPolylineXY asMultiPolyline() const;
2384#else
2385
2397 SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2398 % MethodCode
2399 const Qgis::WkbType type = sipCpp->wkbType();
2400 if ( sipCpp->isNull() )
2401 {
2402 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2403 sipIsErr = 1;
2404 }
2406 {
2407 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() );
2408 sipIsErr = 1;
2409 }
2410 else
2411 {
2412 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2413 sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2414 }
2415 % End
2416#endif
2417
2418#ifndef SIP_RUN
2419
2428 QgsMultiPolygonXY asMultiPolygon() const;
2429#else
2430
2442 SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2443 % MethodCode
2444 const Qgis::WkbType type = sipCpp->wkbType();
2445 if ( sipCpp->isNull() )
2446 {
2447 PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2448 sipIsErr = 1;
2449 }
2451 {
2452 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() );
2453 sipIsErr = 1;
2454 }
2455 else
2456 {
2457 const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2458 sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2459 }
2460 % End
2461#endif
2462
2466 QVector<QgsGeometry> asGeometryCollection() const;
2467
2472 QPointF asQPointF() const SIP_HOLDGIL;
2473
2485 QPolygonF asQPolygonF() const SIP_HOLDGIL;
2486
2492 bool deleteRing( int ringNum, int partNum = 0 );
2493
2498 bool deletePart( int partNum );
2499
2508 bool convertToMultiType();
2509
2525 bool convertToCurvedMultiType();
2526
2536 bool convertToSingleType();
2537
2547 bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2548
2560 Q_DECL_DEPRECATED int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2561 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) ) SIP_DEPRECATED;
2562
2574 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2575 const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2576
2597 QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2598
2608 Qgis::AngularDirection polygonOrientation() const;
2609
2623 bool isPolygonCounterClockwise() const { return polygonOrientation() == Qgis::AngularDirection::CounterClockwise; }
2624
2638 bool isPolygonClockwise() const { return polygonOrientation() == Qgis::AngularDirection::Clockwise; }
2639
2640
2655 QgsGeometry forceRHR() const;
2656
2667 QgsGeometry forcePolygonClockwise() const;
2668
2679 QgsGeometry forcePolygonCounterClockwise() const;
2680
2685 class CORE_EXPORT Error
2686 {
2687 public:
2689 : mMessage( QStringLiteral( "none" ) )
2690 {}
2691
2692 explicit Error( const QString &m )
2693 : mMessage( m )
2694 {}
2695
2696 Error( const QString &m, const QgsPointXY &p )
2697 : mMessage( m )
2698 , mLocation( p )
2699 , mHasLocation( true ) {}
2700
2704 QString what() const;
2705
2709 QgsPointXY where() const;
2710
2714 bool hasWhere() const;
2715
2716#ifdef SIP_RUN
2717 SIP_PYOBJECT __repr__();
2718 % MethodCode
2719 QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2720 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2721 % End
2722#endif
2723
2724 // TODO c++20 - replace with = default
2725 bool operator==( const QgsGeometry::Error &other ) const
2726 {
2727 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2728 }
2729
2730 private:
2731 QString mMessage;
2732 QgsPointXY mLocation;
2733 bool mHasLocation = false;
2734 };
2735
2743 void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2744
2754 void normalize();
2755
2764 static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2765
2773 static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2774
2781 void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2782
2788 bool requiresConversionToStraightSegments() const;
2789
2794 void mapToPixel( const QgsMapToPixel &mtp );
2795
2800 void draw( QPainter &p ) const;
2801
2811 bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2812
2823 int vertexNrFromVertexId( QgsVertexId id ) const;
2824
2831 QString lastError() const SIP_HOLDGIL;
2832
2842 void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2843
2858 void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2859
2864 static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2865
2872 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2873
2881 Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2882
2890 Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2891
2892#ifndef SIP_RUN
2893
2902 static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2903 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2904
2913 static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2914 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2915
2925 static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
2926 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2927#else
2928
2947 static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2948 % MethodCode
2949 {
2950 sipRes = false;
2951 int state0;
2952 int state1;
2953 int sipIsErr = 0;
2954
2955 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2956 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2957 {
2958 PyObject *o0 = PyList_GetItem( a0, 0 );
2959 PyObject *o1 = PyList_GetItem( a1, 0 );
2960 if ( o0 && o1 )
2961 {
2962 // compare polyline - polyline
2963 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2964 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2965 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2966 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2967 {
2968 QgsPolylineXY *p0;
2969 QgsPolylineXY *p1;
2970 p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2971 p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2972 if ( sipIsErr )
2973 {
2974 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2975 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2976 }
2977 else
2978 {
2979 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
2980 }
2981 }
2982 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2983 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2984 {
2985 PyObject *oo0 = PyList_GetItem( o0, 0 );
2986 PyObject *oo1 = PyList_GetItem( o1, 0 );
2987 if ( oo0 && oo1 )
2988 {
2989 // compare polygon - polygon
2990 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2991 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2992 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2993 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2994 {
2995 QgsPolygonXY *p0;
2996 QgsPolygonXY *p1;
2997 p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2998 p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2999 if ( sipIsErr )
3000 {
3001 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3002 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3003 }
3004 else
3005 {
3006 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3007 }
3008 }
3009 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3010 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3011 {
3012 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3013 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3014 if ( ooo0 && ooo1 )
3015 {
3016 // compare multipolygon - multipolygon
3017 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3018 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3019 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3020 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3021 {
3024 p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3025 p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3026 if ( sipIsErr )
3027 {
3028 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3029 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3030 }
3031 else
3032 {
3033 sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3034 }
3035 }
3036 }
3037 }
3038 }
3039 }
3040 }
3041 }
3042 }
3043 % End
3044#endif
3045
3061 QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
3062 double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
3063
3101 static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry, double precision = 0.0 ) SIP_FACTORY;
3102
3108 static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3109
3115 static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3116
3118 operator QVariant() const
3119 {
3120 return QVariant::fromValue( *this );
3121 }
3122
3123 private:
3124
3125 QgsGeometryPrivate *d; //implicitly shared data pointer
3126
3128 mutable QString mLastError;
3129
3134 void detach();
3135
3140 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3141
3142 static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3143
3145 QgsGeometry convertToPoint( bool destMultipart ) const;
3147 QgsGeometry convertToLine( bool destMultipart ) const;
3149 QgsGeometry convertToPolygon( bool destMultipart ) const;
3150
3162 std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3163 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3164
3176 std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3177 double minimumDistance = -1, double maxAngle = 180.0 ) const;
3178
3179
3181
3182}; // class QgsGeometry
3183
3185
3186
3187CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3189CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3190
3191#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:1596
GeometryValidationEngine
Available engines for validating geometries.
Definition qgis.h:1638
@ QgisInternal
Use internal QgsGeometryValidator method.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:255
@ Polygon
Polygons.
@ Unknown
Unknown types.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:182
TransformDirection
Flags for raster layer temporal capabilities.
Definition qgis.h:2169
@ 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.
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:5672
#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