#2786 closed defect (fixed)
TIFF SetMetadata corrupts XML string
Reported by: | gaopeng | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.4 |
Component: | GDAL_Raster | Version: | 1.6.0 |
Severity: | normal | Keywords: | GTiff |
Cc: |
Description
Attached are two files containing what was written to TIFF using SetMetadata, and the metadata read back from the tiff. The returned metadata in the metadata domain, <Metadata domain="xml:ESRI" format="xml">, is no longer a valid XML string.
It's not clear when the XML is changed, before it's written to TIFF, or before it's returned from tiff driver.
Attachments (3)
Change History (8)
by , 15 years ago
Attachment: | palmsprings_1tif_good_xml.xml added |
---|
by , 15 years ago
Attachment: | palmsprings_1tif_bad_xml.xml added |
---|
by , 15 years ago
Attachment: | palmsprings_1tif.tif added |
---|
comment:1 by , 15 years ago
Component: | default → GDAL_Raster |
---|---|
Keywords: | GTiff added; Raster removed |
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 15 years ago
Frank,
I am using GDAL 1.6.0. However I did have a minor local fix, which added ! in front of EQUAL. Otherwise the metadata are not saved.
CPLErr GTiffDataset::SetMetadata( char papszMD, const char *pszDomain )
{
if( pszDomain == NULL !EQUAL(pszDomain,"_temporary_") ) bMetadataChanged = TRUE;
return oGTiffMDMD.SetMetadata( papszMD, pszDomain );
}
comment:3 by , 15 years ago
I have confirmed the original bug, using the following mechanism:
#include "gdal_priv.h" int main() { char *apszMD[2] = { "<GeodataXform xsi:type=\"typens:PolynomialXform\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:typens=\"http://www.esri.com/schemas/ArcGIS/9.3\"> <PolynomialOrder>2</PolynomialOrder> </GeodataXform>", NULL }; GDALAllRegister(); GDALDataset *poDS = (GDALDataset *) GDALOpen("wrk.tif",GA_Update); poDS->SetMetadata( apszMD, "xml:ESRI" ); GDALClose( (GDALDatasetH) poDS ); }
The problem seems to be missing support for the special xml: domain prefix in the GeoTIFF driver. There are also issues with the geotiff driver's _temporary_ tests which I will fix.
comment:4 by , 15 years ago
Milestone: | 1.6.1 → 1.5.4 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
I have corrected the GeoTIFF driver to support the special handling of xml: domain metadata in trunk (r16147) and 1.6 branch (r16148). I have also added testing for this in autotest (r16150).
Unfortunately, the xml metadata in any previously produced files will be corrupt.
I have also ported a small variation on this into 1.5 branch (r16161).
Gao,
The TIFF file is rather badly corrupted in the metadata tag. I have been unable to reproduce a similar problem writing out metadata. I used the following script with trunk, 1.5, and 1.4 branches. Can you indicate what version the file was generated with?