Skip to content
Permalink
Browse files

[geometry fixer] overlapcheck incorectly snaps corrected feature to grid

(cherry picked from commit c97e324)
  • Loading branch information
olivierdalang authored and nyalldawson committed Nov 20, 2020
1 parent 75a3cd7 commit 643648c8e8b51b092f992102706a44662e8ea12d
@@ -153,7 +153,9 @@ void QgsGeometryOverlapCheck::fixError( const QMap<QString, QgsFeaturePool *> &f
}
else if ( method == Subtract )
{
std::unique_ptr< QgsAbstractGeometry > diff1( geomEngineA->difference( interPart, &errMsg ) );
std::unique_ptr< QgsGeometryEngine > geomEngineDiffA = QgsGeometryCheckerUtils::createGeomEngine( geometryA.constGet(), 0 );
geomEngineDiffA->prepareGeometry();
std::unique_ptr< QgsAbstractGeometry > diff1( geomEngineDiffA->difference( interPart, &errMsg ) );
if ( !diff1 || diff1->isEmpty() )
{
diff1.reset();
@@ -162,9 +164,9 @@ void QgsGeometryOverlapCheck::fixError( const QMap<QString, QgsFeaturePool *> &f
{
QgsGeometryCheckerUtils::filter1DTypes( diff1.get() );
}
std::unique_ptr< QgsGeometryEngine > geomEngineB = QgsGeometryCheckerUtils::createGeomEngine( geometryB.constGet(), mContext->reducedTolerance );
geomEngineB->prepareGeometry();
std::unique_ptr< QgsAbstractGeometry > diff2( geomEngineB->difference( interPart, &errMsg ) );
std::unique_ptr< QgsGeometryEngine > geomEngineDiffB = QgsGeometryCheckerUtils::createGeomEngine( geometryB.constGet(), 0 );
geomEngineDiffB->prepareGeometry();
std::unique_ptr< QgsAbstractGeometry > diff2( geomEngineDiffB->difference( interPart, &errMsg ) );
if ( !diff2 || diff2->isEmpty() )
{
diff2.reset();
@@ -1212,6 +1212,9 @@ void TestQgsGeometryChecks::testOverlapCheckToleranceBug()
{
// The overlap (intersection) was computed with a different tolerance when collecting errors
// than when fixing them, leading to failures to fix the issue esp. with big coordinates.
//
// Also, it used to offset unaffected points (far from the actual overlap) on the affected
// feature, leading to both unwanted shifts and remaining slivers.

QTemporaryDir dir;
QMap<QString, QString> layers;
@@ -1240,7 +1243,11 @@ void TestQgsGeometryChecks::testOverlapCheckToleranceBug()
QgsFeature f;
testContext.second[layers["overlap_layer_tolerance_bug.shp"]]->getFeature( 0, f );
double areaOld = f.geometry().area();
QgsPoint pointOld_1 = f.geometry().vertexAt( 1 );
QgsPoint pointOld_2 = f.geometry().vertexAt( 2 );
QCOMPARE( areaOld, 10442.710061549426 );
QCOMPARE( pointOld_1, QgsPoint( 2537221.53079314017668366, 1152360.02460834058001637 ) );
QCOMPARE( pointOld_2, QgsPoint( 2537366.84566075634211302, 1152360.28978145681321621 ) );

QgsGeometryCheck::Changes changes;
QMap<QString, int> mergeAttrs;
@@ -1252,6 +1259,9 @@ void TestQgsGeometryChecks::testOverlapCheckToleranceBug()
// Ensure it actually worked
testContext.second[layers["overlap_layer_tolerance_bug.shp"]]->getFeature( 0, f );
QVERIFY( f.geometry().area() < areaOld );
// And that we don't have unexpected changes on unaffected points
QCOMPARE( f.geometry().vertexAt( 1 ), pointOld_1 );
QCOMPARE( f.geometry().vertexAt( 2 ), pointOld_2 );

cleanupTestContext( testContext );
}

0 comments on commit 643648c

Please sign in to comment.
You can’t perform that action at this time.