QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgssurface.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscurvepolygon.cpp
3  ---------------------
4  begin : August 2017
5  copyright : (C) 2017 by Martí Angelats i Ribera
6  email : marti dot angelats at psig dot cat
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 #include "qgssurface.h"
19 #include "qgspoint.h"
20 #include "qgspolygon.h"
21 #include "qgsgeos.h"
22 #include <memory>
23 
24 bool QgsSurface::isValid( QString &error, int flags ) const
25 {
26  if ( flags == 0 && mHasCachedValidity )
27  {
28  // use cached validity results
29  error = mValidityFailureReason;
30  return error.isEmpty();
31  }
32 
33  QgsGeos geos( this );
34  bool res = geos.isValid( &error, flags & QgsGeometry::FlagAllowSelfTouchingHoles, nullptr );
35  if ( flags == 0 )
36  {
37  mValidityFailureReason = !res ? error : QString();
38  mHasCachedValidity = true;
39  }
40  return res;
41 }
42 
44 {
46  mHasCachedValidity = false;
47  mValidityFailureReason.clear();
49 }
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
@ FlagAllowSelfTouchingHoles
Indicates that self-touching holes are permitted. OGC validity states that self-touching holes are NO...
Definition: qgsgeometry.h:369
Does vector analysis using the geos library and handles import, export, exception handling*.
Definition: qgsgeos.h:104
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsRectangle mBoundingBox
Definition: qgssurface.h:81
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
Definition: qgssurface.cpp:43
QString mValidityFailureReason
Definition: qgssurface.h:83
bool mHasCachedValidity
Definition: qgssurface.h:82
bool isValid(QString &error, int flags=0) const override
Checks validity of the geometry, and returns true if the geometry is valid.
Definition: qgssurface.cpp:24
Contains geos related utilities and functions.
Definition: qgsgeos.h:42