Commit 06c6cca6 authored by Guillaume Pasero's avatar Guillaume Pasero

BUG: #1589: detect the correct metadata on S1 .SAFE

parent c06425ec
......@@ -435,7 +435,7 @@ void GDALImageIO::InternalReadImageInformation()
// supported gdal format using the m_DatasetNumber value
// HDF4_SDS:UNKNOWN:"myfile.hdf":2
// and make m_Dataset point to it.
if (m_Dataset->GetDataSet()->GetRasterCount() == 0)
if (m_Dataset->GetDataSet()->GetRasterCount() == 0 || m_DatasetNumber > 0)
{
// this happen in the case of a hdf file with SUBDATASETS
// Note: we assume that the datasets are in order
......@@ -659,6 +659,24 @@ void GDALImageIO::InternalReadImageInformation()
}
}
// get list of other files part of the same dataset
char** datasetFileList = dataset->GetFileList();
m_AttachedFileNames.clear();
if (datasetFileList != nullptr)
{
char** currentFile = datasetFileList;
while (*currentFile != nullptr)
{
if (m_FileName.compare(*currentFile) != 0)
{
m_AttachedFileNames.emplace_back(*currentFile);
otbLogMacro(Debug,<<"Found attached file : "<< *currentFile);
}
currentFile++;
}
CSLDestroy(datasetFileList);
}
/*----------------------------------------------------------------------*/
/*-------------------------- METADATA ----------------------------------*/
/*----------------------------------------------------------------------*/
......
......@@ -433,7 +433,20 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
}
else
{
otbLogMacro(Info,<< "No kwl metadata found in file "<<lFileNameOssimKeywordlist);
// Try attached files
for (const std::string& path : m_ImageIO->GetAttachedFileNames())
{
otb_kwl = ReadGeometryFromImage(path,!m_FilenameHelper->GetSkipRpcTag());
if(!otb_kwl.Empty())
{
otbLogMacro(Info,<< "Loading kwl metadata in attached file "<<path);
break;
}
}
if (otb_kwl.Empty())
{
otbLogMacro(Info,<< "No kwl metadata found in file "<<lFileNameOssimKeywordlist);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment