From 0e723e704ad17a75e1123780cdd5ae3d98434e65 Mon Sep 17 00:00:00 2001 From: Julien Osman Date: Fri, 20 Nov 2020 14:33:11 +0100 Subject: [PATCH] FIX: Encapsulate output metadata in GenericRSResampleImageFilter --- Modules/Core/Metadata/src/otbImageMetadata.cxx | 2 +- .../include/otbGenericRSResampleImageFilter.hxx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Modules/Core/Metadata/src/otbImageMetadata.cxx b/Modules/Core/Metadata/src/otbImageMetadata.cxx index 82ee5498cc..da84e636b2 100644 --- a/Modules/Core/Metadata/src/otbImageMetadata.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadata.cxx @@ -481,7 +481,7 @@ void ImageMetadata::Merge(const ImageMetadata& imd) { ImageMetadataBase::Fuse(imd); - for (unsigned int i = 0; i < std::min(Bands.size(), imd.Bands.size()); i++) + for (unsigned int i = 0; i < std::min(Bands.size(), imd.Bands.size()); ++i) { Bands[i].Fuse(imd.Bands[i]); } diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx index 30c089d829..8959ec2fa9 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx @@ -99,8 +99,10 @@ void GenericRSResampleImageFilter::GenerateOutputInfo m_Resampler->UpdateOutputInformation(); this->GraftOutput(m_Resampler->GetOutput()); - // Encapsulate output projRef - this->GetOutput()->m_Imd.Add(MDGeom::ProjectionProj, this->GetOutputProjectionRef()); + // Encapsulate output projRef and metadata + if (this->GetOutputImageMetadata() != nullptr) + this->GetOutput()->m_Imd.Merge(*(this->GetOutputImageMetadata())); + this->GetOutput()->m_Imd.Add(MDGeom::ProjectionWKT, this->GetOutputProjectionRef()); } /** @@ -119,8 +121,8 @@ void GenericRSResampleImageFilter::EstimateOutputRpcM tempPtr->SetRegions(region); // Encapsulate the output metadata in the temp image + tempPtr->m_Imd.Add(MDGeom::ProjectionWKT, this->GetOutputProjectionRef()); tempPtr->SetImageMetadata(*(this->GetOutputImageMetadata())); - tempPtr->m_Imd.Add(MDGeom::ProjectionProj, this->GetOutputProjectionRef()); // Estimate the rpc model from the temp image m_OutputRpcEstimator->SetInput(tempPtr); -- GitLab