Commit 0e307262 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

ENH: update import metadata test

parent f9cccd08
......@@ -965,7 +965,6 @@ void GDALImageIO::InternalReadImageInformation()
}
}
/* -------------------------------------------------------------------- */
/* Report subdatasets. */
/* -------------------------------------------------------------------- */
......@@ -1091,7 +1090,6 @@ void GDALImageIO::InternalReadImageInformation()
this->SetPixelType(VECTOR);
}
// Read no data value if present
std::vector<bool> isNoDataAvailable(dataset->GetRasterCount(), false);
std::vector<double> noDataValues(dataset->GetRasterCount(), 0);
......@@ -1927,6 +1925,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)
{
......@@ -1934,6 +1933,7 @@ void GDALImageIO::ImportMetadata()
GDALMetadataToKeywordlist(m_Dataset->GetDataSet()->GetRasterBand(band+1)->GetMetadata(), kwl);
m_Imd.Bands[band].FromKeywordlist(kwl);
}
}
void GDALImageIO::KeywordlistToMetadata(ImageMetadataBase::Keywordlist kwl, int band)
......@@ -1966,6 +1966,11 @@ void GDALImageIO::KeywordlistToMetadata(ImageMetadataBase::Keywordlist kwl, int
void GDALImageIO::GDALMetadataToKeywordlist(const char* const* metadataList, ImageMetadataBase::Keywordlist &kwl)
{
if (!metadataList)
{
return;
}
// The GDAL metadata string list is formatted as a “Name=value” list with the last pointer value being NULL.
for ( ; *metadataList != nullptr ; ++metadataList )
{
......
......@@ -31,7 +31,7 @@ otbGDALReadPxlComplex.cxx
otbGDALImageIOTestCanRead.cxx
otbMultiDatasetReadingInfo.cxx
otbOGRVectorDataIOCanRead.cxx
otbGDALImageIOImportExportMetadata.cxx
otbGDALImageIOImportMetadata.cxx
otbGDALRPCTransformerTest.cxx
otbGDALRPCTransformerTest2.cxx
)
......@@ -133,12 +133,11 @@ otb_add_test(NAME ioTvGDALImageIOWriteMetadata COMMAND otbIOGDALTestDriver
)
# TODO implement this test
otb_add_test(NAME ioTvGDALImageIOImportExportMetadata_JPEG_99 COMMAND otbIOGDALTestDriver
otb_add_test(NAME ioTvGDALImageIOImportMetadata COMMAND otbIOGDALTestDriver
# --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
# ${TEMP}/ioTvGDALImageIOImportExportMetadata_JPEG_99.txt
otbGDALImageIOImportExportMetadata
otbGDALImageIOImportMetadata
${INPUTDATA}/metadataIOexample.tif
${TEMP}/ioTvGDALImageIOImportExportMetadata.tif
${TEMP}/ioTvGDALImageIOImportMetadata.txt
)
......
......@@ -29,39 +29,27 @@
//
//};
int otbGDALImageIOImportExportMetadata(int itkNotUsed(argc), char* argv[])
int otbGDALImageIOImportMetadata(int itkNotUsed(argc), char* argv[])
{
// Verify the number of parameters in the command line
const char* inputFilename = argv[1];
const char* outputFilename = argv[2];
const char* outputReaderFilename = argv[3];
const char* outputReaderFilename = argv[2];
std::ofstream outfileR(outputReaderFilename);
otb::GDALImageIO::Pointer readerGDAL = otb::GDALImageIO::New();
auto readerGDAL = otb::GDALImageIO::New();
readerGDAL->SetFileName(inputFilename);
if (readerGDAL->CanReadFile(inputFilename))
{
std::cout << "Read file OK" << std::endl;
readerGDAL->ReadImageInformation();
outfileR << readerGDAL->GetImageMetadata();
}
{
readerGDAL->ReadImageInformation();
outfileR << readerGDAL->GetImageMetadata();
}
else
{
std::cout << "Read file K0" << std::endl;
{
std::cout << "GDALImageIO cannot read the input file: "
<< inputFilename << std::endl;
return EXIT_FAILURE;
}
otb::GDALImageIO::Pointer writerGDAL = otb::GDALImageIO::New();
if(writerGDAL->CanWriteFile(outputFilename))
{
writerGDAL->WriteImageInformation();
}
else
{
return EXIT_FAILURE ;
}
}
return EXIT_SUCCESS;
}
......@@ -33,7 +33,7 @@ void RegisterTests()
REGISTER_TEST(otbGDALImageIOTestCanRead);
REGISTER_TEST(otbMultiDatasetReadingInfo);
REGISTER_TEST(otbOGRVectorDataIOTestCanRead);
REGISTER_TEST(otbGDALImageIOImportExportMetadata);
REGISTER_TEST(otbGDALImageIOImportMetadata);
REGISTER_TEST(otbGDALRPCTransformerTest);
REGISTER_TEST(otbGDALRPCTransformerTest2);
}
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