From ad72b73f196964550296649acf2ec2d45368d0c3 Mon Sep 17 00:00:00 2001 From: Julien Osman Date: Thu, 29 Oct 2020 09:28:21 +0100 Subject: [PATCH] BUG: Put back KeywordList in image writing process --- Modules/IO/IOGDAL/src/otbGDALImageIO.cxx | 20 +++++++++++++++++++ .../IO/ImageIO/include/otbImageFileWriter.hxx | 1 + 2 files changed, 21 insertions(+) diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index efd461e020..44d115ea8e 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1538,6 +1538,26 @@ 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 91b3a88541..afd716bdde 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.hxx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.hxx @@ -553,6 +553,7 @@ void ImageFileWriter::GenerateOutputInformation(void) } m_ImageIO->SetUseCompression(m_UseCompression); + m_ImageIO->SetMetaDataDictionary(inputPtr->GetMetaDataDictionary()); const ImageCommons* img_common = dynamic_cast(inputPtr.GetPointer()); if (img_common != nullptr) -- GitLab