Skip to content

Commit baf1e52

Browse files
committedOct 15, 2018
Better error reporting from is valid check
1 parent ed27442 commit baf1e52

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 

‎src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ QList<QgsSingleGeometryCheckError *> QgsGeometryIsValidCheck::processGeometry( c
4949
QList<QgsSingleGeometryCheckError *> result;
5050
for ( const auto &error : qgis::as_const( errors ) )
5151
{
52-
result << new QgsSingleGeometryCheckError( this, geometry, QgsGeometry( qgis::make_unique<QgsPoint>( error.where() ) ) );
52+
QgsGeometry errorGeometry;
53+
if ( error.hasWhere() )
54+
errorGeometry = QgsGeometry( qgis::make_unique<QgsPoint>( error.where() ) );
55+
56+
result << new QgsGeometryIsValidCheckError( this, geometry, errorGeometry, error.what() );
5357
}
5458
return result;
5559
}
@@ -89,3 +93,15 @@ QgsGeometryCheck::CheckType QgsGeometryIsValidCheck::factoryCheckType()
8993
return QgsGeometryCheck::FeatureNodeCheck;
9094
}
9195
///@endcond
96+
97+
QgsGeometryIsValidCheckError::QgsGeometryIsValidCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription )
98+
: QgsSingleGeometryCheckError( check, geometry, errorLocation )
99+
, mDescription( errorDescription )
100+
{
101+
102+
}
103+
104+
QString QgsGeometryIsValidCheckError::description() const
105+
{
106+
return mDescription;
107+
}

‎src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ email : matthias@opengis.ch
2020

2121
#include "qgssinglegeometrycheck.h"
2222

23+
class ANALYSIS_EXPORT QgsGeometryIsValidCheckError : public QgsSingleGeometryCheckError
24+
{
25+
public:
26+
QgsGeometryIsValidCheckError( const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, const QString &errorDescription );
27+
28+
QString description() const override;
29+
30+
private:
31+
QString mDescription;
32+
};
33+
2334
/**
2435
* Checks if geometries are valid using the backend configured in the QGIS settings.
2536
* This does not offer any fixes but makes sure that all geometries are valid.

0 commit comments

Comments
 (0)
Please sign in to comment.