QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
17#ifndef QGS_GEOMETRY_GAP_CHECK_H
18#define QGS_GEOMETRY_GAP_CHECK_H
19
20#include "qgsfeatureid.h"
21#include "qgsgeometrycheck.h"
23
24#define SIP_NO_FILE
25
32class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
33{
34 public:
42 const QgsGeometryCheck *check, const QString &layerId, const QgsGeometry &geometry, const QMap<QString, QgsFeatureIds> &neighbors, double area, const QgsRectangle &gapAreaBBox, const QgsRectangle &contextArea
43 )
44 : QgsGeometryCheckError( check, layerId, FID_NULL, geometry, geometry.constGet()->centroid(), QgsVertexId(), area, ValueArea )
45 , mNeighbors( neighbors )
46 , mGapAreaBBox( gapAreaBBox )
47 , mContextBoundingBox( contextArea )
48 {}
49
50 QgsRectangle contextBoundingBox() const override;
51
55 const QMap<QString, QgsFeatureIds> &neighbors() const { return mNeighbors; }
56
57 bool isEqual( QgsGeometryCheckError *other ) const override;
58
59 bool closeMatch( QgsGeometryCheckError *other ) const override;
60
61 void update( const QgsGeometryCheckError *other ) override;
62
63 bool handleChanges( const QgsGeometryCheck::Changes & /*changes*/ ) override;
64
65 QgsRectangle affectedAreaBBox() const override;
66
67 QMap<QString, QgsFeatureIds> involvedFeatures() const override;
68
69 QIcon icon() const override;
70
71 private:
72 QMap<QString, QgsFeatureIds> mNeighbors;
73 QgsRectangle mGapAreaBBox;
74 QgsRectangle mContextBoundingBox;
75};
76
77
84class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
85{
86 Q_GADGET
87 Q_DECLARE_TR_FUNCTIONS( QgsGeometryGapCheck )
88
89 public:
99 Q_ENUM( ResolutionMethod )
100
101
107 explicit QgsGeometryGapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
108
109 void prepare( const QgsGeometryCheckContext *context, const QVariantMap &configuration ) override;
110
111 QList<Qgis::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
113 const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds()
114 ) const override;
115 void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
116 Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
117
118 QList<QgsGeometryCheckResolutionMethod> availableResolutionMethods() 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<Qgis::GeometryType> factoryCompatibleGeometryTypes() SIP_SKIP;
130 static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP;
131 static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
133
134 private:
135 enum Condition
136 {
137 LongestSharedEdge,
138 LargestArea
139 };
140
141 bool mergeWithNeighbor( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryGapCheckError *err, Changes &changes, QString &errMsg, Condition condition ) const;
142
143 const double mGapThresholdMapUnits;
144 QgsWeakMapLayerPointer mAllowedGapsLayer;
145 std::unique_ptr<QgsVectorLayerFeatureSource> mAllowedGapsSource;
146 double mAllowedGapsBuffer = 0;
147};
148
149#endif // QGS_GEOMETRY_GAP_CHECK_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
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.
@ ValueArea
The value is an area.
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.
QgsGeometryCheckError(const QgsGeometryCheck *check, const QgsGeometryCheckerUtils::LayerFeature &layerFeature, const QgsPointXY &errorLocation, QgsVertexId vidx=QgsVertexId(), const QVariant &value=QVariant(), ValueType valueType=ValueOther)
Create a new geometry check error with the parent check and for the layerFeature pair at the errorLoc...
QgsGeometry geometry() const
The geometry of the error in map units.
const QgsGeometryCheck * check() const
The geometry check that created this error.
virtual bool isEqual(QgsGeometryCheckError *other) const
Check if this error is equal to other.
const QString & layerId() const
The id of the layer on which this error has been detected.
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.
Base class for geometry checks.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
QFlags< Flag > Flags
CheckType
The type of a check.
Result
Result of the geometry checker operation.
QgsGeometryCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
Create a new geometry check.
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.
QgsGeometryGapCheck(const QgsGeometryCheckContext *context, const QVariantMap &configuration)
The configuration accepts a "gapThreshold" key which specifies the maximum gap size in squared map un...
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 dataset.
#define SIP_SKIP
Definition qgis_sip.h:133
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:34