@@ -483,6 +483,13 @@ ErrorList topolTest::checkOverlaps( double tolerance, QgsVectorLayer *layer1, Qg
483
483
break ;
484
484
485
485
QgsGeometry* g1 = it->feature .geometry ();
486
+
487
+ if ( g1->isGeosValid () == false )
488
+ {
489
+ qDebug () << " invalid geometry(g1) found..skipping.." << it->feature .id ();
490
+ continue ;
491
+ }
492
+
486
493
QgsRectangle bb = g1->boundingBox ();
487
494
488
495
QList<QgsFeatureId> crossingIds;
@@ -515,12 +522,22 @@ ErrorList topolTest::checkOverlaps( double tolerance, QgsVectorLayer *layer1, Qg
515
522
continue ;
516
523
}
517
524
525
+ if ( g2->isGeosValid () == false )
526
+ {
527
+ qDebug () << " invalid geometry(g2) found..skipping.." << it->feature .id ();
528
+ continue ;
529
+ }
530
+
531
+
532
+ qDebug () << " checking overlap for" << it->feature .id ();
518
533
if (g1->overlaps (g2))
519
534
{
520
535
duplicate = true ;
521
536
duplicateIds->append ( mFeatureMap2 [*cit].feature .id () );
522
537
}
523
538
539
+
540
+
524
541
if ( duplicate )
525
542
{
526
543
QList<FeatureLayer> fls;
@@ -599,7 +616,30 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
599
616
{
600
617
continue ;
601
618
}
602
- geomList.push_back ( GEOSGeom_clone ( g1->asGeos () ) );
619
+
620
+ if ( g1->isGeosValid () == false )
621
+ {
622
+ qDebug () << " invalid geometry found..skipping.." << it->feature .id ();
623
+ continue ;
624
+ }
625
+
626
+ if ( g1->isMultipart () )
627
+ {
628
+ QgsMultiPolygon polys = g1->asMultiPolygon ();
629
+ for ( int m = 0 ; m < polys.count (); m++ )
630
+ {
631
+ QgsPolygon polygon = polys[m];
632
+
633
+ QgsGeometry* polyGeom = QgsGeometry::fromPolygon (polygon);
634
+
635
+ geomList.push_back ( GEOSGeom_clone (polyGeom->asGeos ()) );
636
+ }
637
+
638
+ }
639
+ else
640
+ {
641
+ geomList.push_back ( GEOSGeom_clone ( g1->asGeos () ) );
642
+ }
603
643
}
604
644
605
645
GEOSGeometry** geomArray = new GEOSGeometry*[geomList.size ()];
@@ -629,22 +669,20 @@ ErrorList topolTest::checkGaps( double tolerance, QgsVectorLayer *layer1, QgsVec
629
669
test.fromGeos ( unionGeom );
630
670
631
671
632
- qDebug () << " wktmerged - " << test.exportToWkt ();
672
+ // qDebug() << "wktmerged - " << test.exportToWkt();
633
673
634
674
QString extentWkt = test.boundingBox ().asWktPolygon ();
635
675
QgsGeometry* extentGeom = QgsGeometry::fromWkt ( extentWkt );
636
676
QgsGeometry* bufferExtent = extentGeom->buffer ( 2 , 3 );
637
677
638
- qDebug () << " extent wkt - " << bufferExtent->exportToWkt ();
678
+ // qDebug() << "extent wkt - " << bufferExtent->exportToWkt();
639
679
640
680
QgsGeometry* diffGeoms = bufferExtent->difference ( &test );
641
681
642
- qDebug () << " difference gometry - " << diffGeoms->exportToWkt () ;
682
+ // qDebug() << "difference gometry - " << diffGeoms->exportToWkt() ;
643
683
644
684
QList<QgsGeometry*> geomColl = diffGeoms->asGeometryCollection ();
645
685
646
- // QList<QgsGeometry*> geomColl = test.asGeometryCollection();
647
-
648
686
QgsGeometry* canvasExtentPoly = QgsGeometry::fromWkt (theQgsInterface->mapCanvas ()->extent ().asWktPolygon ());
649
687
650
688
for ( int i = 1 ; i < geomColl.count () ; ++i )
0 commit comments