From f6ea5b55e563b769c1fd885a688abc725483c074 Mon Sep 17 00:00:00 2001 From: Julien Osman <julien.osman@csgroup.eu> Date: Tue, 7 Jul 2020 14:19:46 +0200 Subject: [PATCH] FIX: Apply corrections to the Fetch methods Add a new Fetch method for the Extra metadata. And the other Fetch methods had an issue with fetching the metadata for the bands. --- .../include/otbImageMetadataInterfaceBase.h | 2 ++ .../src/otbImageMetadataInterfaceBase.cxx | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h index e3c1e0ebab..3f3bbff898 100644 --- a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h +++ b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h @@ -219,6 +219,8 @@ public: const MetaData::Time& Fetch(MDTime key, const MetadataSupplierInterface * mds, const char *path, int band=-1); + const std::string& Fetch(std::string key, const MetadataSupplierInterface * mds, const char *path, int band=-1); + const boost::any& FetchRPC(const MetadataSupplierInterface * mds); /** Reads into the MetaDataDictionary to find an OSSIM ImageKeywordlist, diff --git a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx index f9f6db186d..56410b71c1 100644 --- a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx @@ -630,7 +630,7 @@ ImageMetadataInterfaceBase::Fetch( if (band >= 0) { assert( (size_t)(band) < m_Imd.Bands.size()); - m_Imd.Bands[band].Add(key, mds->GetAs<std::string>(path)); + m_Imd.Bands[band].Add(key, mds->GetAs<std::string>(path, band)); return m_Imd.Bands[band][key]; } m_Imd.Add(key, mds->GetAs<std::string>(path) ); @@ -647,7 +647,7 @@ ImageMetadataInterfaceBase::Fetch( if (band >= 0) { assert( (size_t)(band) < m_Imd.Bands.size()); - m_Imd.Bands[band].Add(key, mds->GetAs<double>(path)); + m_Imd.Bands[band].Add(key, mds->GetAs<double>(path, band)); return m_Imd.Bands[band][key]; } m_Imd.Add(key, mds->GetAs<double>(path)); @@ -664,13 +664,30 @@ ImageMetadataInterfaceBase::Fetch( if (band >= 0) { assert( (size_t)(band) < m_Imd.Bands.size()); - m_Imd.Bands[band].Add(key, mds->GetAs<MetaData::Time>(path)); + m_Imd.Bands[band].Add(key, mds->GetAs<MetaData::Time>(path, band)); return m_Imd.Bands[band][key]; } m_Imd.Add(key, mds->GetAs<MetaData::Time>(path)); return m_Imd[key]; } +const std::string& +ImageMetadataInterfaceBase::Fetch( + std::string key, + const MetadataSupplierInterface * mds, + const char *path, + int band) +{ + if (band >= 0) + { + assert( (size_t)(band) < m_Imd.Bands.size()); + m_Imd.Bands[band].Add(key, mds->GetAs<std::string>(path, band)); + return m_Imd.Bands[band][key]; + } + m_Imd.Add(key, mds->GetAs<std::string>(path) ); + return m_Imd[key]; +} + const boost::any& ImageMetadataInterfaceBase::FetchRPC( const MetadataSupplierInterface * mds) { -- GitLab