Commit 6ed3c4b2 authored by Julie Brossard's avatar Julie Brossard Committed by Cédric Traizet
Browse files

[WIP] Import metadata in FileReader

parent fd386a12
......@@ -922,6 +922,10 @@ void GDALImageIO::InternalReadImageInformation()
/* Report metadata. */
/* -------------------------------------------------------------------- */
ImportMetadata() ;
papszMetadata = dataset->GetMetadata(nullptr);
if (CSLCount(papszMetadata) > 0)
{
......@@ -1927,6 +1931,7 @@ void GDALImageIO::ImportMetadata()
m_Imd.FromKeywordlist(kwl);
// GCPs are imported directly in the ImageMetadata.
m_Imd.Add(MDGeom::GCP, m_Dataset->GetGCPParam());
// Parsing the bands
for (int band = 0 ; band < m_NbBands ; ++band)
{
......@@ -1942,7 +1947,7 @@ void GDALImageIO::KeywordlistToMetadata(ImageMetadataBase::Keywordlist kwl, int
{
if (kv.first == MetaData::MDGeomNames.left.at(MDGeom::SensorGeometry))
{
SetMetadataValue("OTB/MDGeomNames[MDGeom::SensorGeometry].", kv.second.c_str(), band);
SetMetadataValue("MDGeomNames[MDGeom::SensorGeometry].", kv.second.c_str(), band);
}
else if (kv.first == MetaData::MDGeomNames.left.at(MDGeom::RPC))
{
......@@ -1957,9 +1962,9 @@ void GDALImageIO::KeywordlistToMetadata(ImageMetadataBase::Keywordlist kwl, int
// Projection have already been exported (see InternalWriteImageInformation)
}
else{
std::string domain = "OTB";
std::string path = domain + "/" + kv.first ;
SetMetadataValue(path.c_str(), kv.second.c_str(), band);
// std::string domain = "OTB";
// std::string path = domain + "/" + kv.first ;
SetMetadataValue(kv.first.c_str(), kv.second.c_str(), band);
}
}
}
......@@ -2013,8 +2018,10 @@ void GDALImageIO::GDALMetadataToKeywordlist(const char* const* metadataList, Ima
m_Imd.Add(MDGeom::RPC, rpcStruct);
}
else
else{
std::cout << fieldName << ":: " << fieldValue << std::endl ;
kwl.emplace(fieldName, fieldValue);
}
}
}
......
......@@ -133,14 +133,14 @@ otb_add_test(NAME ioTvGDALImageIOWriteMetadata COMMAND otbIOGDALTestDriver
)
# TODO implement this test
# otb_add_test(NAME ioTvGDALImageIOImportExportMetadata_JPEG_99 COMMAND otbIOGDALTestDriver
# --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
# ${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
# otbGDALImageIOImportExportMetadata
# ${INPUTDATA}/maur_rgb_24bpp.tif
# ${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.tif
# ${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
# )
otb_add_test(NAME ioTvGDALImageIOImportExportMetadata_JPEG_99 COMMAND otbIOGDALTestDriver
--compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
otbGDALImageIOImportExportMetadata
/datas/Documents_Julie/Logiciels/OTB/bin/build/OTB/build/roi.tif
${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.tif
${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
)
otb_add_test(NAME ioTvGDALOverviewsBuilder_TIFF COMMAND otbIOGDALTestDriver
otbGDALOverviewsBuilder
......
......@@ -37,6 +37,20 @@ int otbGDALImageIOImportExportMetadata(int itkNotUsed(argc), char* argv[])
const char* outputTextFilename = argv[3];
std::ofstream outfile(outputTextFilename);
otb::GDALImageIO::Pointer readerGDAL = otb::GDALImageIO::New();
readerGDAL->SetFileName(inputFilename);
if (readerGDAL->CanReadFile(inputFilename))
{
std::cout << "Read file OK" << std::endl;
readerGDAL->ReadImageInformation();
outfile << readerGDAL->GetImageMetadata();
}
else
{
std::cout << "Read file K0" << std::endl;
return EXIT_FAILURE;
}
// otb::sGDALImageIO::Pointer io = otb::sGDALImageIO::New();
// io->CanReadFile(inputFilename);
......
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