QGIS API Documentation  3.0.2-Girona (307d082)
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 <QDomDocument>
20 #include <QSet>
21 #include <QString>
22 #include <QVector>
23 
24 #include <geos_c.h>
25 #include <climits>
26 #include <limits>
27 #include <memory>
28 
29 #include "qgis_core.h"
30 #include "qgis.h"
31 
32 
33 #if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
34 #define GEOSGeometry struct GEOSGeom_t
35 #define GEOSCoordSequence struct GEOSCoordSeq_t
36 #endif
37 
38 #include "qgsabstractgeometry.h"
39 #include "qgsfeature.h"
40 #include "qgspointxy.h"
41 #include "qgspoint.h"
42 
43 
44 class QgsGeometryEngine;
45 class QgsVectorLayer;
46 class QgsMapToPixel;
47 class QPainter;
48 class QgsPolygon;
50 
60 typedef QVector<QgsPointXY> QgsPolylineXY;
61 
69 typedef QVector<QgsPoint> QgsPolyline;
70 
72 #ifndef SIP_RUN
73 typedef QVector<QgsPolylineXY> QgsPolygonXY;
74 #else
75 typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
76 #endif
77 
79 typedef QVector<QgsPointXY> QgsMultiPointXY;
80 
82 #ifndef SIP_RUN
83 typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
84 #else
85 typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
86 #endif
87 
89 #ifndef SIP_RUN
90 typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
91 #else
92 typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
93 #endif
94 
95 class QgsRectangle;
96 
97 class QgsConstWkbPtr;
98 
99 struct QgsGeometryPrivate;
100 
111 class CORE_EXPORT QgsGeometry
112 {
113  Q_GADGET
114  public:
115 
121  {
122  Success = 0,
123  NothingHappened = 1000,
130  /* Add part issues */
133  /* Add ring issues*/
138  /* Split features */
140  };
141 
143  QgsGeometry();
144 
146  QgsGeometry( const QgsGeometry & );
147 
152  QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
153 
159  explicit QgsGeometry( QgsAbstractGeometry *geom SIP_TRANSFER );
160 
166  explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
167 
168  ~QgsGeometry();
169 
181  const QgsAbstractGeometry *constGet() const;
182 
195  QgsAbstractGeometry *get();
196 
206  void set( QgsAbstractGeometry *geometry SIP_TRANSFER );
207 
215  bool isNull() const;
216 
218  static QgsGeometry fromWkt( const QString &wkt );
220  static QgsGeometry fromPointXY( const QgsPointXY &point );
222  static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
223 
235  static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
236 
246  static QgsGeometry fromPolyline( const QgsPolyline &polyline );
247 
249  static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
251  static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
253  static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
255  static QgsGeometry fromRect( const QgsRectangle &rect );
257  static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
258 
264  void fromGeos( GEOSGeometry *geos ) SIP_SKIP;
265 
271  void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
272 
277  void fromWkb( const QByteArray &wkb );
278 
285  GEOSGeometry *exportToGeos( double precision = 0 ) const SIP_SKIP;
286 
291  QgsWkbTypes::Type wkbType() const;
292 
297  QgsWkbTypes::GeometryType type() const;
298 
305  bool isEmpty() const;
306 
308  bool isMultipart() const;
309 
324  bool equals( const QgsGeometry &geometry ) const;
325 
342  bool isGeosEqual( const QgsGeometry & ) const;
343 
348  bool isGeosValid() const;
349 
358  bool isSimple() const;
359 
364  double area() const;
365 
370  double length() const;
371 
378  double distance( const QgsGeometry &geom ) const;
379 
380 #ifndef SIP_RUN
381 
386  QgsAbstractGeometry::vertex_iterator vertices_begin() const;
387 
392  QgsAbstractGeometry::vertex_iterator vertices_end() const;
393 #endif
394 
399  QgsVertexIterator vertices() const;
400 
418  double hausdorffDistance( const QgsGeometry &geom ) const;
419 
438  double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
439 
452  //TODO QGIS 3.0 - rename beforeVertex to previousVertex, afterVertex to nextVertex
453  QgsPointXY closestVertex( const QgsPointXY &point, int &atVertex SIP_OUT, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT, double &sqrDist SIP_OUT ) const;
454 
461  double distanceToVertex( int vertex ) const;
462 
470  double angleAtVertex( int vertex ) const;
471 
484  void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
485 
498  bool insertVertex( double x, double y, int beforeVertex );
499 
512  bool insertVertex( const QgsPoint &point, int beforeVertex );
513 
521  bool moveVertex( double x, double y, int atVertex );
522 
530  bool moveVertex( const QgsPoint &p, int atVertex );
531 
543  bool deleteVertex( int atVertex );
544 
550  QgsPoint vertexAt( int atVertex ) const;
551 
557  double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
558 
564  QgsGeometry nearestPoint( const QgsGeometry &other ) const;
565 
571  QgsGeometry shortestLine( const QgsGeometry &other ) const;
572 
579  double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
580 
592  double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &afterVertex SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
593 
599  OperationResult addRing( const QVector<QgsPointXY> &ring );
600 
606  OperationResult addRing( QgsCurve *ring SIP_TRANSFER );
607 
614  OperationResult addPart( const QVector<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) SIP_PYNAME( addPointsXY );
615 
623 
631 
638  OperationResult addPart( GEOSGeometry *newPart ) SIP_SKIP;
639 
645  OperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
646 
653  QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
654 
659  OperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
660 
675  OperationResult transform( const QgsCoordinateTransform &ct,
677  bool transformZ = false );
678 
687  OperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
688 
695  OperationResult rotate( double rotation, const QgsPointXY &center );
696 
705  OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QVector<QgsPointXY> &topologyTestPoints SIP_OUT );
706 
711  OperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
712 
718  int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
719 
727  QgsGeometry makeDifference( const QgsGeometry &other ) const;
728 
733  QgsRectangle boundingBox() const;
734 
742  QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
743 
749  QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
750 
758  QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
759 
765  QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
766 
775  QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
776 
789  QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
790 
811  bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );
812 
822  bool intersects( const QgsRectangle &rectangle ) const;
823 
833  bool intersects( const QgsGeometry &geometry ) const;
834 
844  bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
845 
855  bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
856 
858  bool contains( const QgsPointXY *p ) const;
859 
864  bool contains( const QgsGeometry &geometry ) const;
865 
870  bool disjoint( const QgsGeometry &geometry ) const;
871 
876  bool touches( const QgsGeometry &geometry ) const;
877 
882  bool overlaps( const QgsGeometry &geometry ) const;
883 
888  bool within( const QgsGeometry &geometry ) const;
889 
894  bool crosses( const QgsGeometry &geometry ) const;
895 
898  {
899  SideLeft = 0,
901  };
902  Q_ENUM( BufferSide );
903 
906  {
907  CapRound = 1,
910  };
911  Q_ENUM( EndCapStyle );
912 
915  {
916  JoinStyleRound = 1,
919  };
920  Q_ENUM( JoinStyle );
921 
926  QgsGeometry buffer( double distance, int segments ) const;
927 
937  QgsGeometry buffer( double distance, int segments, EndCapStyle endCapStyle, JoinStyle joinStyle, double miterLimit ) const;
938 
947  QgsGeometry offsetCurve( double distance, int segments, JoinStyle joinStyle, double miterLimit ) const;
948 
961  QgsGeometry singleSidedBuffer( double distance, int segments, BufferSide side,
962  JoinStyle joinStyle = JoinStyleRound,
963  double miterLimit = 2.0 ) const;
964 
971  QgsGeometry extendLine( double startDistance, double endDistance ) const;
972 
974  QgsGeometry simplify( double tolerance ) const;
975 
985  QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
986 
1001  QgsGeometry densifyByDistance( double distance ) const;
1002 
1016  QgsGeometry centroid() const;
1017 
1031  QgsGeometry pointOnSurface() const;
1032 
1045  QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1046 
1055  QgsGeometry convexHull() const;
1056 
1072  QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1073 
1083  QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1084 
1104  QgsGeometry subdivide( int maxNodes = 256 ) const;
1105 
1117  QgsGeometry interpolate( double distance ) const;
1118 
1130  double lineLocatePoint( const QgsGeometry &point ) const;
1131 
1141  double interpolateAngle( double distance ) const;
1142 
1151  QgsGeometry intersection( const QgsGeometry &geometry ) const;
1152 
1160  QgsGeometry clipped( const QgsRectangle &rectangle );
1161 
1173  QgsGeometry combine( const QgsGeometry &geometry ) const;
1174 
1183  QgsGeometry mergeLines() const;
1184 
1193  QgsGeometry difference( const QgsGeometry &geometry ) const;
1194 
1203  QgsGeometry symDifference( const QgsGeometry &geometry ) const;
1204 
1206  QgsGeometry extrude( double x, double y );
1207 
1212  QByteArray asWkb() const;
1213 
1219  QString asWkt( int precision = 17 ) const;
1220 
1224  QString asJson( int precision = 17 ) const;
1225 
1233  QgsGeometry convertToType( QgsWkbTypes::GeometryType destType, bool destMultipart = false ) const SIP_FACTORY;
1234 
1235  /* Accessor functions for getting geometry data */
1236 
1241  QgsPointXY asPoint() const;
1242 
1247  QgsPolylineXY asPolyline() const;
1248 
1253  QgsPolygonXY asPolygon() const;
1254 
1259  QgsMultiPointXY asMultiPoint() const;
1260 
1265  QgsMultiPolylineXY asMultiPolyline() const;
1266 
1271  QgsMultiPolygonXY asMultiPolygon() const;
1272 
1277  QVector<QgsGeometry> asGeometryCollection() const;
1278 
1284  QPointF asQPointF() const;
1285 
1292  QPolygonF asQPolygonF() const;
1293 
1300  bool deleteRing( int ringNum, int partNum = 0 );
1301 
1307  bool deletePart( int partNum );
1308 
1317  bool convertToMultiType();
1318 
1328  bool convertToSingleType();
1329 
1340  int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
1341  const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
1342 
1361  QgsGeometry makeValid() const;
1362 
1366  class CORE_EXPORT Error
1367  {
1368  QString message;
1369  QgsPointXY location;
1370  bool hasLocation = false;
1371 
1372  public:
1374  : message( QStringLiteral( "none" ) )
1375  {}
1376 
1377  explicit Error( const QString &m )
1378  : message( m )
1379  {}
1380 
1381  Error( const QString &m, const QgsPointXY &p )
1382  : message( m )
1383  , location( p )
1384  , hasLocation( true ) {}
1385 
1386  QString what() { return message; }
1387  QgsPointXY where() { return location; }
1388  bool hasWhere() { return hasLocation; }
1389  };
1390 
1396  {
1399  };
1400 
1407  void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, ValidationMethod method = ValidatorQgisInternal ) const;
1408 
1414  static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries );
1415 
1424  static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
1425 
1431  void convertToStraightSegment();
1432 
1439  bool requiresConversionToStraightSegments() const;
1440 
1446  void mapToPixel( const QgsMapToPixel &mtp );
1447 
1453  void draw( QPainter &p ) const;
1454 
1465  bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
1466 
1478  int vertexNrFromVertexId( QgsVertexId id ) const;
1479 
1487  QString lastError() const;
1488 
1494  static GEOSContextHandle_t getGEOSHandler() SIP_SKIP;
1495 
1501  static QgsGeometry fromQPointF( QPointF point );
1502 
1510  static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
1511 
1518  static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_FACTORY;
1519 
1526  static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_FACTORY;
1527 
1528 #ifndef SIP_RUN
1529 
1539  static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
1540  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1541 
1551  static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
1552  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1553 
1564  static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
1565  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1566 #else
1567 
1586  static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * DBL_EPSILON );
1587  % MethodCode
1588  {
1589  sipRes = false;
1590  int state0;
1591  int state1;
1592  int sipIsErr = 0;
1593 
1594  if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
1595  PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
1596  {
1597  PyObject *o0 = PyList_GetItem( a0, 0 );
1598  PyObject *o1 = PyList_GetItem( a1, 0 );
1599  if ( o0 && o1 )
1600  {
1601  // compare polyline - polyline
1602  if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1603  sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1604  sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1605  sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1606  {
1607  QgsPolylineXY *p0;
1608  QgsPolylineXY *p1;
1609  p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1610  p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1611  if ( sipIsErr )
1612  {
1613  sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
1614  sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
1615  }
1616  else
1617  {
1618  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1619  }
1620  }
1621  else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
1622  PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
1623  {
1624  PyObject *oo0 = PyList_GetItem( o0, 0 );
1625  PyObject *oo1 = PyList_GetItem( o1, 0 );
1626  if ( oo0 && oo1 )
1627  {
1628  // compare polygon - polygon
1629  if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1630  sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1631  sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1632  sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1633  {
1634  QgsPolygonXY *p0;
1635  QgsPolygonXY *p1;
1636  p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1637  p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1638  if ( sipIsErr )
1639  {
1640  sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
1641  sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
1642  }
1643  else
1644  {
1645  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1646  }
1647  }
1648  else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
1649  PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
1650  {
1651  PyObject *ooo0 = PyList_GetItem( oo0, 0 );
1652  PyObject *ooo1 = PyList_GetItem( oo1, 0 );
1653  if ( ooo0 && ooo1 )
1654  {
1655  // compare multipolygon - multipolygon
1656  if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1657  sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1658  sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1659  sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1660  {
1661  QgsMultiPolygonXY *p0;
1662  QgsMultiPolygonXY *p1;
1663  p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1664  p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1665  if ( sipIsErr )
1666  {
1667  sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
1668  sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
1669  }
1670  else
1671  {
1672  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1673  }
1674  }
1675  }
1676  }
1677  }
1678  }
1679  }
1680  }
1681  }
1682  % End
1683 #endif
1684 
1697  QgsGeometry smooth( const unsigned int iterations = 1, const double offset = 0.25,
1698  double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
1699 
1703  static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry ) SIP_FACTORY;
1704 
1710  static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
1711 
1717  static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
1718 
1720  operator QVariant() const
1721  {
1722  return QVariant::fromValue( *this );
1723  }
1724 
1730  operator bool() const;
1731 
1732  private:
1733 
1734  QgsGeometryPrivate *d; //implicitly shared data pointer
1735 
1737  mutable QString mLastError;
1738 
1743  void detach();
1744 
1749  void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
1750 
1751  static void convertToPolyline( const QgsPointSequence &input, QgsPolylineXY &output );
1752  static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
1753 
1755  QgsGeometry convertToPoint( bool destMultipart ) const;
1757  QgsGeometry convertToLine( bool destMultipart ) const;
1759  QgsGeometry convertToPolygon( bool destMultipart ) const;
1760 
1772  std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, const unsigned int iterations = 1, const double offset = 0.25,
1773  double minimumDistance = -1, double maxAngle = 180.0 ) const;
1774 
1786  std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, const unsigned int iterations = 1, const double offset = 0.25,
1787  double minimumDistance = -1, double maxAngle = 180.0 ) const;
1788 
1789 
1790 }; // class QgsGeometry
1791 
1793 
1794 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
1797 CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
1798 
1799 #endif
Geometry engine misses a method implemented or an error occurred in the geometry engine.
Definition: qgsgeometry.h:128
A rectangle specified with double values.
Definition: qgsrectangle.h:39
The input ring doesn&#39;t have any existing ring to fit into.
Definition: qgsgeometry.h:137
Java-style iterator for traversal of vertices of a geometry.
The source geometry is not multi.
Definition: qgsgeometry.h:132
Use GEOS validation methods.
Definition: qgsgeometry.h:1398
Error(const QString &m)
Definition: qgsgeometry.h:1377
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:40
A class to represent a 2D point.
Definition: qgspointxy.h:43
QVector< QgsPoint > QgsPolyline
Polyline as represented as a vector of points.
Definition: qgsgeometry.h:69
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:73
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:111
Use mitered joins.
Definition: qgsgeometry.h:917
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:79
EndCapStyle
End cap styles for buffers.
Definition: qgsgeometry.h:905
Q_DECLARE_METATYPE(QModelIndex)
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:120
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
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:90
Error(const QString &m, const QgsPointXY &p)
Definition: qgsgeometry.h:1381
#define SIP_IN
Definition: qgis_sip.h:56
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:83
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:36
Cannot edit layer.
Definition: qgsgeometry.h:129
The selected geometry cannot be found.
Definition: qgsgeometry.h:131
No features were selected.
Definition: qgsgeometry.h:126
More than one features were selected.
Definition: qgsgeometry.h:127
Utility class for identifying a unique vertex within a geometry.
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition: qgis.h:465
The input ring crosses existing rings (it is not disjoint)
Definition: qgsgeometry.h:136
#define SIP_SKIP
Definition: qgis_sip.h:119
QgsPointXY where()
Definition: qgsgeometry.h:1387
Use internal QgsGeometryValidator method.
Definition: qgsgeometry.h:1397
#define SIP_TRANSFER
Definition: qgis_sip.h:36
The input ring is not closed.
Definition: qgsgeometry.h:134
Square cap (extends past start/end of line by buffer distance)
Definition: qgsgeometry.h:909
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
#define SIP_FACTORY
Definition: qgis_sip.h:69
Abstract base class for all geometries.
The vertex_iterator class provides STL-style iterator for vertices.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
Contains geos related utilities and functions.
Definition: qgsgeos.h:36
BufferSide
Side of line to buffer.
Definition: qgsgeometry.h:897
QVector< QgsPoint > QgsPointSequence
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:137
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:139
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:49
The base geometry on which the operation is done is invalid or empty.
Definition: qgsgeometry.h:124
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
Definition: qgsgeometry.h:125
#define SIP_OUT
Definition: qgis_sip.h:51
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:41
ValidationMethod
Available methods for validating geometries.
Definition: qgsgeometry.h:1395
Buffer to right of line.
Definition: qgsgeometry.h:900
Class for doing transforms between two map coordinate systems.
The input ring is not valid.
Definition: qgsgeometry.h:135
qint64 QgsFeatureId
Definition: qgsfeature.h:37
Contains geometry relation and modification algorithms.
Use beveled joins.
Definition: qgsgeometry.h:918
Transform from source to destination CRS.
Polygon geometry type.
Definition: qgspolygon.h:31
JoinStyle
Join styles for buffers.
Definition: qgsgeometry.h:914
Flat cap (in line with start/end of line)
Definition: qgsgeometry.h:908
Represents a vector layer which manages a vector based data sets.
double ANALYSIS_EXPORT leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether &#39;thepoint&#39; is left or right of the line from &#39;p1&#39; to &#39;p2&#39;. Negativ values mean left a...
Definition: MathUtils.cpp:292
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.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:74