QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
qgsgeometry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometry.h - Geometry (stored as Open Geospatial Consortium WKB)
3  -------------------------------------------------------------------
4 Date : 02 May 2005
5 Copyright : (C) 2005 by Brendan Morley
6 email : 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"
42 using namespace nlohmann;
43 #endif
44 
45 class QgsGeometryEngine;
46 class QgsVectorLayer;
47 class QgsMapToPixel;
48 class QPainter;
49 class QgsPolygon;
50 class QgsLineString;
51 class QgsCurve;
52 class QgsFeedback;
53 
62 typedef QVector<QgsPointXY> QgsPolylineXY;
63 
71 
73 #ifndef SIP_RUN
74 typedef QVector<QgsPolylineXY> QgsPolygonXY;
75 #else
76 typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
77 #endif
78 
80 typedef QVector<QgsPointXY> QgsMultiPointXY;
81 
83 #ifndef SIP_RUN
84 typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
85 #else
86 typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
87 #endif
88 
90 #ifndef SIP_RUN
91 typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
92 #else
93 typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
94 #endif
95 
96 class QgsRectangle;
97 
98 class QgsConstWkbPtr;
99 
100 struct QgsGeometryPrivate;
101 
108 class 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 
161 class 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 
185  explicit QgsGeometry( QgsAbstractGeometry *geom SIP_TRANSFER );
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 
605  QgsGeometryPartIterator parts();
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 addTopologicalPoint( const QgsPoint &point, double snappingTolerance = 1e-8, double segmentSearchEpsilon = 1e-12 );
799 
807  bool moveVertex( double x, double y, int atVertex );
808 
816  bool moveVertex( const QgsPoint &p, int atVertex );
817 
829  bool deleteVertex( int atVertex );
830 
838  bool toggleCircularAtVertex( int atVertex );
839 
845  QgsPoint vertexAt( int atVertex ) const;
846 
852  double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
853 
858  QgsGeometry nearestPoint( const QgsGeometry &other ) const;
859 
869  QgsGeometry shortestLine( const QgsGeometry &other ) const;
870 
877  double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
878 
890  double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &nextVertexIndex SIP_OUT, int *leftOrRightOfSegment SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
891 
897  Qgis::GeometryOperationResult addRing( const QVector<QgsPointXY> &ring );
898 
905 
912  Qgis::GeometryOperationResult addPart( const QVector<QgsPointXY> &points, Qgis::GeometryType geomType = Qgis::GeometryType::Unknown ) SIP_PYNAME( addPointsXY );
913 
921 
929 
935  Qgis::GeometryOperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
936 
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 
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 
1017  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;
1018 
1019 
1020  /*
1021  This SIP code is to support overloaded methods of splitGeometry.
1022  When the deprecated method is removed in QGIS 4.0 this code can be dropped
1023  TODO QGIS 4 remove MethodCode
1024  */
1025 #ifdef SIP_RUN
1026 
1045  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]]] );
1046  % MethodCode
1047  {
1048  int sipIsErr = 0;
1049  int state;
1050 
1051  if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1052  {
1053  PyObject *p0 = PyList_GetItem( a0, 0 );
1054  if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1055  sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1056  {
1057  QVector<QgsGeometry> newGeometries;
1058  QVector<QgsPointXY> topologyTestPoints;
1059 
1060  QVector<QgsPointXY> *splitLine = reinterpret_cast<QVector<QgsPointXY> *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1061  if ( sipIsErr )
1062  {
1063  sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1064  }
1065  else
1066  {
1067  Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1068 
1069  PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1070  PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1071  PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1072 
1073  sipRes = PyTuple_New( 3 );
1074  PyTuple_SET_ITEM( sipRes, 0, o0 );
1075  PyTuple_SET_ITEM( sipRes, 1, o1 );
1076  PyTuple_SET_ITEM( sipRes, 2, o2 );
1077  }
1078  }
1079 
1080  else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1081  sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1082  {
1083  QVector<QgsGeometry> newGeometries;
1084  QVector<QgsPoint> topologyTestPoints;
1085 
1086  QVector<QgsPoint> *splitLine = reinterpret_cast<QVector<QgsPoint> *>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1087  if ( sipIsErr )
1088  {
1089  sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1090  }
1091  else
1092  {
1093  Qgis::GeometryOperationResult result = sipCpp->splitGeometry( *splitLine, newGeometries, a1, topologyTestPoints, a2 );
1094 
1095  PyObject *o0 = sipConvertFromEnum( static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1096  PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1097  PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1098 
1099  sipRes = PyTuple_New( 3 );
1100  PyTuple_SET_ITEM( sipRes, 0, o0 );
1101  PyTuple_SET_ITEM( sipRes, 1, o1 );
1102  PyTuple_SET_ITEM( sipRes, 2, o2 );
1103  }
1104  }
1105  else
1106  {
1107  sipIsErr = 1;
1108  PyErr_SetString( PyExc_TypeError, QStringLiteral( "Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1109  }
1110  }
1111  else
1112  {
1113  sipIsErr = 1;
1114  PyErr_SetString( PyExc_TypeError, QStringLiteral( "First argument is not a list of points or is empty." ).toUtf8().constData() );
1115  }
1116  }
1117  % End
1118 #endif
1119 
1131  Qgis::GeometryOperationResult splitGeometry( const QgsCurve *curve, QVector<QgsGeometry> &newGeometries SIP_OUT, bool preserveCircular, bool topological, QgsPointSequence &topologyTestPoints SIP_OUT, bool splitFeature = true );
1132 
1137  Qgis::GeometryOperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
1138 
1144  int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
1145 
1152  QgsGeometry makeDifference( const QgsGeometry &other ) const;
1153 
1158  QgsRectangle boundingBox() const;
1159 
1165  QgsBox3D boundingBox3D() const;
1166 
1177  QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
1178 
1187  QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
1188 
1196  QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
1197 
1202  QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
1203 
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 
1345  QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
1346 
1366  bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
1367 
1377  bool intersects( const QgsRectangle &rectangle ) const;
1378 
1393  bool intersects( const QgsGeometry &geometry ) const;
1394 
1403  bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
1404 
1413  bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
1414 
1418  bool contains( const QgsPointXY *p ) const;
1419 
1429  bool contains( const QgsGeometry &geometry ) const;
1430 
1440  bool disjoint( const QgsGeometry &geometry ) const;
1441 
1451  bool touches( const QgsGeometry &geometry ) const;
1452 
1462  bool overlaps( const QgsGeometry &geometry ) const;
1463 
1473  bool within( const QgsGeometry &geometry ) const;
1474 
1484  bool crosses( const QgsGeometry &geometry ) const;
1485 
1493  QgsGeometry buffer( double distance, int segments ) const;
1494 
1506  QgsGeometry buffer( double distance, int segments, Qgis::EndCapStyle endCapStyle, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1507 
1515  QgsGeometry offsetCurve( double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit ) const;
1516 
1531  QgsGeometry singleSidedBuffer( double distance, int segments, Qgis::BufferSide side,
1532  Qgis::JoinStyle joinStyle = Qgis::JoinStyle::Round,
1533  double miterLimit = 2.0 ) const;
1534 
1552  QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
1553 
1568  QgsGeometry variableWidthBufferByM( int segments ) const;
1569 
1575  QgsGeometry extendLine( double startDistance, double endDistance ) const;
1576 
1578  QgsGeometry simplify( double tolerance ) const;
1579 
1588  QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1589 
1603  QgsGeometry densifyByDistance( double distance ) const;
1604 
1620  QgsGeometry convertToCurves( double distanceTolerance = 1e-8, double angleTolerance = 1e-8 ) const;
1621 
1635  QgsGeometry centroid() const;
1636 
1650  QgsGeometry pointOnSurface() const;
1651 
1663  QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1664 
1688  QgsGeometry largestEmptyCircle( double tolerance, const QgsGeometry &boundary = QgsGeometry() ) const SIP_THROW( QgsNotSupportedException );
1689 
1704  QgsGeometry minimumWidth() const SIP_THROW( QgsNotSupportedException );
1705 
1727  double minimumClearance() const SIP_THROW( QgsNotSupportedException );
1728 
1740  QgsGeometry minimumClearanceLine() const SIP_THROW( QgsNotSupportedException );
1741 
1750  QgsGeometry convexHull() const;
1751 
1765  QgsGeometry concaveHull( double targetPercent, bool allowHoles = false ) const SIP_THROW( QgsNotSupportedException );
1766 
1781  QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1782 
1793  QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1794 
1807  QgsGeometry constrainedDelaunayTriangulation() const SIP_THROW( QgsNotSupportedException );
1808 
1826  Qgis::CoverageValidityResult validateCoverage( double gapWidth, QgsGeometry *invalidEdges SIP_OUT = nullptr ) const SIP_THROW( QgsNotSupportedException );
1827 
1848  QgsGeometry simplifyCoverageVW( double tolerance, bool preserveBoundary ) const SIP_THROW( QgsNotSupportedException );
1849 
1861  QgsGeometry unionCoverage() const;
1862 
1873  QgsGeometry node() const;
1874 
1889  QgsGeometry sharedPaths( const QgsGeometry &other ) const;
1890 
1912  QgsGeometry subdivide( int maxNodes = 256, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1913 
1928  QgsGeometry interpolate( double distance ) const;
1929 
1940  double lineLocatePoint( const QgsGeometry &point ) const;
1941 
1950  double interpolateAngle( double distance ) const;
1951 
1963  QgsGeometry intersection( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1964 
1971  QgsGeometry clipped( const QgsRectangle &rectangle );
1972 
1987  QgsGeometry combine( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
1988 
1996  QgsGeometry mergeLines() const;
1997 
2009  QgsGeometry difference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2010 
2022  QgsGeometry symDifference( const QgsGeometry &geometry, const QgsGeometryParameters &parameters = QgsGeometryParameters() ) const;
2023 
2025  QgsGeometry extrude( double x, double y );
2026 
2027 #ifndef SIP_RUN
2028 
2050  QVector< QgsPointXY > randomPointsInPolygon( int count, const std::function< bool( const QgsPointXY & ) > &acceptPoint, unsigned long seed = 0, QgsFeedback *feedback = nullptr, int maxTriesPerPoint = 0 ) const;
2051 
2065  QVector< QgsPointXY > randomPointsInPolygon( int count, unsigned long seed = 0, QgsFeedback *feedback = nullptr ) const;
2067 #else
2068 
2082  SIP_PYOBJECT randomPointsInPolygon( int count, unsigned long seed = 0 ) const SIP_TYPEHINT( QgsPolylineXY );
2083  % MethodCode
2084  const Qgis::GeometryType type = sipCpp->type();
2085  if ( sipCpp->isNull() )
2086  {
2087  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Cannot generate points inside a null geometry." ).toUtf8().constData() );
2088  sipIsErr = 1;
2089  }
2090  else if ( type != Qgis::GeometryType::Polygon )
2091  {
2092  PyErr_SetString( PyExc_TypeError, QStringLiteral( "Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg( QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2093  sipIsErr = 1;
2094  }
2095  else
2096  {
2097  const sipTypeDef *qvector_type = sipFindType( "QVector<QgsPointXY>" );
2098  sipRes = sipConvertFromNewType( new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2099  }
2100  % End
2101 
2102 
2103 #endif
2105 
2113  int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2114 
2121  QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
2122 
2128  QString asWkt( int precision = 17 ) const;
2129 
2130 #ifdef SIP_RUN
2131  SIP_PYOBJECT __repr__();
2132  % MethodCode
2133  QString str;
2134  if ( sipCpp->isNull() )
2135  str = QStringLiteral( "<QgsGeometry: null>" );
2136  else
2137  {
2138  QString wkt = sipCpp->asWkt();
2139  if ( wkt.length() > 1000 )
2140  wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
2141  str = QStringLiteral( "<QgsGeometry: %1>" ).arg( wkt );
2142  }
2143  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2144  % End
2145 #endif
2146 
2150  QString asJson( int precision = 17 ) const;
2151 
2157  virtual json asJsonObject( int precision = 17 ) const SIP_SKIP;
2158 
2185  QVector< QgsGeometry > coerceToType( Qgis::WkbType type, double defaultZ = 0, double defaultM = 0 ) const;
2186 
2198  QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
2199 
2200  /* Accessor functions for getting geometry data */
2201 
2202 #ifndef SIP_RUN
2203 
2212  QgsPointXY asPoint() const;
2213 #else
2214 
2225  SIP_PYOBJECT asPoint() const SIP_TYPEHINT( QgsPointXY );
2226  % MethodCode
2227  if ( sipCpp->isNull() )
2228  {
2229  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a point." ).toUtf8().constData() );
2230  sipIsErr = 1;
2231  }
2232  else
2233  {
2234  const QgsAbstractGeometry *geom = sipCpp->constGet();
2236  {
2237  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() );
2238  sipIsErr = 1;
2239  }
2240  else
2241  {
2242  sipRes = sipConvertFromNewType( new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2243  }
2244  }
2245  % End
2246 #endif
2247 
2248 #ifndef SIP_RUN
2249 
2258  QgsPolylineXY asPolyline() const;
2259 #else
2260 
2272  SIP_PYOBJECT asPolyline() const SIP_TYPEHINT( QgsPolylineXY );
2273  % MethodCode
2274  const Qgis::WkbType type = sipCpp->wkbType();
2275  if ( sipCpp->isNull() )
2276  {
2277  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2278  sipIsErr = 1;
2279  }
2281  {
2282  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() );
2283  sipIsErr = 1;
2284  }
2285  else
2286  {
2287  const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2288  sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2289  }
2290  % End
2291 #endif
2292 
2293 #ifndef SIP_RUN
2294 
2303  QgsPolygonXY asPolygon() const;
2304 #else
2305 
2317  SIP_PYOBJECT asPolygon() const SIP_TYPEHINT( QgsPolygonXY );
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 polygon." ).toUtf8().constData() );
2323  sipIsErr = 1;
2324  }
2326  {
2327  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() );
2328  sipIsErr = 1;
2329  }
2330  else
2331  {
2332  const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2333  sipRes = sipConvertFromNewType( new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2334  }
2335  % End
2336 #endif
2337 
2338 #ifndef SIP_RUN
2339 
2347  QgsMultiPointXY asMultiPoint() const;
2348 #else
2349 
2360  SIP_PYOBJECT asMultiPoint() const SIP_TYPEHINT( QgsMultiPointXY );
2361  % MethodCode
2362  const Qgis::WkbType type = sipCpp->wkbType();
2363  if ( sipCpp->isNull() )
2364  {
2365  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2366  sipIsErr = 1;
2367  }
2369  {
2370  PyErr_SetString( PyExc_TypeError, QStringLiteral( "%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg( QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2371  sipIsErr = 1;
2372  }
2373  else
2374  {
2375  const sipTypeDef *qvector_type = sipFindType( "QVector< QgsPointXY >" );
2376  sipRes = sipConvertFromNewType( new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2377  }
2378  % End
2379 #endif
2380 
2381 #ifndef SIP_RUN
2382 
2391  QgsMultiPolylineXY asMultiPolyline() const;
2392 #else
2393 
2405  SIP_PYOBJECT asMultiPolyline() const SIP_TYPEHINT( QgsMultiPolylineXY );
2406  % MethodCode
2407  const Qgis::WkbType type = sipCpp->wkbType();
2408  if ( sipCpp->isNull() )
2409  {
2410  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2411  sipIsErr = 1;
2412  }
2414  {
2415  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() );
2416  sipIsErr = 1;
2417  }
2418  else
2419  {
2420  const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QgsPointXY>>" );
2421  sipRes = sipConvertFromNewType( new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2422  }
2423  % End
2424 #endif
2425 
2426 #ifndef SIP_RUN
2427 
2436  QgsMultiPolygonXY asMultiPolygon() const;
2437 #else
2438 
2450  SIP_PYOBJECT asMultiPolygon() const SIP_TYPEHINT( QgsMultiPolygonXY );
2451  % MethodCode
2452  const Qgis::WkbType type = sipCpp->wkbType();
2453  if ( sipCpp->isNull() )
2454  {
2455  PyErr_SetString( PyExc_ValueError, QStringLiteral( "Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2456  sipIsErr = 1;
2457  }
2459  {
2460  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() );
2461  sipIsErr = 1;
2462  }
2463  else
2464  {
2465  const sipTypeDef *qvector_type = sipFindType( "QVector<QVector<QVector<QgsPointXY>>>" );
2466  sipRes = sipConvertFromNewType( new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2467  }
2468  % End
2469 #endif
2470 
2474  QVector<QgsGeometry> asGeometryCollection() const;
2475 
2480  QPointF asQPointF() const SIP_HOLDGIL;
2481 
2493  QPolygonF asQPolygonF() const SIP_HOLDGIL;
2494 
2500  bool deleteRing( int ringNum, int partNum = 0 );
2501 
2506  bool deletePart( int partNum );
2507 
2516  bool convertToMultiType();
2517 
2533  bool convertToCurvedMultiType();
2534 
2544  bool convertToSingleType();
2545 
2555  bool convertGeometryCollectionToSubclass( Qgis::GeometryType geomType );
2556 
2568  Q_DECL_DEPRECATED int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2569  const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) ) SIP_DEPRECATED;
2570 
2582  Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
2583  const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
2584 
2605  QgsGeometry makeValid( Qgis::MakeValidMethod method = Qgis::MakeValidMethod::Linework, bool keepCollapsed = false ) const SIP_THROW( QgsNotSupportedException );
2606 
2616  Qgis::AngularDirection polygonOrientation() const;
2617 
2631  bool isPolygonCounterClockwise() const { return polygonOrientation() == Qgis::AngularDirection::CounterClockwise; }
2632 
2646  bool isPolygonClockwise() const { return polygonOrientation() == Qgis::AngularDirection::Clockwise; }
2647 
2648 
2663  QgsGeometry forceRHR() const;
2664 
2675  QgsGeometry forcePolygonClockwise() const;
2676 
2687  QgsGeometry forcePolygonCounterClockwise() const;
2688 
2693  class CORE_EXPORT Error
2694  {
2695  public:
2697  : mMessage( QStringLiteral( "none" ) )
2698  {}
2699 
2700  explicit Error( const QString &m )
2701  : mMessage( m )
2702  {}
2703 
2704  Error( const QString &m, const QgsPointXY &p )
2705  : mMessage( m )
2706  , mLocation( p )
2707  , mHasLocation( true ) {}
2708 
2712  QString what() const;
2713 
2717  QgsPointXY where() const;
2718 
2722  bool hasWhere() const;
2723 
2724 #ifdef SIP_RUN
2725  SIP_PYOBJECT __repr__();
2726  % MethodCode
2727  QString str = QStringLiteral( "<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2728  sipRes = PyUnicode_FromString( str.toUtf8().data() );
2729  % End
2730 #endif
2731 
2732  // TODO c++20 - replace with = default
2733  bool operator==( const QgsGeometry::Error &other ) const
2734  {
2735  return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2736  }
2737 
2738  private:
2739  QString mMessage;
2740  QgsPointXY mLocation;
2741  bool mHasLocation = false;
2742  };
2743 
2751  void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, Qgis::GeometryValidationEngine method = Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
2752 
2762  void normalize();
2763 
2772  static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries, const QgsGeometryParameters &parameters = QgsGeometryParameters() );
2773 
2781  static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
2782 
2789  void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
2790 
2796  bool requiresConversionToStraightSegments() const;
2797 
2802  void mapToPixel( const QgsMapToPixel &mtp );
2803 
2808  void draw( QPainter &p ) const;
2809 
2819  bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
2820 
2831  int vertexNrFromVertexId( QgsVertexId id ) const;
2832 
2839  QString lastError() const SIP_HOLDGIL;
2840 
2850  void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
2851 
2866  void transformVertices( const std::function< QgsPoint( const QgsPoint & ) > &transform ) SIP_SKIP;
2867 
2872  static QgsGeometry fromQPointF( QPointF point ) SIP_HOLDGIL;
2873 
2880  static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2881 
2889  Q_DECL_DEPRECATED static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2890 
2898  Q_DECL_DEPRECATED static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_DEPRECATED;
2899 
2900 #ifndef SIP_RUN
2901 
2910  static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
2911  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2912 
2921  static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
2922  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2923 
2933  static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
2934  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2935 #else
2936 
2955  static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2956  % MethodCode
2957  {
2958  sipRes = false;
2959  int state0;
2960  int state1;
2961  int sipIsErr = 0;
2962 
2963  if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2964  PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2965  {
2966  PyObject *o0 = PyList_GetItem( a0, 0 );
2967  PyObject *o1 = PyList_GetItem( a1, 0 );
2968  if ( o0 && o1 )
2969  {
2970  // compare polyline - polyline
2971  if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2972  sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2973  sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2974  sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2975  {
2976  QgsPolylineXY *p0;
2977  QgsPolylineXY *p1;
2978  p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2979  p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2980  if ( sipIsErr )
2981  {
2982  sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2983  sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2984  }
2985  else
2986  {
2987  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
2988  }
2989  }
2990  else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2991  PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2992  {
2993  PyObject *oo0 = PyList_GetItem( o0, 0 );
2994  PyObject *oo1 = PyList_GetItem( o1, 0 );
2995  if ( oo0 && oo1 )
2996  {
2997  // compare polygon - polygon
2998  if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2999  sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3000  sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3001  sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3002  {
3003  QgsPolygonXY *p0;
3004  QgsPolygonXY *p1;
3005  p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3006  p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3007  if ( sipIsErr )
3008  {
3009  sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3010  sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3011  }
3012  else
3013  {
3014  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3015  }
3016  }
3017  else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3018  PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3019  {
3020  PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3021  PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3022  if ( ooo0 && ooo1 )
3023  {
3024  // compare multipolygon - multipolygon
3025  if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3026  sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3027  sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3028  sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3029  {
3030  QgsMultiPolygonXY *p0;
3031  QgsMultiPolygonXY *p1;
3032  p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3033  p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3034  if ( sipIsErr )
3035  {
3036  sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3037  sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3038  }
3039  else
3040  {
3041  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
3042  }
3043  }
3044  }
3045  }
3046  }
3047  }
3048  }
3049  }
3050  }
3051  % End
3052 #endif
3053 
3069  QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
3070  double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
3071 
3109  static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry, double precision = 0.0 ) SIP_FACTORY;
3110 
3116  static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
3117 
3123  static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
3124 
3126  operator QVariant() const
3127  {
3128  return QVariant::fromValue( *this );
3129  }
3130 
3131  private:
3132 
3133  QgsGeometryPrivate *d; //implicitly shared data pointer
3134 
3136  mutable QString mLastError;
3137 
3142  void detach();
3143 
3148  void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3149 
3150  static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
3151 
3153  QgsGeometry convertToPoint( bool destMultipart ) const;
3155  QgsGeometry convertToLine( bool destMultipart ) const;
3157  QgsGeometry convertToPolygon( bool destMultipart ) const;
3158 
3170  std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
3171  double minimumDistance = -1, double maxAngle = 180.0 ) const;
3172 
3184  std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
3185  double minimumDistance = -1, double maxAngle = 180.0 ) const;
3186 
3187 
3189 
3190 }; // class QgsGeometry
3191 
3193 
3194 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
3197 CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
3198 
3199 #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
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
Definition: qgis.h:1629
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
Indicates the direction (forward or inverse) of a transform.
Definition: qgis.h:2171
@ 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.
Definition: qgsexception.h:67
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.
Definition: qgsgeometry.h:109
double gridSize() const
Returns the grid size which will be used to snap vertices of a geometry.
Definition: qgsgeometry.h:122
void setGridSize(double size)
Sets the grid size which will be used to snap vertices of a geometry.
Definition: qgsgeometry.h:134
Java-style iterator for traversal of parts of a geometry.
A geometry error.
Definition: qgsgeometry.h:2694
Error(const QString &m)
Definition: qgsgeometry.h:2700
Error(const QString &m, const QgsPointXY &p)
Definition: qgsgeometry.h:2704
bool operator==(const QgsGeometry::Error &other) const
Definition: qgsgeometry.h:2733
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
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.
Definition: qgsgeometry.h:2646
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:118
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.
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)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Definition: qgswkbtypes.h:862
static bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:758
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.
Definition: qgswkbtypes.h:628
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:716
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:73
#define str(x)
Definition: qgis.cpp:38
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition: qgis.h:5700
#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
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:74
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:84
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
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:52
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
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