From c644e75a464f03c3ba187ae18685f7d33fe4f3cd Mon Sep 17 00:00:00 2001 From: Julien Osman <julien.osman@csgroup.eu> Date: Mon, 19 Oct 2020 11:55:53 +0200 Subject: [PATCH] ENH: Deactivate GEOM writing --- .../Metadata/src/otbGeomMetadataSupplier.cxx | 4 +++- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 21 +------------------ .../IO/ImageIO/include/otbImageFileWriter.hxx | 19 ----------------- 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx index 190f24ff1b..2508336c54 100644 --- a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx +++ b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx @@ -20,6 +20,7 @@ #include <iomanip> #include <iostream> +#include<boost/algorithm/string.hpp> #include "otbGeomMetadataSupplier.h" #include "otbMetaDataKey.h" @@ -55,10 +56,11 @@ int GeomMetadataSupplier::GetNbBands() const { bool hasValue; std::string ret = this->GetMetadataValue("support_data.band_name_list", hasValue); + boost::algorithm::trim_if(ret, boost::algorithm::is_any_of("\" ")); if (!hasValue) otbGenericExceptionMacro(MissingMetadataException,<<"Missing metadata 'support_data.band_name_list'") std::vector<std::string> ret_vect; - otb::Utils::ConvertStringToVector(ret, ret_vect, "band name"); + otb::Utils::ConvertStringToVector(ret, ret_vect, "band name"); return ret_vect.size(); } diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 1018f93052..efd461e020 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1308,7 +1308,7 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) } // TODO : this should be a warning instead of an exception - // For complex pixels the number of bands is twice the number of compnents (in GDAL sense) + // For complex pixels the number of bands is twice the number of components (in GDAL sense) if ( !m_Imd.Bands.empty() && static_cast<std::size_t>(m_NbBands) != m_Imd.Bands.size() && !((m_Imd.Bands.size() == static_cast<std::size_t>(2 * m_NbBands)) && this->GetPixelType() == COMPLEX)) @@ -1538,25 +1538,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) CSLDestroy(rpcMetadata); } } - // ToDo : remove this part. This case is here for compatibility for images - // that still use Ossim for managing the sensor model (with OSSIMKeywordList). - else if (otb_kwl.GetSize()) - { - /* -------------------------------------------------------------------- */ - /* Set the RPC coeffs (since GDAL 1.10.0) */ - /* -------------------------------------------------------------------- */ - if (m_WriteRPCTags) - { - GDALRPCInfo gdalRpcStruct; - if (otb_kwl.convertToGDALRPC(gdalRpcStruct)) - { - otbLogMacro(Debug, << "Saving RPC to file (" << m_FileName << ")") - char** rpcMetadata = RPCInfoToMD(&gdalRpcStruct); - dataset->SetMetadata(rpcMetadata, "RPC"); - CSLDestroy(rpcMetadata); - } - } - } /* -------------------------------------------------------------------- */ /* Case 3: Set the GCPs */ /* -------------------------------------------------------------------- */ diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.hxx b/Modules/IO/ImageIO/include/otbImageFileWriter.hxx index 24c7d409a6..91b3a88541 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.hxx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.hxx @@ -553,7 +553,6 @@ void ImageFileWriter<TInputImage>::GenerateOutputInformation(void) } m_ImageIO->SetUseCompression(m_UseCompression); - m_ImageIO->SetMetaDataDictionary(inputPtr->GetMetaDataDictionary()); const ImageCommons* img_common = dynamic_cast<const ImageCommons*>(inputPtr.GetPointer()); if (img_common != nullptr) @@ -667,16 +666,6 @@ void ImageFileWriter<TInputImage>::Update() source->RemoveObserver(m_ObserverID); } - // Write the image keyword list if any - // ossimKeywordlist geom_kwl; - // ImageKeywordlist otb_kwl; - - // itk::MetaDataDictionary dict = this->GetInput()->GetMetaDataDictionary(); - // itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl); - // otb_kwl.convertToOSSIMKeywordlist(geom_kwl); - // FIXME: why nothing is done with otb_kwl in that case??? - // If required, put a call to WriteGeometry() here - /** * Release any inputs if marked for release */ @@ -803,14 +792,6 @@ void ImageFileWriter<TInputImage>::GenerateData(void) } m_ImageIO->Write(dataPtr); - - if (m_WriteGeomFile || m_FilenameHelper->GetWriteGEOMFile()) - { - ImageKeywordlist otb_kwl; - itk::MetaDataDictionary dict = this->GetInput()->GetMetaDataDictionary(); - itk::ExposeMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, otb_kwl); - WriteGeometry(otb_kwl, this->GetFileName()); - } } template <class TInputImage> -- GitLab