Skip to content

Commit

Permalink
Revert "QgsGeometryCheckError class requires context in constructor (…
Browse files Browse the repository at this point in the history
…not inherited classes yet)"

This reverts commit 73c89ae.
  • Loading branch information
3nids authored and m-kuhn committed Oct 15, 2018
1 parent 7df2c63 commit 3817df6
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 52 deletions.
Expand Up @@ -33,7 +33,6 @@ the Free Software Foundation; either version 2 of the License, or *
enum ValueType { ValueLength, ValueArea, ValueOther };

QgsGeometryCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckContext *context,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
QgsVertexId vidx = QgsVertexId(),
Expand All @@ -44,7 +43,6 @@ the Free Software Foundation; either version 2 of the License, or *


const QgsGeometryCheck *check() const;
const QgsGeometryCheckContext *context() const;
const QString &layerId() const;
QgsFeatureId featureId() const;
QgsGeometry geometry() const;
Expand Down
Expand Up @@ -35,7 +35,7 @@ the Free Software Foundation; either version 2 of the License, or *
%End
public:

LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, const QgsGeometryCheckContext *context, bool useMapCrs );
LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, QgsGeometryCheckContext *context, bool useMapCrs );
%Docstring
Create a new layer/feature combination.
The layer is defined by ``pool``, ``feature`` needs to be from this layer.
Expand Down
Expand Up @@ -63,7 +63,7 @@ void QgsGeometryAngleCheck::collectErrors( const QMap<QString, QgsFeaturePool *>
double angle = std::acos( v21 * v23 ) / M_PI * 180.0;
if ( angle < mMinAngle )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, p2, QgsVertexId( iPart, iRing, iVert ), angle ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, p2, QgsVertexId( iPart, iRing, iVert ), angle ) );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometryareacheck.cpp
Expand Up @@ -20,7 +20,7 @@
#include "qgsfeaturepool.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryAreaCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryAreaCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds( featurePools ) : ids.toMap();
Expand All @@ -35,7 +35,7 @@ void QgsGeometryAreaCheck::collectErrors( const QMap<QString, QgsFeaturePool *>
const QgsAbstractGeometry *part = QgsGeometryCheckerUtils::getGeomPart( geom, iPart );
if ( checkThreshold( layerToMapUnits, part, value ) )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, part->centroid(), QgsVertexId( iPart ), value * layerToMapUnits * layerToMapUnits, QgsGeometryCheckError::ValueArea ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, part->centroid(), QgsVertexId( iPart ), value * layerToMapUnits * layerToMapUnits, QgsGeometryCheckError::ValueArea ) );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
Expand Up @@ -200,14 +200,14 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
{
if ( !recheckAreaFeatures.isEmpty() )
{
check->collectErrors( mFeaturePools, mContext, recheckErrors, mMessages, nullptr, recheckAreaFeatures );
check->collectErrors( mFeaturePools, recheckErrors, mMessages, nullptr, recheckAreaFeatures );
}
}
else
{
if ( !recheckFeatures.isEmpty() )
{
check->collectErrors( mFeaturePools, mContext, recheckErrors, mMessages, nullptr, recheckFeatures );
check->collectErrors( mFeaturePools, recheckErrors, mMessages, nullptr, recheckFeatures );
}
}
}
Expand Down Expand Up @@ -285,7 +285,7 @@ void QgsGeometryChecker::runCheck( const QMap<QString, QgsFeaturePool *> &featur
// Run checks
QList<QgsGeometryCheckError *> errors;
QStringList messages;
check->collectErrors( featurePools, mContext, errors, messages, &mFeedback );
check->collectErrors( featurePools, errors, messages, &mFeedback );
mErrorListMutex.lock();
mCheckErrors.append( errors );
mMessages.append( messages );
Expand Down
3 changes: 0 additions & 3 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
Expand Up @@ -33,7 +33,6 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
enum ValueType { ValueLength, ValueArea, ValueOther };

QgsGeometryCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckContext *context,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
QgsVertexId vidx = QgsVertexId(),
Expand All @@ -45,7 +44,6 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
const QgsGeometryCheckError &operator=( const QgsGeometryCheckError & ) = delete;

const QgsGeometryCheck *check() const { return mCheck; }
const QgsGeometryCheckContext *context() const {return mContext;}
const QString &layerId() const { return mLayerId; }
QgsFeatureId featureId() const { return mFeatureId; }
// In map units
Expand Down Expand Up @@ -101,7 +99,6 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
ValueType valueType = ValueOther );

const QgsGeometryCheck *mCheck = nullptr;
const QgsGeometryCheckContext *mContext = nullptr;
QString mLayerId;
QgsFeatureId mFeatureId;
QgsGeometry mGeometry;
Expand Down
Expand Up @@ -31,7 +31,7 @@

