QGIS API Documentation  3.2.0-Bonn (bc43194)
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 <climits>
25 #include <limits>
26 #include <memory>
27 
28 #include "qgis_core.h"
29 #include "qgis.h"
30 
31 #include "qgsabstractgeometry.h"
32 #include "qgsfeature.h"
33 #include "qgspointxy.h"
34 #include "qgspoint.h"
35 
36 
37 class QgsGeometryEngine;
38 class QgsVectorLayer;
39 class QgsMapToPixel;
40 class QPainter;
41 class QgsPolygon;
43 
53 typedef QVector<QgsPointXY> QgsPolylineXY;
54 
62 typedef QVector<QgsPoint> QgsPolyline;
63 
65 #ifndef SIP_RUN
66 typedef QVector<QgsPolylineXY> QgsPolygonXY;
67 #else
68 typedef QVector<QVector<QgsPointXY>> QgsPolygonXY;
69 #endif
70 
72 typedef QVector<QgsPointXY> QgsMultiPointXY;
73 
75 #ifndef SIP_RUN
76 typedef QVector<QgsPolylineXY> QgsMultiPolylineXY;
77 #else
78 typedef QVector<QVector<QgsPointXY>> QgsMultiPolylineXY;
79 #endif
80 
82 #ifndef SIP_RUN
83 typedef QVector<QgsPolygonXY> QgsMultiPolygonXY;
84 #else
85 typedef QVector<QVector<QVector<QgsPointXY>>> QgsMultiPolygonXY;
86 #endif
87 
88 class QgsRectangle;
89 
90 class QgsConstWkbPtr;
91 
92 struct QgsGeometryPrivate;
93 
104 class CORE_EXPORT QgsGeometry
105 {
106  Q_GADGET
107  public:
108 
114  {
115  Success = 0,
116  NothingHappened = 1000,
123  /* Add part issues */
126  /* Add ring issues*/
131  /* Split features */
133  };
134 
136  QgsGeometry();
137 
139  QgsGeometry( const QgsGeometry & );
140 
145  QgsGeometry &operator=( QgsGeometry const &rhs ) SIP_SKIP;
146 
152  explicit QgsGeometry( QgsAbstractGeometry *geom SIP_TRANSFER );
153 
159  explicit QgsGeometry( std::unique_ptr< QgsAbstractGeometry > geom ) SIP_SKIP;
160 
161  ~QgsGeometry();
162 
174  const QgsAbstractGeometry *constGet() const;
175 
188  QgsAbstractGeometry *get();
189 
199  void set( QgsAbstractGeometry *geometry SIP_TRANSFER );
200 
208  bool isNull() const;
209 
211  static QgsGeometry fromWkt( const QString &wkt );
213  static QgsGeometry fromPointXY( const QgsPointXY &point );
215  static QgsGeometry fromMultiPointXY( const QgsMultiPointXY &multipoint );
216 
228  static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
229 
239  static QgsGeometry fromPolyline( const QgsPolyline &polyline );
240 
242  static QgsGeometry fromMultiPolylineXY( const QgsMultiPolylineXY &multiline );
244  static QgsGeometry fromPolygonXY( const QgsPolygonXY &polygon );
246  static QgsGeometry fromMultiPolygonXY( const QgsMultiPolygonXY &multipoly );
248  static QgsGeometry fromRect( const QgsRectangle &rect );
250  static QgsGeometry collectGeometry( const QVector<QgsGeometry> &geometries );
251 
267  static QgsGeometry createWedgeBuffer( const QgsPoint &center, double azimuth, double angularWidth,
268  double outerRadius, double innerRadius = 0 );
269 
275  void fromWkb( unsigned char *wkb, int length ) SIP_SKIP;
276 
281  void fromWkb( const QByteArray &wkb );
282 
287  QgsWkbTypes::Type wkbType() const;
288 
293  QgsWkbTypes::GeometryType type() const;
294 
301  bool isEmpty() const;
302 
304  bool isMultipart() const;
305 
320  bool equals( const QgsGeometry &geometry ) const;
321 
338  bool isGeosEqual( const QgsGeometry & ) const;
339 
344  bool isGeosValid() const;
345 
354  bool isSimple() const;
355 
360  double area() const;
361 
366  double length() const;
367 
374  double distance( const QgsGeometry &geom ) const;
375 
376 #ifndef SIP_RUN
377 
382  QgsAbstractGeometry::vertex_iterator vertices_begin() const;
383 
388  QgsAbstractGeometry::vertex_iterator vertices_end() const;
389 #endif
390 
395  QgsVertexIterator vertices() const;
396 
414  double hausdorffDistance( const QgsGeometry &geom ) const;
415 
434  double hausdorffDistanceDensify( const QgsGeometry &geom, double densifyFraction ) const;
435 
448  //TODO QGIS 3.0 - rename beforeVertex to previousVertex, afterVertex to nextVertex
449  QgsPointXY closestVertex( const QgsPointXY &point, int &atVertex SIP_OUT, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT, double &sqrDist SIP_OUT ) const;
450 
457  double distanceToVertex( int vertex ) const;
458 
466  double angleAtVertex( int vertex ) const;
467 
480  void adjacentVertices( int atVertex, int &beforeVertex SIP_OUT, int &afterVertex SIP_OUT ) const;
481 
494  bool insertVertex( double x, double y, int beforeVertex );
495 
508  bool insertVertex( const QgsPoint &point, int beforeVertex );
509 
517  bool moveVertex( double x, double y, int atVertex );
518 
526  bool moveVertex( const QgsPoint &p, int atVertex );
527 
539  bool deleteVertex( int atVertex );
540 
546  QgsPoint vertexAt( int atVertex ) const;
547 
553  double sqrDistToVertexAt( QgsPointXY &point SIP_IN, int atVertex ) const;
554 
560  QgsGeometry nearestPoint( const QgsGeometry &other ) const;
561 
567  QgsGeometry shortestLine( const QgsGeometry &other ) const;
568 
575  double closestVertexWithContext( const QgsPointXY &point, int &atVertex SIP_OUT ) const;
576 
588  double closestSegmentWithContext( const QgsPointXY &point, QgsPointXY &minDistPoint SIP_OUT, int &afterVertex SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
589 
595  OperationResult addRing( const QVector<QgsPointXY> &ring );
596 
602  OperationResult addRing( QgsCurve *ring SIP_TRANSFER );
603 
610  OperationResult addPart( const QVector<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) SIP_PYNAME( addPointsXY );
611 
619 
627 
633  OperationResult addPart( const QgsGeometry &newPart ) SIP_PYNAME( addPartGeometry );
634 
641  QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
642 
647  OperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
648 
664 
673  OperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
674 
681  OperationResult rotate( double rotation, const QgsPointXY &center );
682 
691  OperationResult splitGeometry( const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries SIP_OUT, bool topological, QVector<QgsPointXY> &topologyTestPoints SIP_OUT );
692 
697  OperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
698 
704  int makeDifferenceInPlace( const QgsGeometry &other ) SIP_SKIP;
705 
713  QgsGeometry makeDifference( const QgsGeometry &other ) const;
714 
719  QgsRectangle boundingBox() const;
720 
728  QgsGeometry orientedMinimumBoundingBox( double &area SIP_OUT, double &angle SIP_OUT, double &width SIP_OUT, double &height SIP_OUT ) const;
729 
735  QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
736 
744  QgsGeometry minimalEnclosingCircle( QgsPointXY &center SIP_OUT, double &radius SIP_OUT, unsigned int segments = 36 ) const;
745 
751  QgsGeometry minimalEnclosingCircle( unsigned int segments = 36 ) const SIP_SKIP;
752 
761  QgsGeometry orthogonalize( double tolerance = 1.0E-8, int maxIterations = 1000, double angleThreshold = 15.0 ) const;
762 
775  QgsGeometry snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const;
776 
797  bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );
798 
808  bool intersects( const QgsRectangle &rectangle ) const;
809 
819  bool intersects( const QgsGeometry &geometry ) const;
820 
830  bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
831 
841  bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
842 
844  bool contains( const QgsPointXY *p ) const;
845 
850  bool contains( const QgsGeometry &geometry ) const;
851 
856  bool disjoint( const QgsGeometry &geometry ) const;
857 
862  bool touches( const QgsGeometry &geometry ) const;
863 
868  bool overlaps( const QgsGeometry &geometry ) const;
869 
874  bool within( const QgsGeometry &geometry ) const;
875 
880  bool crosses( const QgsGeometry &geometry ) const;
881 
884  {
885  SideLeft = 0,
887  };
888  Q_ENUM( BufferSide )
889 
890 
892  {
893  CapRound = 1,
896  };
897  Q_ENUM( EndCapStyle )
898 
899 
901  {
902  JoinStyleRound = 1,
905  };
906  Q_ENUM( JoinStyle )
907 
908 
915  QgsGeometry buffer( double distance, int segments ) const;
916 
929  QgsGeometry buffer( double distance, int segments, EndCapStyle endCapStyle, JoinStyle joinStyle, double miterLimit ) const;
930 
939  QgsGeometry offsetCurve( double distance, int segments, JoinStyle joinStyle, double miterLimit ) const;
940 
956  QgsGeometry singleSidedBuffer( double distance, int segments, BufferSide side,
957  JoinStyle joinStyle = JoinStyleRound,
958  double miterLimit = 2.0 ) const;
959 
977  QgsGeometry taperedBuffer( double startWidth, double endWidth, int segments ) const;
978 
993  QgsGeometry variableWidthBufferByM( int segments ) const;
994 
1001  QgsGeometry extendLine( double startDistance, double endDistance ) const;
1002 
1004  QgsGeometry simplify( double tolerance ) const;
1005 
1015  QgsGeometry densifyByCount( int extraNodesPerSegment ) const;
1016 
1031  QgsGeometry densifyByDistance( double distance ) const;
1032 
1046  QgsGeometry centroid() const;
1047 
1061  QgsGeometry pointOnSurface() const;
1062 
1075  QgsGeometry poleOfInaccessibility( double precision, double *distanceToBoundary SIP_OUT = nullptr ) const;
1076 
1085  QgsGeometry convexHull() const;
1086 
1102  QgsGeometry voronoiDiagram( const QgsGeometry &extent = QgsGeometry(), double tolerance = 0.0, bool edgesOnly = false ) const;
1103 
1113  QgsGeometry delaunayTriangulation( double tolerance = 0.0, bool edgesOnly = false ) const;
1114 
1134  QgsGeometry subdivide( int maxNodes = 256 ) const;
1135 
1147  QgsGeometry interpolate( double distance ) const;
1148 
1160  double lineLocatePoint( const QgsGeometry &point ) const;
1161 
1171  double interpolateAngle( double distance ) const;
1172 
1181  QgsGeometry intersection( const QgsGeometry &geometry ) const;
1182 
1190  QgsGeometry clipped( const QgsRectangle &rectangle );
1191 
1203  QgsGeometry combine( const QgsGeometry &geometry ) const;
1204 
1213  QgsGeometry mergeLines() const;
1214 
1223  QgsGeometry difference( const QgsGeometry &geometry ) const;
1224 
1233  QgsGeometry symDifference( const QgsGeometry &geometry ) const;
1234 
1236  QgsGeometry extrude( double x, double y );
1237 
1242  QByteArray asWkb() const;
1243 
1249  QString asWkt( int precision = 17 ) const;
1250 
1251 #ifdef SIP_RUN
1252  SIP_PYOBJECT __repr__();
1253  % MethodCode
1254  QString str = QStringLiteral( "<QgsGeometry: %1>" ).arg( sipCpp->asWkt() );
1255  sipRes = PyUnicode_FromString( str.toUtf8().data() );
1256  % End
1257 #endif
1258 
1262  QString asJson( int precision = 17 ) const;
1263 
1271  QgsGeometry convertToType( QgsWkbTypes::GeometryType destType, bool destMultipart = false ) const SIP_FACTORY;
1272 
1273  /* Accessor functions for getting geometry data */
1274 
1279  QgsPointXY asPoint() const;
1280 
1285  QgsPolylineXY asPolyline() const;
1286 
1291  QgsPolygonXY asPolygon() const;
1292 
1297  QgsMultiPointXY asMultiPoint() const;
1298 
1303  QgsMultiPolylineXY asMultiPolyline() const;
1304 
1309  QgsMultiPolygonXY asMultiPolygon() const;
1310 
1315  QVector<QgsGeometry> asGeometryCollection() const;
1316 
1322  QPointF asQPointF() const;
1323 
1330  QPolygonF asQPolygonF() const;
1331 
1338  bool deleteRing( int ringNum, int partNum = 0 );
1339 
1345  bool deletePart( int partNum );
1346 
1355  bool convertToMultiType();
1356 
1366  bool convertToSingleType();
1367 
1377  bool convertGeometryCollectionToSubclass( QgsWkbTypes::GeometryType geomType );
1378 
1389  int avoidIntersections( const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
1390  const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures SIP_PYARGREMOVE = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
1391 
1410  QgsGeometry makeValid() const;
1411 
1415  class CORE_EXPORT Error
1416  {
1417  QString message;
1418  QgsPointXY location;
1419  bool hasLocation = false;
1420 
1421  public:
1423  : message( QStringLiteral( "none" ) )
1424  {}
1425 
1426  explicit Error( const QString &m )
1427  : message( m )
1428  {}
1429 
1430  Error( const QString &m, const QgsPointXY &p )
1431  : message( m )
1432  , location( p )
1433  , hasLocation( true ) {}
1434 
1435  QString what() { return message; }
1436  QgsPointXY where() { return location; }
1437  bool hasWhere() { return hasLocation; }
1438  };
1439 
1445  {
1448  };
1449 
1456  void validateGeometry( QVector<QgsGeometry::Error> &errors SIP_OUT, ValidationMethod method = ValidatorQgisInternal ) const;
1457 
1463  static QgsGeometry unaryUnion( const QVector<QgsGeometry> &geometries );
1464 
1473  static QgsGeometry polygonize( const QVector<QgsGeometry> &geometries );
1474 
1482  void convertToStraightSegment( double tolerance = M_PI / 180., QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle );
1483 
1490  bool requiresConversionToStraightSegments() const;
1491 
1497  void mapToPixel( const QgsMapToPixel &mtp );
1498 
1504  void draw( QPainter &p ) const;
1505 
1516  bool vertexIdFromVertexNr( int number, QgsVertexId &id SIP_OUT ) const;
1517 
1529  int vertexNrFromVertexId( QgsVertexId id ) const;
1530 
1538  QString lastError() const;
1539 
1549  void filterVertices( const std::function< bool( const QgsPoint & ) > &filter ) SIP_SKIP;
1550 
1556  static QgsGeometry fromQPointF( QPointF point );
1557 
1565  static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
1566 
1573  static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) SIP_FACTORY;
1574 
1581  static QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_FACTORY;
1582 
1583 #ifndef SIP_RUN
1584 
1594  static bool compare( const QgsPolylineXY &p1, const QgsPolylineXY &p2,
1595  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1596 
1606  static bool compare( const QgsPolygonXY &p1, const QgsPolygonXY &p2,
1607  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1608 
1619  static bool compare( const QgsMultiPolygonXY &p1, const QgsMultiPolygonXY &p2,
1620  double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1621 #else
1622 
1641  static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1642  % MethodCode
1643  {
1644  sipRes = false;
1645  int state0;
1646  int state1;
1647  int sipIsErr = 0;
1648 
1649  if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
1650  PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
1651  {
1652  PyObject *o0 = PyList_GetItem( a0, 0 );
1653  PyObject *o1 = PyList_GetItem( a1, 0 );
1654  if ( o0 && o1 )
1655  {
1656  // compare polyline - polyline
1657  if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1658  sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1659  sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1660  sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1661  {
1662  QgsPolylineXY *p0;
1663  QgsPolylineXY *p1;
1664  p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1665  p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1666  if ( sipIsErr )
1667  {
1668  sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
1669  sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
1670  }
1671  else
1672  {
1673  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1674  }
1675  }
1676  else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
1677  PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
1678  {
1679  PyObject *oo0 = PyList_GetItem( o0, 0 );
1680  PyObject *oo1 = PyList_GetItem( o1, 0 );
1681  if ( oo0 && oo1 )
1682  {
1683  // compare polygon - polygon
1684  if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1685  sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1686  sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1687  sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1688  {
1689  QgsPolygonXY *p0;
1690  QgsPolygonXY *p1;
1691  p0 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1692  p1 = reinterpret_cast<QgsPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1693  if ( sipIsErr )
1694  {
1695  sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
1696  sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
1697  }
1698  else
1699  {
1700  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1701  }
1702  }
1703  else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
1704  PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
1705  {
1706  PyObject *ooo0 = PyList_GetItem( oo0, 0 );
1707  PyObject *ooo1 = PyList_GetItem( oo1, 0 );
1708  if ( ooo0 && ooo1 )
1709  {
1710  // compare multipolygon - multipolygon
1711  if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1712  sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1713  sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1714  sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1715  {
1716  QgsMultiPolygonXY *p0;
1717  QgsMultiPolygonXY *p1;
1718  p0 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1719  p1 = reinterpret_cast<QgsMultiPolygonXY *>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1720  if ( sipIsErr )
1721  {
1722  sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
1723  sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
1724  }
1725  else
1726  {
1727  sipRes = QgsGeometry::compare( *p0, *p1, a2 );
1728  }
1729  }
1730  }
1731  }
1732  }
1733  }
1734  }
1735  }
1736  }
1737  % End
1738 #endif
1739 
1756  QgsGeometry smooth( unsigned int iterations = 1, double offset = 0.25,
1757  double minimumDistance = -1.0, double maxAngle = 180.0 ) const;
1758 
1762  static QgsGeometryEngine *createGeometryEngine( const QgsAbstractGeometry *geometry ) SIP_FACTORY;
1763 
1769  static void convertPointList( const QVector<QgsPointXY> &input, QgsPointSequence &output );
1770 
1776  static void convertPointList( const QgsPointSequence &input, QVector<QgsPointXY> &output );
1777 
1779  operator QVariant() const
1780  {
1781  return QVariant::fromValue( *this );
1782  }
1783 
1789  operator bool() const;
1790 
1791  private:
1792 
1793  QgsGeometryPrivate *d; //implicitly shared data pointer
1794 
1796  mutable QString mLastError;
1797 
1802  void detach();
1803 
1808  void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
1809 
1810  static void convertToPolyline( const QgsPointSequence &input, QgsPolylineXY &output );
1811  static void convertPolygon( const QgsPolygon &input, QgsPolygonXY &output );
1812 
1814  QgsGeometry convertToPoint( bool destMultipart ) const;
1816  QgsGeometry convertToLine( bool destMultipart ) const;
1818  QgsGeometry convertToPolygon( bool destMultipart ) const;
1819 
1831  std::unique_ptr< QgsLineString > smoothLine( const QgsLineString &line, unsigned int iterations = 1, double offset = 0.25,
1832  double minimumDistance = -1, double maxAngle = 180.0 ) const;
1833 
1845  std::unique_ptr< QgsPolygon > smoothPolygon( const QgsPolygon &polygon, unsigned int iterations = 1, double offset = 0.25,
1846  double minimumDistance = -1, double maxAngle = 180.0 ) const;
1847 
1848 
1850 
1851 }; // class QgsGeometry
1852 
1854 
1855 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
1858 CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
1859 
1860 #endif
Geometry engine misses a method implemented or an error occurred in the geometry engine.
Definition: qgsgeometry.h:121
A rectangle specified with double values.
Definition: qgsrectangle.h:40
The input ring doesn&#39;t have any existing ring to fit into.
Definition: qgsgeometry.h:130
Java-style iterator for traversal of vertices of a geometry.
The source geometry is not multi.
Definition: qgsgeometry.h:125
Maximum angle between generating radii (lines from arc center to output vertices) ...
Use GEOS validation methods.
Definition: qgsgeometry.h:1447
Error(const QString &m)
Definition: qgsgeometry.h:1426
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:62
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:66
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:104
Use mitered joins.
Definition: qgsgeometry.h:903
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:72
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
EndCapStyle
End cap styles for buffers.
Definition: qgsgeometry.h:891
Q_DECLARE_METATYPE(QModelIndex)
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:113
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:83
Error(const QString &m, const QgsPointXY &p)
Definition: qgsgeometry.h:1430
#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:76
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:122
The selected geometry cannot be found.
Definition: qgsgeometry.h:124
No features were selected.
Definition: qgsgeometry.h:119
More than one features were selected.
Definition: qgsgeometry.h:120
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:67
Utility class for identifying a unique vertex within a geometry.
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
Definition: qgis.h:487
The input ring crosses existing rings (it is not disjoint)
Definition: qgsgeometry.h:129
#define SIP_SKIP
Definition: qgis_sip.h:119
QgsPointXY where()
Definition: qgsgeometry.h:1436
Use internal QgsGeometryValidator method.
Definition: qgsgeometry.h:1446
#define SIP_TRANSFER
Definition: qgis_sip.h:36
The input ring is not closed.
Definition: qgsgeometry.h:127
Square cap (extends past start/end of line by buffer distance)
Definition: qgsgeometry.h:895
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
This class offers geometry processing methods.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
BufferSide
Side of line to buffer.
Definition: qgsgeometry.h:883
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:42
The base geometry on which the operation is done is invalid or empty.
Definition: qgsgeometry.h:117
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
Definition: qgsgeometry.h:118
#define SIP_OUT
Definition: qgis_sip.h:51
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:43
ValidationMethod
Available methods for validating geometries.
Definition: qgsgeometry.h:1444
Buffer to right of line.
Definition: qgsgeometry.h:886
Class for doing transforms between two map coordinate systems.
The input ring is not valid.
Definition: qgsgeometry.h:128
qint64 QgsFeatureId
Definition: qgsfeature.h:37
#define SIP_THROW(name)
Definition: qgis_sip.h:177
Contains geometry relation and modification algorithms.
Use beveled joins.
Definition: qgsgeometry.h:904
Transform from source to destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
Polygon geometry type.
Definition: qgspolygon.h:31
JoinStyle
Join styles for buffers.
Definition: qgsgeometry.h:900
Flat cap (in line with start/end of line)
Definition: qgsgeometry.h:894
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