QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsgeometryoverlapcheck.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometryoverlapcheck.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_OVERLAP_CHECK_H
19 #define QGS_GEOMETRY_OVERLAP_CHECK_H
20 
21 #include "qgsgeometrycheck.h"
22 #include "qgsgeometrycheckerror.h"
23 
31 {
32  public:
33 
35  {
36  public:
38  : mLayerId( vl->id() )
39  , mLayerName( vl->name() )
40  , mFeatureId( fid )
41  {}
42 
43  QString layerId() const {return mLayerId;}
44  QString layerName() const {return mLayerName;}
45  QgsFeatureId featureId() const {return mFeatureId;}
46  bool operator==( const OverlappedFeature &other ) const {return mLayerId == other.layerId() && mFeatureId == other.featureId();}
47 
48  private:
49  QString mLayerId;
50  QString mLayerName;
51  QgsFeatureId mFeatureId;
52  };
53 
61  const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
62  const QgsGeometry &geometry,
63  const QgsPointXY &errorLocation,
64  const QVariant &value,
65  const QgsGeometryCheckerUtils::LayerFeature &overlappedFeature );
66 
70  const OverlappedFeature &overlappedFeature() const { return mOverlappedFeature; }
71 
72  bool isEqual( QgsGeometryCheckError *other ) const override;
73 
74  bool closeMatch( QgsGeometryCheckError *other ) const override;
75 
76  bool handleChanges( const QgsGeometryCheck::Changes &changes ) override;
77 
78  QString description() const override;
79 
80  QMap<QString, QgsFeatureIds > involvedFeatures() const override;
81  QIcon icon() const override;
82 
83  private:
84  OverlappedFeature mOverlappedFeature;
85 };
86 
93 class ANALYSIS_EXPORT QgsGeometryOverlapCheck : public QgsGeometryCheck
94 {
95  public:
96 
101  {
103  NoChange
104  };
105 
114  QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
115  QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
116  void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
117  void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
118  Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
119 
120  QString description() const override;
121  QString id() const override;
122  QgsGeometryCheck::Flags flags() const override;
123  QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
124 
126  static QString factoryDescription() SIP_SKIP;
127  static QString factoryId() SIP_SKIP;
128  static QgsGeometryCheck::Flags factoryFlags() SIP_SKIP;
129  static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() SIP_SKIP;
130  static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP;
131  static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
133 
134  private:
135  const double mOverlapThresholdMapUnits;
136 
137 };
138 
139 #endif // QGS_GEOMETRY_OVERLAP_CHECK_H
QgsGeometryOverlapCheck::Subtract
@ Subtract
Subtract the overlap region from the polygon.
Definition: qgsgeometryoverlapcheck.h:102
QgsGeometryCheckError::closeMatch
virtual bool closeMatch(QgsGeometryCheckError *) const
Check if this error is almost equal to other.
Definition: qgsgeometrycheckerror.cpp:123
QgsGeometryCheck::Changes
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
Definition: qgsgeometrycheck.h:214
QgsGeometryCheck::description
virtual QString description() const =0
Returns a human readable description for this check.
QgsGeometryOverlapCheckError::OverlappedFeature::layerName
QString layerName() const
Definition: qgsgeometryoverlapcheck.h:44
QgsGeometryOverlapCheck::compatibleGeometryTypes
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
Definition: qgsgeometryoverlapcheck.h:115
QgsGeometryCheck::resolutionMethods
virtual Q_DECL_DEPRECATED QStringList resolutionMethods() const
Returns a list of descriptions for available resolutions for errors.
Definition: qgsgeometrycheck.cpp:77
qgsgeometrycheckerror.h
QgsGeometryCheck::collectErrors
virtual void collectErrors(const QMap< QString, QgsFeaturePool * > &featurePools, QList< QgsGeometryCheckError * > &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids=QgsGeometryCheck::LayerFeatureIds()) const =0
The main worker method.
QgsGeometryOverlapCheckError::OverlappedFeature::layerId
QString layerId() const
Definition: qgsgeometryoverlapcheck.h:43
QgsGeometryCheck
Definition: qgsgeometrycheck.h:91
QgsGeometryCheck::flags
virtual QgsGeometryCheck::Flags flags() const
Flags for this geometry check.
Definition: qgsgeometrycheck.cpp:45
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
QgsGeometryOverlapCheckError::OverlappedFeature
Definition: qgsgeometryoverlapcheck.h:34
qgsgeometrycheck.h
QgsGeometryCheckError::handleChanges
virtual bool handleChanges(const QgsGeometryCheck::Changes &changes)
Apply a list of changes.
Definition: qgsgeometrycheckerror.cpp:128
QgsFeedback
Definition: qgsfeedback.h:43
QgsGeometryCheckContext
Definition: qgsgeometrycheckcontext.h:31
QgsGeometryCheckError::description
virtual QString description() const
The error description.
Definition: qgsgeometrycheckerror.h:116
QgsGeometryCheckerUtils::LayerFeature
Definition: qgsgeometrycheckerutils.h:51
QgsGeometryOverlapCheckError::OverlappedFeature::OverlappedFeature
OverlappedFeature(QgsVectorLayer *vl, QgsFeatureId fid)
Definition: qgsgeometryoverlapcheck.h:37
QgsGeometryOverlapCheck::checkType
QgsGeometryCheck::CheckType checkType() const override
Returns the check type.
Definition: qgsgeometryoverlapcheck.h:123
QgsGeometryOverlapCheckError
Definition: qgsgeometryoverlapcheck.h:30
QgsGeometryCheckError::isEqual
virtual bool isEqual(QgsGeometryCheckError *other) const
Check if this error is equal to other.
Definition: qgsgeometrycheckerror.cpp:115
QgsGeometryOverlapCheck::ResolutionMethod
ResolutionMethod
Available resolution methods.
Definition: qgsgeometryoverlapcheck.h:100
QgsGeometryOverlapCheckError::OverlappedFeature::featureId
QgsFeatureId featureId() const
Definition: qgsgeometryoverlapcheck.h:45
QgsPointXY
Definition: qgspointxy.h:43
QgsGeometryOverlapCheck
Definition: qgsgeometryoverlapcheck.h:93
QgsGeometry
Definition: qgsgeometry.h:122
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsGeometryCheck::CheckType
CheckType
The type of a check.
Definition: qgsgeometrycheck.h:155
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:40
QgsGeometryCheckError
Definition: qgsgeometrycheckerror.h:35
QgsGeometryCheckError::icon
virtual QIcon icon() const
Returns an icon that should be shown for this kind of error.
Definition: qgsgeometrycheckerror.cpp:199
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsGeometryOverlapCheckError::OverlappedFeature::operator==
bool operator==(const OverlappedFeature &other) const
Definition: qgsgeometryoverlapcheck.h:46
QgsGeometryOverlapCheckError::overlappedFeature
const OverlappedFeature & overlappedFeature() const
Returns the overlapped feature.
Definition: qgsgeometryoverlapcheck.h:70
QgsGeometryCheckError::involvedFeatures
virtual QMap< QString, QgsFeatureIds > involvedFeatures() const
Returns a list of involved features.
Definition: qgsgeometrycheckerror.cpp:194