Skip to content

Commit

Permalink
Better error reporting from is valid check
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent ed27442 commit baf1e52
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.cpp
Expand Up @@ -49,7 +49,11 @@ QList<QgsSingleGeometryCheckError *> QgsGeometryIsValidCheck::processGeometry( c
QList<QgsSingleGeometryCheckError *> result;
for ( const auto &error : qgis::as_const( errors ) )
{
result << new QgsSingleGeometryCheckError( this, geometry, QgsGeometry( qgis::make_unique<QgsPoint>( error.where() ) ) );
QgsGeometry errorGeometry;
if ( error.hasWhere() )
errorGeometry = QgsGeometry( qgis::make_unique<QgsPoint>( error.where() ) );

result << new QgsGeometryIsValidCheckError( this, geometry, errorGeometry, error.what() );
}
return result;
}
Expand Down Expand Up @@ -89,3 +93,15 @@ QgsGeometryCheck::CheckType QgsGeometryIsValidCheck::factoryCheckType()
return QgsGeometryCheck::FeatureNodeCheck;
}
///@endcond

QgsGeometryIsValidCheckError::QgsGeometryIsValidCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription )
: QgsSingleGeometryCheckError( check, geometry, errorLocation )
, mDescription( errorDescription )
{

}

QString QgsGeometryIsValidCheckError::description() const
{
return mDescription;
}
11 changes: 11 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.h
Expand Up @@ -20,6 +20,17 @@ email : matthias@opengis.ch

#include "qgssinglegeometrycheck.h"

class ANALYSIS_EXPORT QgsGeometryIsValidCheckError : public QgsSingleGeometryCheckError
{
public:
QgsGeometryIsValidCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription );

QString description() const override;

private:
QString mDescription;
};

/**
* Checks if geometries are valid using the backend configured in the QGIS settings.
* This does not offer any fixes but makes sure that all geometries are valid.
Expand Down

0 comments on commit baf1e52

Please sign in to comment.