QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsgeometrygapcheck.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometrygapcheck.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_GAP_CHECK_H
19#define QGS_GEOMETRY_GAP_CHECK_H
20
21#include "qgsgeometrycheck.h"
23#include "qgsfeatureid.h"
24
31class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
32{
33 public:
40 QgsGeometryGapCheckError( const QgsGeometryCheck *check, const QString &layerId, const QgsGeometry &geometry, const QMap<QString, QgsFeatureIds> &neighbors, double area, const QgsRectangle &gapAreaBBox, const QgsRectangle &contextArea )
41 : QgsGeometryCheckError( check, layerId, FID_NULL, geometry, geometry.constGet()->centroid(), QgsVertexId(), area, ValueArea )
42 , mNeighbors( neighbors )
43 , mGapAreaBBox( gapAreaBBox )
44 , mContextBoundingBox( contextArea )
45 {
46 }
47
48 QgsRectangle contextBoundingBox() const override;
49
53 const QMap<QString, QgsFeatureIds> &neighbors() const { return mNeighbors; }
54
55 bool isEqual( QgsGeometryCheckError *other ) const override;
56
57 bool closeMatch( QgsGeometryCheckError *other ) const override;
58
59 void update( const QgsGeometryCheckError *other ) override;
60
61 bool handleChanges( const QgsGeometryCheck::Changes & /*changes*/ ) override;
62
63 QgsRectangle affectedAreaBBox() const override;
64
65 QMap<QString, QgsFeatureIds> involvedFeatures() const override;
66
67 QIcon icon() const override;
68
69 private:
70 QMap<QString, QgsFeatureIds> mNeighbors;
71 QgsRectangle mGapAreaBBox;
72 QgsRectangle mContextBoundingBox;
73};
74
75
82class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
83{
84 Q_GADGET
85 Q_DECLARE_TR_FUNCTIONS( QgsGeometryGapCheck )
86
87 public:
97 Q_ENUM( ResolutionMethod )
98
99
105 explicit QgsGeometryGapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
106
107 void prepare( const QgsGeometryCheckContext *context, const QVariantMap &configuration ) override;
108
109 QList<Qgis::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
110 void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
111 void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
112 Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
113
114 QList<QgsGeometryCheckResolutionMethod> availableResolutionMethods() const override;
115
116 QString description() const override;
117 QString id() const override;
118 QgsGeometryCheck::Flags flags() const override;
119 QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
120
122 static QString factoryDescription() SIP_SKIP;
123 static QString factoryId() SIP_SKIP;
124 static QgsGeometryCheck::Flags factoryFlags() SIP_SKIP;
125 static QList<Qgis::GeometryType> factoryCompatibleGeometryTypes() SIP_SKIP;
126 static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP;
127 static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
129
130 private:
131 enum Condition
132 {
133 LongestSharedEdge,
134 LargestArea
135 };
136
137 bool mergeWithNeighbor( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryGapCheckError *err, Changes &changes, QString &errMsg, Condition condition ) const;
138
139 const double mGapThresholdMapUnits;
140 QgsWeakMapLayerPointer mAllowedGapsLayer;
141 std::unique_ptr<QgsVectorLayerFeatureSource> mAllowedGapsSource;
142 double mAllowedGapsBuffer = 0;
143};
144
145#endif // QGS_GEOMETRY_GAP_CHECK_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Base configuration for geometry checks.
This represents an error reported by a geometry check.
virtual QMap< QString, QgsFeatureIds > involvedFeatures() const
Returns a list of involved features.
virtual void update(const QgsGeometryCheckError *other)
Update this error with the information from other.
virtual QString description() const
The error description.
virtual bool isEqual(QgsGeometryCheckError *other) const
Check if this error is equal to other.
virtual bool closeMatch(QgsGeometryCheckError *) const
Check if this error is almost equal to other.
virtual QgsRectangle affectedAreaBBox() const
The bounding box of the affected area of the error.
virtual QIcon icon() const
Returns an icon that should be shown for this kind of error.
virtual bool handleChanges(const QgsGeometryCheck::Changes &changes)
Apply a list of changes.
virtual QgsRectangle contextBoundingBox() const
The context of the error.
This class implements a geometry check.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
QFlags< Flag > Flags
CheckType
The type of a check.
An error produced by a QgsGeometryGapCheck.
QgsGeometryGapCheckError(const QgsGeometryCheck *check, const QString &layerId, const QgsGeometry &geometry, const QMap< QString, QgsFeatureIds > &neighbors, double area, const QgsRectangle &gapAreaBBox, const QgsRectangle &contextArea)
Create a new gap check error produced by check on the layer layerId.
const QMap< QString, QgsFeatureIds > & neighbors() const
A map of layers and feature ids of the neighbors of the gap.
Checks for gaps between neighbouring polygons.
QgsGeometryCheck::CheckType checkType() const override
Returns the check type.
ResolutionMethod
Resolution methods for geometry gap checks.
@ CreateNewFeature
Create a new feature with the gap geometry.
@ AddToAllowedGaps
Add gap geometry to allowed gaps layer.
@ MergeLongestEdge
Merge the gap with the polygon with the longest shared edge.
@ NoChange
Do not handle the error.
@ MergeLargestArea
Merge with neighbouring polygon with largest area.
QList< Qgis::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
A geometry is the spatial representation of a feature.
A rectangle specified with double values.
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition qgis_sip.h:126
void CPL_STDCALL collectErrors(CPLErr, int, const char *msg)
#define FID_NULL
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:30