QgsGeometryCheckerUtils::LayerFeature::LayerFeature( const QgsFeaturePool *pool,
const QgsFeature &feature,
const QgsGeometryCheckContext *context,
QgsGeometryCheckContext *context,
bool useMapCrs )
: mFeaturePool( pool )
, mFeature( feature )
Expand Down Expand Up @@ -211,7 +211,7 @@ QgsGeometryCheckerUtils::LayerFeatures::LayerFeatures( const QMap<QString, QgsFe
const QMap<QString, QgsFeatureIds> &featureIds,
const QList<QgsWkbTypes::GeometryType> &geometryTypes,
QgsFeedback *feedback,
const QgsGeometryCheckContext *context,
QgsGeometryCheckContext *context,
bool useMapCrs )
: mFeaturePools( featurePools )
, mFeatureIds( featureIds )
Expand All @@ -225,7 +225,7 @@ QgsGeometryCheckerUtils::LayerFeatures::LayerFeatures( const QMap<QString, QgsFe
QgsGeometryCheckerUtils::LayerFeatures::LayerFeatures( const QMap<QString, QgsFeaturePool *> &featurePools,
const QList<QString> &layerIds, const QgsRectangle &extent,
const QList<QgsWkbTypes::GeometryType> &geometryTypes,
const QgsGeometryCheckContext *context )
QgsGeometryCheckContext *context )
: mFeaturePools( featurePools )
, mLayerIds( layerIds )
, mExtent( extent )
Expand Down
Expand Up @@ -41,7 +41,7 @@ class ANALYSIS_EXPORT QgsGeometryCheckerUtils
* If \a useMapCrs is True, geometries will be reprojected to the mapCrs defined
* in \a context.
*/
LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, const QgsGeometryCheckContext *context, bool useMapCrs );
LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, QgsGeometryCheckContext *context, bool useMapCrs );

