diff --git a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx index 4b355d489f535ac26cf52a781f2998e8ef8ad01a..4e0b6b56f56c8d40c5e68503e3f844e84c1ed9e9 100644 --- a/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx +++ b/Modules/Applications/AppProjection/app/otbOrthoRectification.cxx @@ -235,6 +235,11 @@ private: { if (HasValue("io.in")) { + + // Clear and reset the DEM Handler + otb::DEMHandler::Instance()->ClearDEMs(); + otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); + // input image FloatVectorImageType::Pointer inImage = GetParameterImage("io.in"); @@ -645,9 +650,6 @@ private: break; } - // Setup the DEM Handler - otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); - // If activated, generate RPC model if(IsParameterEnabled("opt.rpc")) { diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx index e72145ce085f42418074a7643a740d7ffb6cc756..409f8ad46ed49cad63f9b735ddd32261018bb773 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx @@ -107,10 +107,20 @@ void ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(const Ap // Set DEM directory if available if(IsDEMUsed(app,key)) { - oss.str(""); - oss<<"Elevation management: using DEM directory ("<<GetDEMDirectory(app,key)<<")"<<std::endl; - otb::DEMHandler::Instance()->OpenDEMDirectory(GetDEMDirectory(app,key)); - app->GetLogger()->Info(oss.str()); + std::string demDirectory = GetDEMDirectory(app,key); + if(otb::DEMHandler::Instance()->IsValidDEMDirectory(demDirectory.c_str())) + { + oss.str( "" ); + oss << "Elevation management: using DEM directory (" << demDirectory << ")" << std::endl; + otb::DEMHandler::Instance()->OpenDEMDirectory( demDirectory ); + app->GetLogger()->Info( oss.str() ); + } + else + { + oss.str( "" ); + oss << "DEM directory : " << demDirectory << " is not a valid DEM directory"; + app->GetLogger()->Warning( oss.str() ); + } } } @@ -161,10 +171,10 @@ ElevationParametersHandler::IsGeoidUsed(const Application::Pointer app, const st bool ElevationParametersHandler::IsDEMUsed(const Application::Pointer app, const std::string& key) { - std::ostringstream geoidKey; - geoidKey<< key<<".dem"; + std::ostringstream demKey; + demKey<< key<<".dem"; - return app->IsParameterEnabled(geoidKey.str()) && app->HasValue(geoidKey.str()); + return app->IsParameterEnabled(demKey.str()) && app->HasValue(demKey.str()); }