Skip to content

Commit

Permalink
fix(qgsfeaturepool): better synchronization between cache and spatial…
Browse files Browse the repository at this point in the history
… index
  • Loading branch information
Djedouas committed Aug 29, 2024
1 parent 57fce5a commit cf0da99
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,21 @@ bool QgsFeaturePool::getFeature( QgsFeatureId id, QgsFeature &feature )
}
locker.changeMode( QgsReadWriteLocker::Write );
mFeatureCache.insert( id, new QgsFeature( feature ) );
mIndex.addFeature( feature );

QgsGeometry indexGeom = mIndex.geometry( id );

// feature not in the index: add it
if ( indexGeom.isNull() )
mIndex.addFeature( feature );

// feature already in the index but with a different geometry (it has been evicted from the cache and externally modified):
// remove the old geometry and add the new one
else if ( !mIndex.geometry( id ).equals( feature.geometry() ) )
{
mIndex.deleteFeature( id, indexGeom.boundingBox() );
mIndex.addFeature( feature );
}

}
return true;
}
Expand Down

0 comments on commit cf0da99

Please sign in to comment.