Skip to content

Commit

Permalink
Merge pull request #11471 from rouault/fix_11470
Browse files Browse the repository at this point in the history
Do not sort items in IMD metadata domain
  • Loading branch information
rouault authored Dec 10, 2024
2 parents f6b2cd5 + 2e46729 commit a72535d
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 a72535d

Please sign in to comment.