Skip to content

Commit 4d5dad8

Browse files
authored
Merge pull request #9223 from m-kuhn/geometry_validator_summary_cleanup
Geometry validator summary cleanup
2 parents 9280a07 + 9c06061 commit 4d5dad8

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

python/core/auto_generated/qgsgeometryvalidator.sip.in

+20-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,29 @@ Constructor for QgsGeometryValidator.
2828

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

3435
signals:
35-
void errorFound( const QgsGeometry::Error & );
36+
37+
void errorFound( const QgsGeometry::Error &error );
38+
%Docstring
39+
Sent when an error has been found during the validation process.
40+
41+
The ``error`` contains details about the error.
42+
%End
43+
44+
void validationFinished( const QString &summary );
45+
%Docstring
46+
Sent when the validation is finished.
47+
48+
The result is in a human readable ``summary``, mentioning
49+
if the validation has been aborted, successfully been validated
50+
or how many errors have been found.
51+
52+
.. versionadded:: 3.6
53+
%End
3654

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

python/plugins/processing/tests/CheckValidityAlgorithm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_check_validity(self):
116116
self.assertEqual(invalid_layer.featureCount(), 1)
117117
f = next(invalid_layer.getFeatures())
118118
self.assertEqual(f.attributes(), [
119-
1, 'segments 0 and 2 of line 0 intersect at 1, 1\nGeometry has 1 errors.'])
119+
1, 'segments 0 and 2 of line 0 intersect at 1, 1'])
120120

121121
# GEOS method
122122
parameters['METHOD'] = 2

src/core/qgsgeometryvalidator.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,16 @@ void QgsGeometryValidator::run()
349349

350350
if ( mStop )
351351
{
352-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry validation was aborted." ) ) );
352+
emit validationFinished( QObject::tr( "Geometry validation was aborted." ) );
353353
}
354354
else if ( mErrorCount > 0 )
355355
{
356-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) ) );
356+
emit validationFinished( QObject::tr( "Geometry has %1 errors." ).arg( mErrorCount ) );
357357
}
358-
#if 0
359358
else
360359
{
361-
emit errorFound( QgsGeometry::Error( QObject::tr( "Geometry is valid." ) ) );
360+
emit validationFinished( QObject::tr( "Geometry is valid." ) );
362361
}
363-
#endif
364362
break;
365363
}
366364
}

src/core/qgsgeometryvalidator.h

+22-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,31 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
4040
void run() override;
4141
void stop();
4242

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

4649
signals:
47-
void errorFound( const QgsGeometry::Error & );
50+
51+
/**
52+
* Sent when an error has been found during the validation process.
53+
*
54+
* The \a error contains details about the error.
55+
*/
56+
void errorFound( const QgsGeometry::Error &error );
57+
58+
/**
59+
* Sent when the validation is finished.
60+
*
61+
* The result is in a human readable \a summary, mentioning
62+
* if the validation has been aborted, successfully been validated
63+
* or how many errors have been found.
64+
*
65+
* \since QGIS 3.6
66+
*/
67+
void validationFinished( const QString &summary );
4868

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

0 commit comments

Comments
 (0)