QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsgeometrytypecheck.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometrytypecheck.h
3  ---------------------
4  begin : September 2015
5  copyright : (C) 2014 by Sandro Mani / Sourcepole AG
6  email : smani at sourcepole dot ch
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 #define SIP_NO_FILE
17 
18 #ifndef QGS_GEOMETRY_TYPE_CHECK_H
19 #define QGS_GEOMETRY_TYPE_CHECK_H
20 
21 #include "qgssinglegeometrycheck.h"
22 
27 {
28  public:
30  const QgsGeometry &geometry,
31  const QgsGeometry &errorLocation,
32  QgsWkbTypes::Type flatType )
33  : QgsSingleGeometryCheckError( check, geometry, errorLocation )
34  , mFlatType( flatType )
35  {
36  }
37 
38  bool isEqual( const QgsSingleGeometryCheckError *other ) const override;
39 
40  QString description() const override;
41 
42  private:
43  QgsWkbTypes::Type mFlatType;
44 };
45 
49 class ANALYSIS_EXPORT QgsGeometryTypeCheck : public QgsSingleGeometryCheck
50 {
51  Q_DECLARE_TR_FUNCTIONS( QgsGeometryTypeCheck )
52  public:
53  QgsGeometryTypeCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes )
54  : QgsSingleGeometryCheck( context, configuration )
55  , mAllowedTypes( allowedTypes )
56  {}
57  QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
58  QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const override;
59  void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
60  Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
61  QString description() const override;
62  QString id() const override;
63  QgsGeometryCheck::CheckType checkType() const override;
64 
66  static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
67  static QString factoryDescription() SIP_SKIP;
68  static QString factoryId() SIP_SKIP;
69  static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
70 
71  private:
72  enum ResolutionMethod { Convert, Delete, NoChange };
73  int mAllowedTypes;
74 };
75 
76 #endif // QGS_GEOMETRY_TYPE_CHECK_H
QgsGeometryCheck::description
virtual QString description() const =0
Returns a human readable description for this check.
QgsGeometryTypeCheckError::QgsGeometryTypeCheckError
QgsGeometryTypeCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, QgsWkbTypes::Type flatType)
Definition: qgsgeometrytypecheck.h:29
QgsGeometryTypeCheck
Definition: qgsgeometrytypecheck.h:50
QgsGeometryTypeCheck::factoryCompatibleGeometryTypes
static QList< QgsWkbTypes::GeometryType > factoryCompatibleGeometryTypes()
Definition: qgsgeometrytypecheck.h:65
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QgsGeometryCheck::resolutionMethods
virtual Q_DECL_DEPRECATED QStringList resolutionMethods() const
Returns a list of descriptions for available resolutions for errors.
Definition: qgsgeometrycheck.cpp:77
QgsSingleGeometryCheckError
An error from a QgsSingleGeometryCheck.
Definition: qgssinglegeometrycheck.h:40
QgsGeometryTypeCheck::QgsGeometryTypeCheck
QgsGeometryTypeCheck(QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes)
Definition: qgsgeometrytypecheck.h:53
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
QgsSingleGeometryCheck::processGeometry
virtual QList< QgsSingleGeometryCheckError * > processGeometry(const QgsGeometry &geometry) const =0
Check the geometry for errors.
QgsSingleGeometryCheckError::description
virtual QString description() const
A human readable description of this error.
Definition: qgssinglegeometrycheck.cpp:64
QgsSingleGeometryCheck
Base class for geometry checks for a single geometry without any context of the layer or other layers...
Definition: qgssinglegeometrycheck.h:150
QgsGeometryCheck
This class implements a geometry check.
Definition: qgsgeometrycheck.h:92
QgsGeometryCheck::fixError
virtual void fixError(const QMap< QString, QgsFeaturePool * > &featurePools, QgsGeometryCheckError *error, int method, const QMap< QString, int > &mergeAttributeIndices, Changes &changes) const
Fixes the error error with the specified method.
Definition: qgsgeometrycheck.cpp:50
QgsGeometryCheck::id
virtual QString id() const =0
Returns an id for this check.
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsGeometryCheck::checkType
virtual CheckType checkType() const =0
Returns the check type.
QgsGeometryCheckContext
Base configuration for geometry checks.
Definition: qgsgeometrycheckcontext.h:32
QgsSingleGeometryCheckError::isEqual
virtual bool isEqual(const QgsSingleGeometryCheckError *other) const
Check if this error is equal to other.
Definition: qgssinglegeometrycheck.cpp:50
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsGeometryTypeCheckError
Definition: qgsgeometrytypecheck.h:27
QgsGeometryCheck::CheckType
CheckType
The type of a check.
Definition: qgsgeometrycheck.h:155
QgsGeometryTypeCheck::compatibleGeometryTypes
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
Definition: qgsgeometrytypecheck.h:57
qgssinglegeometrycheck.h
QgsGeometryCheckError
This represents an error reported by a geometry check.
Definition: qgsgeometrycheckerror.h:36
QgsGeometryTypeCheck::factoryIsCompatible
static bool factoryIsCompatible(QgsVectorLayer *layer)
Definition: qgsgeometrytypecheck.h:66