Commit 3cd0f3e5 authored by Julien Osman's avatar Julien Osman

FIX: Update the test with the new API

parent a37eb1ca
......@@ -81,6 +81,8 @@ public:
bool HasValue(std::string path, int band=-1);
virtual int GetNbBands() const = 0;
// utility functions
template <typename T> T GetAs(std::string path, int band=-1) const
{
......
......@@ -51,6 +51,8 @@ public:
std::string GetResourceFile(std::string="") const override;
int GetNbBands() const override;
std::string PrintSelf();
protected:
......
......@@ -403,7 +403,7 @@ std::vector<OTB_calibrationVector> Sentinel1ImageMetadataInterface::GetCalibrati
void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds)
{
assert(mds);
assert(mds->GetNbBands() == this->m_Imd.GetNbBands());
assert(mds->GetNbBands() == this->m_Imd.Bands.size());
// Metadata read by GDAL
//Fetch(MDTime::AcquisitionStartTime, mds, "ACQUISITION_START_TIME");
//Fetch(MDTime::AcquisitionStopTime, mds, "ACQUISITION_STOP_TIME");
......
......@@ -43,7 +43,7 @@ XMLMetadataSupplier::XMLMetadataSupplier(const std::string & fileName)
const std::string XMLMetadataSupplier::GetMetadataValue(const std::string path, bool& hasValue, int band) const
{
const char * ret = CSLFetchNameValue(m_MetadataDic, path);
const char * ret = CSLFetchNameValue(m_MetadataDic, path.c_str());
if (ret)
hasValue = true;
else
......@@ -165,6 +165,11 @@ char** XMLMetadataSupplier::ReadXMLToList(CPLXMLNode* psNode, char** papszList,
return papszList;
}
int XMLMetadataSupplier::GetNbBands() const
{
return 0;
}
std::string XMLMetadataSupplier::PrintSelf()
{
std::ostringstream oss;
......
......@@ -59,7 +59,5 @@ int otbImageMetadataInterfaceTest(int itkNotUsed(argc), char* argv[])
file << boost::any_cast<otb::Projection::GCPParam>(imd2[otb::MDGeom::GCP]).ToJSON(true);
file.close();
std::cout << mds2->printSomething() << std::endl;;
return EXIT_SUCCESS;
}
......@@ -27,10 +27,11 @@ int otbXMLMetadataSupplierTest(int itkNotUsed(argc), char* argv[])
const char* outputFilename = argv[2];
otb::XMLMetadataSupplier mds(fileName);
bool hasValue;
std::ofstream file;
file.open(outputFilename);
file << mds.GetMetadataValue("OTB.application.name") << "\n";
file << mds.GetMetadataValue("OTB.application.parameter_3.name") << "\n";
file << mds.GetMetadataValue("OTB.application.name", hasValue) << "\n";
file << mds.GetMetadataValue("OTB.application.parameter_3.name", hasValue) << "\n";
file.close();
return EXIT_SUCCESS;
......
......@@ -201,7 +201,7 @@ public:
/** Returns gdal pixel type as string */
std::string GetGdalPixelTypeAsString() const;
itkGetMacro(NbBands, int);
int GetNbBands() const override;
// MetadataSupplierInterface overrides
......
......@@ -1808,6 +1808,10 @@ std::string GDALImageIO::GetGdalPixelTypeAsString() const
return name;
}
int GDALImageIO::GetNbBands() const
{
return m_Dataset->GetDataSet()->GetRasterCount();
}
std::string GDALImageIO::GetResourceFile(std::string str) const
{
......
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