QGIS API Documentation 3.43.0-Master (3ee7834ace6)
qgssurface.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssurface.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 QGSSURFACE_H
19#define QGSSURFACE_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsabstractgeometry.h"
24#include "qgsbox3d.h"
25
26class QgsPolygon;
27
33class CORE_EXPORT QgsSurface: public QgsAbstractGeometry
34{
35 public:
36
37 QgsBox3D boundingBox3D() const override
38 {
39 if ( mBoundingBox.isNull() )
40 {
41 mBoundingBox = calculateBoundingBox3D();
42 }
43 return mBoundingBox;
44 }
45
46 bool isValid( QString &error SIP_OUT, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const override;
47
48
49#ifndef SIP_RUN
50
59 inline static const QgsSurface *cast( const QgsAbstractGeometry *geom )
60 {
61 if ( !geom )
62 return nullptr;
63
64 const Qgis::WkbType flatType = QgsWkbTypes::flatType( geom->wkbType() );
65 if ( flatType == Qgis::WkbType::CurvePolygon
66 || flatType == Qgis::WkbType::Polygon
67 || flatType == Qgis::WkbType::Triangle
69 || flatType == Qgis::WkbType::TIN )
70 return static_cast<const QgsSurface *>( geom );
71 return nullptr;
72 }
73
82 inline static QgsSurface *cast( QgsAbstractGeometry *geom )
83 {
84 if ( !geom )
85 return nullptr;
86
87 const Qgis::WkbType flatType = QgsWkbTypes::flatType( geom->wkbType() );
88 if ( flatType == Qgis::WkbType::CurvePolygon
89 || flatType == Qgis::WkbType::Polygon
90 || flatType == Qgis::WkbType::Triangle
92 || flatType == Qgis::WkbType::TIN )
93 return static_cast<QgsSurface *>( geom );
94 return nullptr;
95 }
96#endif
97 protected:
98
99 void clearCache() const override;
100
102 mutable bool mHasCachedValidity = false;
103 mutable QString mValidityFailureReason;
104};
105
106#endif // QGSSURFACE_H
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
Definition qgis.h:2038
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ Polygon
Polygon.
@ Triangle
Triangle.
@ CurvePolygon
CurvePolygon.
@ PolyhedralSurface
PolyhedralSurface.
Abstract base class for all geometries.
virtual QgsBox3D calculateBoundingBox3D() const
Calculates the minimal 3D bounding box for the geometry.
virtual bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const =0
Checks validity of the geometry, and returns true if the geometry is valid.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
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
Polygon geometry type.
Definition qgspolygon.h:33
Surface geometry type.
Definition qgssurface.h:34
QgsBox3D mBoundingBox
Definition qgssurface.h:101
static QgsSurface * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsSurface.
Definition qgssurface.h:82
QgsBox3D boundingBox3D() const override
Returns the 3D bounding box for the geometry.
Definition qgssurface.h:37
static const QgsSurface * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsSurface.
Definition qgssurface.h:59
QString mValidityFailureReason
Definition qgssurface.h:103
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define SIP_OUT
Definition qgis_sip.h:58