Skip to content

Commit

Permalink
Merge pull request #10794 from rouault/fix_geojson_update_feature
Browse files Browse the repository at this point in the history
MEM layer: fix UpdateFeature() that didn't mark the layer as updated, which caused GeoJSON files to not be updated
  • Loading branch information
rouault authored Sep 18, 2024
2 parents 6c1d64a + 21dba70 commit 0178ae6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions autotest/ogr/ogr_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,11 @@ def test_ogr_geojson_48(tmp_vsimem):
# Test UpdateFeature() support


def test_ogr_geojson_update_feature(tmp_vsimem):
@pytest.mark.parametrize("check_after_update_before_reopen", [True, False])
@pytest.mark.parametrize("sync_to_disk_after_update", [True, False])
def test_ogr_geojson_update_feature(
tmp_vsimem, check_after_update_before_reopen, sync_to_disk_after_update
):

filename = str(tmp_vsimem / "test.json")

Expand All @@ -1821,13 +1825,21 @@ def test_ogr_geojson_update_feature(tmp_vsimem):
lyr = ds.GetLayer(0)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetFID(0)
f["int64list"] = [123456790123, -123456790123]
f["int64list"] = [-123456790123, 123456790123]
lyr.UpdateFeature(f, [0], [], False)

if sync_to_disk_after_update:
lyr.SyncToDisk()

if check_after_update_before_reopen:
lyr.ResetReading()
f = lyr.GetNextFeature()
assert f["int64list"] == [-123456790123, 123456790123]

with ogr.Open(filename) as ds:
lyr = ds.GetLayer(0)
f = lyr.GetNextFeature()
assert f["int64list"] == [123456790123, -123456790123]
assert f["int64list"] == [-123456790123, 123456790123]


###############################################################################
Expand Down
3 changes: 3 additions & 0 deletions ogr/ogrsf_frmts/mem/ogrmemlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ OGRErr OGRMemLayer::IUpdateFeature(OGRFeature *poFeature,
{
poFeatureRef->SetStyleString(poFeature->GetStyleString());
}

m_bUpdated = true;

return OGRERR_NONE;
}

Expand Down

0 comments on commit 0178ae6

Please sign in to comment.