@@ -441,36 +441,16 @@ def check_geometry( self, vlayer ):
441
441
geom = QgsGeometry ( feat .geometry () )
442
442
self .emit ( SIGNAL ( "runStatus(PyQt_PyObject)" ), nElement )
443
443
nElement += 1
444
- if geom .isMultipart ():
445
- polygons = geom .asMultiPolygon ()
446
- for polygon in polygons :
447
- if not self .isHoleNested ( polygon ):
448
- lstErrors .append ( self .tr ( "Feature %1 contains an unnested hole" ).arg ( unicode ( feat .id () ) ) )
449
- count += 1
450
- if not self .isPolygonClosed ( polygon ):
451
- lstErrors .append ( self .tr ( "Feature %1 is not closed" ).arg ( unicode ( feat .id () ) ) )
452
- count += 1
453
- if self .isSelfIntersecting ( polygon ):
454
- lstErrors .append ( self .tr ( "Feature %1 is self intersecting" ).arg ( unicode ( feat .id () ) ) )
455
- count += 1
456
- if not self .isCorrectOrientation ( polygon ):
457
- lstErrors .append ( self .tr ( "Feature %1 has incorrect node ordering" ).arg ( unicode ( feat .id () ) ) )
458
- count += 1
459
-
460
- else :
461
- geom = geom .asPolygon ()
462
- if not self .isHoleNested ( geom ):
463
- lstErrors .append ( self .tr ( "Feature %1 contains an unnested hole" ).arg ( unicode ( feat .id () ) ) )
464
- count += 1
465
- if not self .isPolygonClosed ( geom ):
466
- lstErrors .append ( self .tr ( "Feature %1 is not closed" ).arg ( unicode ( feat .id () ) ) )
467
- count += 1
468
- if self .isSelfIntersecting ( geom ):
469
- lstErrors .append ( self .tr ( "Feature %1 is self intersecting" ).arg ( unicode ( feat .id () ) ) )
470
- count += 1
471
- if not self .isCorrectOrientation ( geom ):
472
- lstErrors .append ( self .tr ( "Feature %1 has incorrect node ordering" ).arg ( unicode ( feat .id () ) ) )
473
- count += 1
444
+
445
+ errors = geom .validateGeometry ()
446
+ if len (errors ) > 0 :
447
+ lstErrors .append ( self .tr ( "Feature %1 has %2 errors:" ).arg ( feat .id () ).arg ( uni
448
+ for e in errors :
449
+ if e .hasWhere ():
450
+ lstErrors .append ( self .tr ( "Feature %1: %2 [%3]" ).arg ( feat .id () ).arg ( e .what () ).arg ( e .where () ) )
451
+ else :
452
+ lstErrors .append ( self .tr ( "Feature %1: %2 [%3]" ).arg ( feat .id () ).arg ( e .what () ).arg ( e .where () ) )
453
+
474
454
self .emit ( SIGNAL ( "runStatus(PyQt_PyObject)" ), nFeat )
475
455
return ( lstErrors , count )
476
456
0 commit comments