Skip to content

Commit

Permalink
Do not sort items in IMD metadata domain
Browse files Browse the repository at this point in the history
Fixes #11470
  • Loading branch information
rouault committed Dec 10, 2024
1 parent 1ee024f commit 2e46729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions autotest/gcore/tiff_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,10 @@ def test_tiff_read_md1():
md["ACQUISITIONDATETIME"] == "2010-04-01 12:00:00"
), "bad value for IMAGERY[ACQUISITIONDATETIME]"

# Check that IMD metadata domain is not sorted (https://github.com/OSGeo/gdal/issues/11470)
md = ds.GetMetadata_List("IMD")
assert md[0] == 'version="24.06"'

ds = None

assert not os.path.exists("data/md_dg.tif.aux.xml")
Expand Down
6 changes: 5 additions & 1 deletion gcore/gdalmultidomainmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ CPLErr GDALMultiDomainMetadata::SetMetadata(CSLConstList papszMetadata,
// we want to mark name/value pair domains as being sorted for fast
// access.
if (!STARTS_WITH_CI(pszDomain, "xml:") &&
!STARTS_WITH_CI(pszDomain, "json:") && !EQUAL(pszDomain, "SUBDATASETS"))
!STARTS_WITH_CI(pszDomain, "json:") &&
!EQUAL(pszDomain, "SUBDATASETS")
// The IMD metadata domain should not be sorted, as order matters
// when writing it back. Cf https://github.com/OSGeo/gdal/issues/11470
&& !EQUAL(pszDomain, "IMD"))
{
oMDList.Sort();
}
Expand Down

0 comments on commit 2e46729

Please sign in to comment.