Skip to content

Commit

Permalink
Use a prepared geometry in topology checker overlap check
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 5, 2019
1 parent b4c1f0a commit 70fe6c8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/plugins/topology/topolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ ErrorList topolTest::checkOverlaps( QgsVectorLayer *layer1, QgsVectorLayer *laye
continue;
}

std::unique_ptr< QgsGeometryEngine > engine1( QgsGeometry::createGeometryEngine( g1.constGet() ) );
engine1->prepareGeometry();

QgsRectangle bb = g1.boundingBox();

QList<QgsFeatureId> crossingIds;
Expand All @@ -397,7 +400,7 @@ ErrorList topolTest::checkOverlaps( QgsVectorLayer *layer1, QgsVectorLayer *laye

bool duplicate = false;

QgsGeometry canvasExtentPoly = QgsGeometry::fromWkt( qgsInterface->mapCanvas()->extent().asWktPolygon() );
QgsGeometry canvasExtentPoly = QgsGeometry::fromRect( qgsInterface->mapCanvas()->extent() );

for ( ; cit != crossingIdsEnd; ++cit )
{
Expand All @@ -416,21 +419,14 @@ ErrorList topolTest::checkOverlaps( QgsVectorLayer *layer1, QgsVectorLayer *laye
continue;
}

if ( !_canExportToGeos( g2 ) )
{
QgsMessageLog::logMessage( tr( "Failed to import second geometry into GEOS in overlaps test." ), tr( "Topology plugin" ) );
continue;
}

if ( !g2.isGeosValid() )
{
QgsMessageLog::logMessage( tr( "Skipping invalid second geometry of feature %1 in overlaps test." ).arg( it->feature.id() ), tr( "Topology plugin" ) );
continue;
}


qDebug() << "checking overlap for" << it->feature.id();
if ( g1.overlaps( g2 ) )
if ( engine1->overlaps( g2.constGet() ) )
{
duplicate = true;
duplicateIds->append( mFeatureMap2[*cit].feature.id() );
Expand Down

0 comments on commit 70fe6c8

Please sign in to comment.