From c600713058d9aceacf2bbeea1048e67c79b8c024 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Thu, 10 Dec 2015 18:29:55 +0100
Subject: [PATCH] BUG: ortho generated without projRef

---
 .../otbGenericRSResampleImageFilter.txx       | 32 ++++++-------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
index 590688a421..bd60be834c 100644
--- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
+++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
@@ -82,21 +82,6 @@ void
 GenericRSResampleImageFilter<TInputImage, TOutputImage>
 ::GenerateOutputInformation()
 {
-  typename OutputImageType::Pointer outputPtr = this->GetOutput();
-
-  // Get the Output MetaData Dictionary
-  itk::MetaDataDictionary& dict = outputPtr->GetMetaDataDictionary();
-
-  // Encapsulate the   metadata set by the user
-  itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey,
-                                        this->GetOutputProjectionRef());
-
-  if (this->GetOutputKeywordList().GetSize() > 0)
-    {
-    itk::EncapsulateMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey,
-                                               this->GetOutputKeywordList());
-    }
-
   // Estimate the output rpc Model if needed
   if (m_EstimateOutputRpcModel)
     this->EstimateOutputRpcModel();
@@ -116,6 +101,16 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
   m_Resampler->GraftOutput(this->GetOutput());
   m_Resampler->UpdateOutputInformation();
   this->GraftOutput(m_Resampler->GetOutput());
+
+  // Encapsulate output projRef and keywordlist
+  itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary();
+  itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey,
+                                        this->GetOutputProjectionRef());
+  if (this->GetOutputKeywordList().GetSize() > 0)
+    {
+    itk::EncapsulateMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey,
+                                               this->GetOutputKeywordList());
+    }
 }
 
 /**
@@ -126,9 +121,6 @@ void
 GenericRSResampleImageFilter<TInputImage, TOutputImage>
 ::EstimateOutputRpcModel()
 {
-  // Get the output dictionary
-  itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary();
-
   // Temp image : not allocated but with the same metadata than the
   // output
   typename OutputImageType::Pointer tempPtr = OutputImageType::New();
@@ -152,10 +144,6 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
   // Encapsulate the estimated rpc model in the output
   if (m_OutputRpcEstimator->GetOutput()->GetImageKeywordlist().GetSize() > 0)
     {
-    // Fill the output dict
-    itk::EncapsulateMetaData<ImageKeywordlist>(dict,
-                                               MetaDataKey::OSSIMKeywordlistKey,
-                                               m_OutputRpcEstimator->GetOutput()->GetImageKeywordlist());
     // Fill the transform with the right kwl
     m_Transform->SetInputKeywordList( m_OutputRpcEstimator->GetOutput()->GetImageKeywordlist());
     }
-- 
GitLab