From 72c51792c5eef74e09f23639f4fda28fe0488c6e Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Tue, 22 Sep 2015 15:34:03 +0200
Subject: [PATCH] BUG: fix ortho-rectification filter, wrong place for
 EstimateInputRpcModel

---
 .../otbGenericRSResampleImageFilter.txx        | 18 +++++++++---------
 .../include/otbOrthoRectificationFilter.txx    |  1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
index a18dabf09a..590688a421 100644
--- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
+++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.txx
@@ -101,6 +101,15 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
   if (m_EstimateOutputRpcModel)
     this->EstimateOutputRpcModel();
 
+  // Estimate the input rpc model if it is needed
+  if (m_EstimateInputRpcModel && !m_RpcEstimationUpdated)
+    {
+    this->EstimateInputRpcModel();
+    }
+
+  // Instanciate the RS transform
+  this->UpdateTransform();
+
   m_Resampler->SetInput(this->GetInput());
   m_Resampler->SetTransform(m_Transform);
   m_Resampler->SetDisplacementFieldSpacing(this->GetDisplacementFieldSpacing());
@@ -177,15 +186,6 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
 {
   if (this->m_Updating) return;
 
-  // Estimate the input rpc model if it is needed
-  if (m_EstimateInputRpcModel && !m_RpcEstimationUpdated)
-    {
-    this->EstimateInputRpcModel();
-    }
-
-  // Instanciate the RS transform
-  this->UpdateTransform();
-
   // Retrieve output requested region
   m_Resampler->GetOutput()->SetRequestedRegion(output);
   m_Resampler->GetOutput()->PropagateRequestedRegion();
diff --git a/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.txx b/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.txx
index d3e16f52d8..51bdfecb49 100644
--- a/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.txx
+++ b/Modules/Filtering/Projection/include/otbOrthoRectificationFilter.txx
@@ -67,6 +67,7 @@ OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolato
 
     // Fill the GenericRSTransform with those information
     this->SetOutputProjectionRef(projectionRef);
+    this->UpdateTransform();
     }
 }
 
-- 
GitLab