QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgspolygon.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspolygon.h
3  -------------------
4  begin : September 2014
5  copyright : (C) 2014 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPOLYGONV2_H
19 #define QGSPOLYGONV2_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgscurvepolygon.h"
24 
31 class CORE_EXPORT QgsPolygon: public QgsCurvePolygon
32 {
33  public:
34  QgsPolygon();
35 
36  QString geometryType() const override;
37  QgsPolygon *clone() const override SIP_FACTORY;
38  void clear() override;
39  bool fromWkb( QgsConstWkbPtr &wkb ) override;
40  QByteArray asWkb() const override;
41  QgsPolygon *surfaceToPolygon() const override SIP_FACTORY;
42 
46  QgsCurvePolygon *toCurveType() const override SIP_FACTORY;
47 
48  void addInteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
49  //overridden to handle LineString25D rings
50  void setExteriorRing( QgsCurve *ring SIP_TRANSFER ) override;
51 
52  QgsAbstractGeometry *boundary() const override SIP_FACTORY;
53 
60  double pointDistanceToBoundary( double x, double y ) const;
61 
62 #ifndef SIP_RUN
63 
71  inline const QgsPolygon *cast( const QgsAbstractGeometry *geom ) const
72  {
73  if ( !geom )
74  return nullptr;
75 
76  QgsWkbTypes::Type flatType = QgsWkbTypes::flatType( geom->wkbType() );
77 
78  if ( flatType == QgsWkbTypes::Polygon
79  || flatType == QgsWkbTypes::Triangle )
80  return static_cast<const QgsPolygon *>( geom );
81  return nullptr;
82  }
83 #endif
84 
86 
87 #ifdef SIP_RUN
88  SIP_PYOBJECT __repr__();
89  % MethodCode
90  QString wkt = sipCpp->asWkt();
91  if ( wkt.length() > 1000 )
92  wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
93  QString str = QStringLiteral( "<QgsPolygon: %1>" ).arg( wkt );
94  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
95  % End
96 #endif
97 
98  protected:
99 
100  friend class QgsCurvePolygon;
101 
102 };
103 #endif // QGSPOLYGONV2_H
QByteArray asWkb() const override
Returns a WKB representation of the geometry.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
const QgsPolygon * cast(const QgsAbstractGeometry *geom) const
Cast the geom to a QgsPolygonV2.
Definition: qgspolygon.h:71
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Curve polygon geometry type.
void clear() override
Clears the geometry, ie reset it to a null geometry.
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsCurvePolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
QString geometryType() const override
Returns a unique string representing the geometry type.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
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.
QgsCurvePolygon * clone() const override
Clones the geometry by performing a deep copy.
Polygon geometry type.
Definition: qgspolygon.h:31
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:565