@@ -230,6 +230,28 @@ void QgsGeometryValidator::run()
230
230
char res = GEOSisValidDetail_r ( handle, g0.get (), GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE, &r, &g1 );
231
231
if ( res != 1 )
232
232
{
233
+ static QgsStringMap translatedErrors;
234
+
235
+ if ( translatedErrors.empty () )
236
+ {
237
+ // Copied from https://git.osgeo.org/gitea/geos/geos/src/branch/master/src/operation/valid/TopologyValidationError.cpp
238
+ translatedErrors.insert ( QStringLiteral ( " Topology Validation Error" ), QObject::tr ( " Topology Validation Error" , " GEOS Error" ) );
239
+ translatedErrors.insert ( QStringLiteral ( " Repeated Point" ), QObject::tr ( " Repeated Point" , " GEOS Error" ) );
240
+ translatedErrors.insert ( QStringLiteral ( " Hole lies outside shell" ), QObject::tr ( " Hole lies outside shell" , " GEOS Error" ) );
241
+ translatedErrors.insert ( QStringLiteral ( " Holes are nested" ), QObject::tr ( " Holes are nested" , " GEOS Error" ) );
242
+ translatedErrors.insert ( QStringLiteral ( " Interior is disconnected" ), QObject::tr ( " Interior is disconnected" , " GEOS Error" ) );
243
+ translatedErrors.insert ( QStringLiteral ( " Self-intersection" ), QObject::tr ( " Self-intersection" , " GEOS Error" ) );
244
+ translatedErrors.insert ( QStringLiteral ( " Ring Self-intersection" ), QObject::tr ( " Ring Self-intersection" , " GEOS Error" ) );
245
+ translatedErrors.insert ( QStringLiteral ( " Nested shells" ), QObject::tr ( " Nested shells" , " GEOS Error" ) );
246
+ translatedErrors.insert ( QStringLiteral ( " Duplicate Rings" ), QObject::tr ( " Duplicate Rings" , " GEOS Error" ) );
247
+ translatedErrors.insert ( QStringLiteral ( " Too few points in geometry component" ), QObject::tr ( " Too few points in geometry component" , " GEOS Error" ) );
248
+ translatedErrors.insert ( QStringLiteral ( " Invalid Coordinate" ), QObject::tr ( " Invalid Coordinate" , " GEOS Error" ) );
249
+ translatedErrors.insert ( QStringLiteral ( " Ring is not closed" ), QObject::tr ( " Ring is not closed" , " GEOS Error" ) );
250
+ }
251
+
252
+ const QString errorMsg ( r );
253
+ const QString translatedErrorMsg = translatedErrors.value ( errorMsg, errorMsg );
254
+
233
255
if ( g1 )
234
256
{
235
257
const GEOSCoordSequence *cs = GEOSGeom_getCoordSeq_r ( handle, g1 );
@@ -240,15 +262,16 @@ void QgsGeometryValidator::run()
240
262
double x, y;
241
263
GEOSCoordSeq_getX_r ( handle, cs, 0 , &x );
242
264
GEOSCoordSeq_getY_r ( handle, cs, 0 , &y );
243
- emit errorFound ( QgsGeometry::Error ( QObject::tr ( " GEOS error: %1" ).arg ( r ), QgsPointXY ( x, y ) ) );
265
+
266
+ emit errorFound ( QgsGeometry::Error ( translatedErrorMsg, QgsPointXY ( x, y ) ) );
244
267
mErrorCount ++;
245
268
}
246
269
247
270
GEOSGeom_destroy_r ( handle, g1 );
248
271
}
249
272
else
250
273
{
251
- emit errorFound ( QgsGeometry::Error ( QObject::tr ( " GEOS error: %1 " ). arg ( r ) ) );
274
+ emit errorFound ( QgsGeometry::Error ( translatedErrorMsg ) );
252
275
mErrorCount ++;
253
276
}
254
277
0 commit comments