QGIS API Documentation  3.2.0-Bonn (bc43194)
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 str = QStringLiteral( "<QgsPolygon: %1>" ).arg( sipCpp->asWkt() );
91  sipRes = PyUnicode_FromString( str.toUtf8().data() );
92  % End
93 #endif
94 
95  protected:
96 
97  friend class QgsCurvePolygon;
98 
99 };
100 #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.
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.
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:67
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.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
const QgsPolygon * cast(const QgsAbstractGeometry *geom) const
Cast the geom to a QgsPolygonV2.
Definition: qgspolygon.h:71
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:427