From a486e95a2d1df901eafdbc74f46aa8fa613d0269 Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Fri, 8 Nov 2013 15:52:51 +0100 Subject: [PATCH] ENH: warn when deformation grid spacing is inferior to output spacing --- .../Projections/otbOrthoRectification.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Applications/Projections/otbOrthoRectification.cxx b/Applications/Projections/otbOrthoRectification.cxx index 0d67cde84d..2e19415f25 100644 --- a/Applications/Projections/otbOrthoRectification.cxx +++ b/Applications/Projections/otbOrthoRectification.cxx @@ -641,13 +641,24 @@ private: // Predict size of deformation grid ResampleFilterType::SizeType deformationGridSize; - deformationGridSize[0] = GetParameterInt("outputs.sizex") * GetParameterFloat("outputs.spacingx") / GetParameterFloat("opt.gridspacing"); - deformationGridSize[1] = GetParameterInt("outputs.sizey") * GetParameterFloat("outputs.spacingy") / GetParameterFloat("opt.gridspacing"); + deformationGridSize[0] = static_cast(vcl_abs( + GetParameterInt("outputs.sizex") * GetParameterFloat("outputs.spacingx") / GetParameterFloat("opt.gridspacing") )); + deformationGridSize[1] = static_cast(vcl_abs( + GetParameterInt("outputs.sizey") * GetParameterFloat("outputs.spacingy") / GetParameterFloat("opt.gridspacing") )); otbAppLogINFO("Using a deformation grid with a size of " << deformationGridSize); if (deformationGridSize[0] * deformationGridSize[1] == 0) { - otbAppLogFATAL("Deformation grid degenerated (size of 0). You shall set opt.gridspacing appropriately"); + otbAppLogFATAL("Deformation grid degenerated (size of 0). " + "You shall set opt.gridspacing appropriately. opt.gridspacing is homogenous to outputs.spacing parameters"); + } + + if (vcl_abs(GetParameterFloat("opt.gridspacing")) < vcl_abs(GetParameterFloat("outputs.spacingx")) + || vcl_abs(GetParameterFloat("opt.gridspacing")) < vcl_abs(GetParameterFloat("outputs.spacingy")) ) + { + otbAppLogWARNING("Resolution of deformation grid should not be better than " + "resolution of output image. Computation time will be slow, and precision of output won't be better. " + "You shall set opt.gridspacing appropriately."); } //otb::GeoInformationConversion::ToWKT(4326) -- GitLab