Skip to content
Permalink
Browse files

Merge pull request #9223 from m-kuhn/geometry_validator_summary_cleanup

Geometry validator summary cleanup
  • Loading branch information
m-kuhn committed Feb 21, 2019
2 parents 9280a07 + 9c06061 commit 4d5dad8172437f143a4907e732bfd92b5a86fa15
@@ -28,11 +28,29 @@ Constructor for QgsGeometryValidator.

static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors /Out/, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );
%Docstring
Validate geometry and produce a list of geometry errors
Validate geometry and produce a list of geometry errors.
This method blocks the thread until the validation is finished.
%End

signals:
void errorFound( const QgsGeometry::Error & );

void errorFound( const QgsGeometry::Error &error );
%Docstring
Sent when an error has been found during the validation process.

The ``error`` contains details about the error.
%End

void validationFinished( const QString &summary );
%Docstring
Sent when the validation is finished.

The result is in a human readable ``summary``, mentioning
if the validation has been aborted, successfully been validated
or how many errors have been found.

.. versionadded:: 3.6
%End

public slots:
void addError( const QgsGeometry::Error & );
@@ -116,7 +116,7 @@ def test_check_validity(self):
self.assertEqual(invalid_layer.featureCount(), 1)
f = next(invalid_layer.getFeatures())
self.assertEqual(f.attributes(), [
1, 'segments 0 and 2 of line 0 intersect at 1, 1\nGeometry has 1 errors.'])
1, 'segments 0 and 2 of line 0 intersect at 1, 1'])

# GEOS method
parameters['METHOD'] = 2
@@ -349,18 +349,16 @@ void QgsGeometryValidator::run()

if ( mStop )
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry validation was aborted." ) ) );
emit validationFinished( QObject::tr( "Geometry validation was aborted." ) );
}
else if ( mErrorCount > 0 )
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) ) );
emit validationFinished( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) );
}
#if 0
else
{
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry is valid." ) ) );
emit validationFinished( QObject::tr( "Geometry is valid." ) );
}
#endif
break;
}
}
@@ -40,11 +40,31 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
void run() override;
void stop();

//! Validate geometry and produce a list of geometry errors
/**
* Validate geometry and produce a list of geometry errors.
* This method blocks the thread until the validation is finished.
*/
static void validateGeometry( const QgsGeometry &geometry, QVector<QgsGeometry::Error> &errors SIP_OUT, QgsGeometry::ValidationMethod method = QgsGeometry::ValidatorQgisInternal );

signals:
void errorFound( const QgsGeometry::Error & );

/**
* Sent when an error has been found during the validation process.
*
* The \a error contains details about the error.
*/
void errorFound( const QgsGeometry::Error &error );

/**
* Sent when the validation is finished.
*
* The result is in a human readable \a summary, mentioning
* if the validation has been aborted, successfully been validated
* or how many errors have been found.
*
* \since QGIS 3.6
*/
void validationFinished( const QString &summary );

public slots:
void addError( const QgsGeometry::Error & );

0 comments on commit 4d5dad8

Please sign in to comment.
You can’t perform that action at this time.