-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsgeometryoverlapcheck.h
140 lines (117 loc) · 5.38 KB
/
qgsgeometryoverlapcheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/***************************************************************************
qgsgeometryoverlapcheck.h
---------------------
begin : September 2015
copyright : (C) 2014 by Sandro Mani / Sourcepole AG
email : smani at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#define SIP_NO_FILE
#ifndef QGS_GEOMETRY_OVERLAP_CHECK_H
#define QGS_GEOMETRY_OVERLAP_CHECK_H
#include "qgsgeometrycheck.h"
#include "qgsgeometrycheckerror.h"
/**
* \ingroup analysis
* An error of a QgsGeometryOverlapCheck.
*
* \since QGIS 3.4
*/
class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckError
{
public:
struct OverlappedFeature
{
public:
OverlappedFeature( QgsVectorLayer *vl, QgsFeatureId fid )
: mLayerId( vl->id() )
, mLayerName( vl->name() )
, mFeatureId( fid )
{}
QString layerId() const {return mLayerId;}
QString layerName() const {return mLayerName;}
QgsFeatureId featureId() const {return mFeatureId;}
bool operator==( const OverlappedFeature &other ) const {return mLayerId == other.layerId() && mFeatureId == other.featureId();}
private:
QString mLayerId;
QString mLayerName;
QgsFeatureId mFeatureId;
};
/**
* Creates a new overlap check error for \a check and the \a layerFeature combination.
* The \a geometry and \a errorLocation ned to be in map coordinates.
* The \a value is the area of the overlapping area in map units.
* The \a overlappedFeature provides more details about the overlap.
*/
QgsGeometryOverlapCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsGeometry &geometry,
const QgsPointXY &errorLocation,
const QVariant &value,
const QgsGeometryCheckerUtils::LayerFeature &overlappedFeature );
/**
* Returns the overlapped feature
*/
const OverlappedFeature &overlappedFeature() const { return mOverlappedFeature; }
bool isEqual( QgsGeometryCheckError *other ) const override;
bool closeMatch( QgsGeometryCheckError *other ) const override;
bool handleChanges( const QgsGeometryCheck::Changes &changes ) override;
QString description() const override;
QMap<QString, QgsFeatureIds > involvedFeatures() const override;
QIcon icon() const override;
private:
OverlappedFeature mOverlappedFeature;
};
/**
* \ingroup analysis
* Checks if geometries overlap.
*
* \since QGIS 3.4
*/
class ANALYSIS_EXPORT QgsGeometryOverlapCheck : public QgsGeometryCheck
{
Q_DECLARE_TR_FUNCTIONS( QgsGeometryOverlapCheck )
public:
/**
* Available resolution methods.
*/
enum ResolutionMethod
{
Subtract, //!< Subtract the overlap region from the polygon
NoChange //!< Do not change anything
};
/**
* Checks for overlapping polygons.
*
* In \a configuration a maxOverlapArea parameter can be passed. In case this parameter is set
* to something else than 0.0, the error will only be reported if the overlapping area is smaller
* than maxOverlapArea.
* Overlapping areas smaller than the reducedTolerance parameter of the \a context are ignored.
*/
QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
QString description() const override;
QString id() const override;
QgsGeometryCheck::Flags flags() const override;
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
///@cond private
static QString factoryDescription() SIP_SKIP;
static QString factoryId() SIP_SKIP;
static QgsGeometryCheck::Flags factoryFlags() SIP_SKIP;
static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() SIP_SKIP;
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP;
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
///@endcond private
private:
const double mOverlapThresholdMapUnits;
};
#endif // QGS_GEOMETRY_OVERLAP_CHECK_H