/**
* Returns the feature.
Expand Down Expand Up @@ -89,13 +89,13 @@ class ANALYSIS_EXPORT QgsGeometryCheckerUtils
const QMap<QString, QgsFeatureIds> &featureIds,
const QList<QgsWkbTypes::GeometryType> &geometryTypes,
QgsFeedback *feedback,
const QgsGeometryCheckContext *context,
QgsGeometryCheckContext *context,
bool useMapCrs = false );

LayerFeatures( const QMap<QString, QgsFeaturePool *> &featurePools,
const QList<QString> &layerIds, const QgsRectangle &extent,
const QList<QgsWkbTypes::GeometryType> &geometryTypes,
const QgsGeometryCheckContext *context );
QgsGeometryCheckContext *context );

class iterator
{
Expand Down Expand Up @@ -133,7 +133,7 @@ class ANALYSIS_EXPORT QgsGeometryCheckerUtils
QgsRectangle mExtent;
QList<QgsWkbTypes::GeometryType> mGeometryTypes;
QgsFeedback *mFeedback = nullptr;
const QgsGeometryCheckContext *mContext = nullptr;
QgsGeometryCheckContext *mContext = nullptr;
bool mUseMapCrs = true;
};

Expand Down
Expand Up @@ -20,7 +20,7 @@
#include "qgsvectorlayer.h"


void QgsGeometryContainedCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryContainedCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds( featurePools ) : ids.toMap();
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesA( featurePools, featureIds, compatibleGeometryTypes(), feedback, mContext );
Expand Down
Expand Up @@ -30,7 +30,7 @@ class ANALYSIS_EXPORT QgsGeometryContainedCheckError : public QgsGeometryCheckEr
const QgsPointXY &errorLocation,
const QgsGeometryCheckerUtils::LayerFeature &containingFeature
)
: QgsGeometryCheckError( check, check->context(), layerFeature, errorLocation, QgsVertexId(), containingFeature.id(), ValueOther )
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), containingFeature.id(), ValueOther )
, mContainingFeature( qMakePair( containingFeature.layer()->id(), containingFeature.feature().id() ) )
{ }
const QPair<QString, QgsFeatureId> &containingFeature() const { return mContainingFeature; }
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include "qgsvectorlayer.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryDangleCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryDangleCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds( featurePools ) : ids.toMap();
Expand Down Expand Up @@ -84,11 +84,11 @@ void QgsGeometryDangleCheck::collectErrors( const QMap<QString, QgsFeaturePool *
}
if ( !p1touches )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, p1, QgsVertexId( iPart, 0, 0 ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, p1, QgsVertexId( iPart, 0, 0 ) ) );
}
if ( !p2touches )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, p2, QgsVertexId( iPart, 0, nVerts - 1 ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, p2, QgsVertexId( iPart, 0, nVerts - 1 ) ) );
}
}
}
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include "qgsgeometrycheckerror.h"


void QgsGeometryDegeneratePolygonCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryDegeneratePolygonCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand All @@ -35,7 +35,7 @@ void QgsGeometryDegeneratePolygonCheck::collectErrors( const QMap<QString, QgsFe
if ( QgsGeometryCheckerUtils::polyLineSize( geom, iPart, iRing ) < 3 )
{
QgsVertexId vidx( iPart, iRing );
errors.append( new QgsGeometryCheckError( this, context, layerFeature, geom->vertexAt( vidx ), vidx ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, geom->vertexAt( vidx ), vidx ) );
}
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@ QString QgsGeometryDuplicateCheckError::duplicatesString( const QMap<QString, Qg
}


void QgsGeometryDuplicateCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryDuplicateCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds( featurePools ) : ids.toMap();
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesA( featurePools, featureIds, compatibleGeometryTypes(), feedback, mContext, true );
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include "qgsfeaturepool.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryDuplicateNodesCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryDuplicateNodesCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand All @@ -41,7 +41,7 @@ void QgsGeometryDuplicateNodesCheck::collectErrors( const QMap<QString, QgsFeatu
QgsPoint pj = geom->vertexAt( QgsVertexId( iPart, iRing, jVert ) );
if ( QgsGeometryUtils::sqrDistance2D( pi, pj ) < mContext->tolerance )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, pj, QgsVertexId( iPart, iRing, jVert ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, pj, QgsVertexId( iPart, iRing, jVert ) ) );
}
}
}
Expand Down
Expand Up @@ -36,7 +36,7 @@ QgsGeometryFollowBoundariesCheck::~QgsGeometryFollowBoundariesCheck()
delete mIndex;
}

void QgsGeometryFollowBoundariesCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryFollowBoundariesCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand Down Expand Up @@ -70,7 +70,7 @@ void QgsGeometryFollowBoundariesCheck::collectErrors( const QMap<QString, QgsFea
if ( refFeatureIds.isEmpty() )
{
// If no potential reference features are found, the geometry is definitely not following boundaries of reference layer features
errors.append( new QgsGeometryCheckError( this, context, layerFeature, QgsPointXY( geom->centroid() ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, QgsPointXY( geom->centroid() ) ) );
}
else
{
Expand All @@ -83,7 +83,7 @@ void QgsGeometryFollowBoundariesCheck::collectErrors( const QMap<QString, QgsFea
QgsGeometry reducedRefGeom( refgeomEngine->buffer( -mContext->tolerance, 0 ) );
if ( !( geomEngine->contains( reducedRefGeom.constGet() ) || geomEngine->disjoint( reducedRefGeom.constGet() ) ) )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, QgsPointXY( geom->centroid() ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, QgsPointXY( geom->centroid() ) ) );
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometryholecheck.cpp
Expand Up @@ -20,7 +20,7 @@
#include "qgsfeaturepool.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryHoleCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryHoleCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand All @@ -41,7 +41,7 @@ void QgsGeometryHoleCheck::collectErrors( const QMap<QString, QgsFeaturePool *>
{

QgsPoint pos = poly->interiorRing( iRing - 1 )->centroid();
errors.append( new QgsGeometryCheckError( this, context, layerFeature, pos, QgsVertexId( iPart, iRing ) ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, pos, QgsVertexId( iPart, iRing ) ) );
}
}
}
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include "qgsvectorlayer.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryLineIntersectionCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryLineIntersectionCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand Down Expand Up @@ -67,7 +67,7 @@ void QgsGeometryLineIntersectionCheck::collectErrors( const QMap<QString, QgsFea
const QList< QgsPoint > intersections = QgsGeometryCheckerUtils::lineIntersections( line, testLine, mContext->tolerance );
for ( const QgsPoint &inter : intersections )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeatureA, inter, QgsVertexId( iPart ), layerFeatureB.id() ) );
errors.append( new QgsGeometryCheckError( this, layerFeatureA, inter, QgsVertexId( iPart ), layerFeatureB.id() ) );
}
}
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
#include "qgsfeaturepool.h"
#include "qgsgeometrycheckerror.h"

void QgsGeometryLineLayerIntersectionCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheckContext *context, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
void QgsGeometryLineLayerIntersectionCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids ) const
{
Q_UNUSED( messages )

Expand Down Expand Up @@ -52,7 +52,7 @@ void QgsGeometryLineLayerIntersectionCheck::collectErrors( const QMap<QString, Q
const QList< QgsPoint > intersections = QgsGeometryCheckerUtils::lineIntersections( line, testLine, mContext->tolerance );
for ( const QgsPoint &inter : intersections )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, inter, QgsVertexId( iPart ), checkFeature.id() ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, inter, QgsVertexId( iPart ), checkFeature.id() ) );
}
}
else if ( const QgsPolygon *polygon = dynamic_cast<const QgsPolygon *>( part ) )
Expand All @@ -63,7 +63,7 @@ void QgsGeometryLineLayerIntersectionCheck::collectErrors( const QMap<QString, Q
const QList< QgsPoint > intersections = QgsGeometryCheckerUtils::lineIntersections( line, ring, mContext->tolerance );
for ( const QgsPoint &inter : intersections )
{
errors.append( new QgsGeometryCheckError( this, context, layerFeature, inter, QgsVertexId( iPart ), checkFeature.id() ) );
errors.append( new QgsGeometryCheckError( this, layerFeature, inter, QgsVertexId( iPart ), checkFeature.id() ) );
}
}
}
Expand Down

0 comments on commit 3817df6

Please sign in to comment.