QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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  Q_DECLARE_TR_FUNCTIONS( QgsGeometryOverlapCheck )
96  public:
97 
102  {
104  NoChange
105  };
106 
115  QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
116  QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
117  void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
118  void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
119  Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
120 
121  QString description() const override;
122  QString id() const override;
123  QgsGeometryCheck::Flags flags() const override;
124  QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
125 
127  static QString factoryDescription() SIP_SKIP;
128  static QString factoryId() SIP_SKIP;
129  static QgsGeometryCheck::Flags factoryFlags() SIP_SKIP;
130  static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() SIP_SKIP;
131  static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP;
132  static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
134 
135  private:
136  const double mOverlapThresholdMapUnits;
137 
138 };
139 
140 #endif // QGS_GEOMETRY_OVERLAP_CHECK_H
QgsGeometryOverlapCheck::Subtract
@ Subtract
Subtract the overlap region from the polygon.
Definition: qgsgeometryoverlapcheck.h:103
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:220
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:116
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
This class implements a geometry check.
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
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsGeometryCheckContext
Base configuration for geometry checks.
Definition: qgsgeometrycheckcontext.h:31
QgsGeometryCheckError::description
virtual QString description() const
The error description.
Definition: qgsgeometrycheckerror.h:116
QgsGeometryCheckerUtils::LayerFeature
A layer feature combination to uniquely identify and access a feature in a set of layers.
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:124
QgsGeometryOverlapCheckError
An error of a QgsGeometryOverlapCheck.
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:101
QgsGeometryOverlapCheckError::OverlappedFeature::featureId
QgsFeatureId featureId() const
Definition: qgsgeometryoverlapcheck.h:45
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsGeometryOverlapCheck
Checks if geometries overlap.
Definition: qgsgeometryoverlapcheck.h:93
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:391
QgsGeometryCheck::CheckType
CheckType
The type of a check.
Definition: qgsgeometrycheck.h:154
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:41
QgsGeometryCheckError
This represents an error reported by a geometry check.
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
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
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