From efc5a2a8c5fb152da66d69bd53f83aef7821be85 Mon Sep 17 00:00:00 2001 From: Thomas Feuvrier <thomas.feuvrier@c-s.fr> Date: Wed, 2 Sep 2009 11:10:41 +0200 Subject: [PATCH] BUG: Segfault correction for AtmosphericCorrectionSequencement example: add Update for AtmosphericCorrectionParametersTo6SAtmosphericRadiativeTerms variable. --- Code/Radiometry/otbSIXSTraits.cxx | 10 ++++++---- .../Radiometry/AtmosphericCorrectionSequencement.cxx | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Code/Radiometry/otbSIXSTraits.cxx b/Code/Radiometry/otbSIXSTraits.cxx index 3c4836a06c..d707abd3b7 100644 --- a/Code/Radiometry/otbSIXSTraits.cxx +++ b/Code/Radiometry/otbSIXSTraits.cxx @@ -21,6 +21,8 @@ #include "main_6s.h" #include "otbMacro.h" +#include <iomanip> + namespace otb { @@ -158,6 +160,7 @@ SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S( WavelenghtSpectralType* WavelenghtSpectralBand ) { + const double epsilon(.000001); const double L_min = static_cast<double>(WavelenghtSpectralBand->GetMinSpectralValue()); const double L_max = static_cast<double>(WavelenghtSpectralBand->GetMaxSpectralValue()); const double L_userStep = static_cast<double>(WavelenghtSpectralBand->GetUserStep()); @@ -172,15 +175,14 @@ SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S( itkGenericExceptionMacro(<<"The FilterFunctionValues vector must have more than 1 values !"); } //if( vcl_abs((static_cast<double>(FilterFunctionValues.size()-1)*L_userStep)-(L_max-L_min) ) > .000001 ) - if( L_min+static_cast<double>(FilterFunctionValues.size()-1)*L_userStep < L_max ) + if( L_min+static_cast<double>(FilterFunctionValues.size()-1)*L_userStep < (L_max - epsilon )) { - std::cout<<L_min+static_cast<double>(FilterFunctionValues.size()-1)*L_userStep<<" "<<L_max<<std::endl; - itkGenericExceptionMacro(<<"The FilterFunctionValues vector size ( ("<<FilterFunctionValues.size()<<"-1) x userstep ("<<L_userStep<<") must be less than the Max spectral value ("<< L_max-L_min<<") !"); + itkGenericExceptionMacro(<<"The following condition: "<<L_min<<"+("<<FilterFunctionValues.size()<<"-1)*"<<L_userStep<<" < ("<< L_max <<"-"<<epsilon<<") is not respected !"); } // Generate WavelenghtSpectralBand if the step is not the offical 6S step value - if ( vcl_abs(L_userStep-SIXSStepOfWavelenghtSpectralBandValues) > .000001 ) + if ( vcl_abs(L_userStep-SIXSStepOfWavelenghtSpectralBandValues) > epsilon ) { ValuesVectorType values(1, FilterFunctionValues[0]); //vector size 1 with the value vect[0] diff --git a/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx b/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx index 66cf2d3fce..e02e4f5caa 100644 --- a/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx +++ b/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx @@ -419,6 +419,8 @@ int main( int argc, char *argv[] ) filterAtmosphericCorrectionParametersTo6SRadiativeTerms->SetInput( dataAtmosphericCorrectionParameters ); + + filterAtmosphericCorrectionParametersTo6SRadiativeTerms->Update(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex -- GitLab