@@ -187,7 +187,7 @@ void QgsGeometryValidator::validatePolygon( int idx, const QgsPolygonXY &polygon
187
187
{
188
188
if ( !ringInRing ( polygon[i], polygon[0 ] ) )
189
189
{
190
- QString msg = QObject::tr ( " ring %1 of polygon %2 not in exterior ring" ).arg ( i ).arg ( idx );
190
+ QString msg = QObject::tr ( " Ring %1 of polygon %2 not in exterior ring" ).arg ( i ).arg ( idx );
191
191
QgsDebugMsg ( msg );
192
192
emit errorFound ( QgsGeometry::Error ( msg ) );
193
193
mErrorCount ++;
@@ -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.toLower (), 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
@@ -290,7 +313,7 @@ void QgsGeometryValidator::run()
290
313
{
291
314
if ( mp[i].isEmpty () )
292
315
{
293
- emit errorFound ( QgsGeometry::Error ( QObject::tr ( " polygon %1 has no rings" ).arg ( i ) ) );
316
+ emit errorFound ( QgsGeometry::Error ( QObject::tr ( " Polygon %1 has no rings" ).arg ( i ) ) );
294
317
mErrorCount ++;
295
318
continue ;
296
319
}
@@ -302,12 +325,12 @@ void QgsGeometryValidator::run()
302
325
303
326
if ( ringInRing ( mp[i][0 ], mp[j][0 ] ) )
304
327
{
305
- emit errorFound ( QgsGeometry::Error ( QObject::tr ( " polygon %1 inside polygon %2" ).arg ( i ).arg ( j ) ) );
328
+ emit errorFound ( QgsGeometry::Error ( QObject::tr ( " Polygon %1 lies inside polygon %2" ).arg ( i ).arg ( j ) ) );
306
329
mErrorCount ++;
307
330
}
308
331
else if ( ringInRing ( mp[j][0 ], mp[i][0 ] ) )
309
332
{
310
- emit errorFound ( QgsGeometry::Error ( QObject::tr ( " polygon %1 inside polygon %2" ).arg ( j ).arg ( i ) ) );
333
+ emit errorFound ( QgsGeometry::Error ( QObject::tr ( " Polygon %1 lies inside polygon %2" ).arg ( j ).arg ( i ) ) );
311
334
mErrorCount ++;
312
335
}
313
336
else
@@ -320,7 +343,6 @@ void QgsGeometryValidator::run()
320
343
321
344
else if ( flatType == QgsWkbTypes::Unknown )
322
345
{
323
- QgsDebugMsg ( QObject::tr ( " Unknown geometry type" ) );
324
346
emit errorFound ( QgsGeometry::Error ( QObject::tr ( " Unknown geometry type %1" ).arg ( mGeometry .wkbType () ) ) );
325
347
mErrorCount ++;
326
348
}
0 commit comments