From 7dd65f077d4ff0e504ff9c51382137140b25a701 Mon Sep 17 00:00:00 2001
From: Ludovic Hussonnois <ludovic.hussonnois@c-s.fr>
Date: Mon, 30 Jan 2017 16:56:27 +0100
Subject: [PATCH] BUG: Mantis-1348 : Correct gridspacing limitation when used
 with EPSG or WGS format.

---
 .../AppProjection/app/otbOrthoRectification.cxx       | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
index 3d0624f663..4b355d489f 100644
--- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
+++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx
@@ -692,11 +692,16 @@ private:
 
       otbAppLogINFO("Using a deformation grid with a physical spacing of " << GetParameterFloat("opt.gridspacing"));
 
+      if ( GetParameterFloat( "opt.gridspacing" ) == 0 )
+        {
+        otbAppLogFATAL( "opt.gridspacing must be different from 0 " );
+        }
+
       // Predict size of deformation grid
-      ResampleFilterType::SizeType deformationGridSize;
-      deformationGridSize[0] = static_cast<ResampleFilterType::SizeType::SizeValueType>(vcl_abs(
+      ResampleFilterType::SpacingType deformationGridSize;
+      deformationGridSize[0] = static_cast<ResampleFilterType::SpacingType::ValueType >(vcl_abs(
           GetParameterInt("outputs.sizex") * GetParameterFloat("outputs.spacingx") / GetParameterFloat("opt.gridspacing") ));
-      deformationGridSize[1] = static_cast<ResampleFilterType::SizeType::SizeValueType>(vcl_abs(
+      deformationGridSize[1] = static_cast<ResampleFilterType::SpacingType::ValueType>(vcl_abs(
           GetParameterInt("outputs.sizey") * GetParameterFloat("outputs.spacingy") / GetParameterFloat("opt.gridspacing") ));
       otbAppLogINFO("Using a deformation grid of size " << deformationGridSize);
 
-- 
GitLab