From 5d00b76fb357cf5e241874578fbafea075fb31b0 Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Tue, 13 Dec 2011 15:59:07 +0100
Subject: [PATCH] ENH: elevation group is not mandatory then inactive by
 defaut, check if it was activated before using its parameters

---
 .../otbComputePolylineFeatureFromImage.cxx    | 37 +++++++-------
 .../otbTrainSVMImagesClassifier.cxx           | 37 +++++++-------
 .../otbValidateSVMImagesClassifier.cxx        | 37 +++++++-------
 .../otbStereoSensorModelToElevationMap.cxx    | 39 ++++++++-------
 .../otbLineSegmentDetection.cxx               | 43 ++++++++--------
 .../Projections/otbBundleToPerfectSensor.cxx  | 37 +++++++-------
 Applications/Projections/otbImageEnvelope.cxx | 37 +++++++-------
 .../Projections/otbOrthoRectification.cxx     | 37 +++++++-------
 Applications/Projections/otbSuperimpose.cxx   | 37 +++++++-------
 .../otbConnectedComponentSegmentation.cxx     | 37 +++++++-------
 Applications/Utils/otbKmzExport.cxx           | 32 +++++++++---
 Applications/Utils/otbOSMDownloader.cxx       | 35 ++++++++++---
 .../otbVectorDataExtractROIApplication.cxx    | 49 ++++++++++---------
 13 files changed, 283 insertions(+), 211 deletions(-)

diff --git a/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx b/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx
index 22cf8b2ee5..45ada79183 100644
--- a/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx
+++ b/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx
@@ -147,24 +147,27 @@ private:
     vprojIm->SetInputImage(inImage);
 
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      vprojIm->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      vprojIm->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      vprojIm->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        vprojIm->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        vprojIm->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        vprojIm->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
 
     vprojIm->SetUseOutputSpacingAndOriginFromImage(true); // we want index as input;
diff --git a/Applications/Classification/otbTrainSVMImagesClassifier.cxx b/Applications/Classification/otbTrainSVMImagesClassifier.cxx
index 1cb733fc92..eb14d36528 100644
--- a/Applications/Classification/otbTrainSVMImagesClassifier.cxx
+++ b/Applications/Classification/otbTrainSVMImagesClassifier.cxx
@@ -259,24 +259,27 @@ private:
       vdreproj->SetUseOutputSpacingAndOriginFromImage(false);
 
       // Elevation through the elevation handler
-      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+      if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
         {
-        case Elevation_DEM:
-        {
-        vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-        vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-        }
-        break;
-        case Elevation_Average:
-        {
-        vdreproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-        }
-        break;
-        //   Commented cause using a tiff file is not implemented yet
-        //  case Elevation_Tiff:
-        //  {
-        //  }
-        //  break;
+        switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+          {
+          case Elevation_DEM:
+          {
+          vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+          vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+          }
+          break;
+          case Elevation_Average:
+          {
+          vdreproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+          }
+          break;
+          //   Commented cause using a tiff file is not implemented yet
+          //  case Elevation_Tiff:
+          //  {
+          //  }
+          //  break;
+          }
         }
 
       vdreproj->Update();
diff --git a/Applications/Classification/otbValidateSVMImagesClassifier.cxx b/Applications/Classification/otbValidateSVMImagesClassifier.cxx
index 7039f97777..46ad92d0b4 100644
--- a/Applications/Classification/otbValidateSVMImagesClassifier.cxx
+++ b/Applications/Classification/otbValidateSVMImagesClassifier.cxx
@@ -206,24 +206,27 @@ private:
       vdreproj->SetUseOutputSpacingAndOriginFromImage(false);
 
       // Elevation through the elevation handler
-      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+      if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
         {
-        case Elevation_DEM:
-        {
-        vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-        vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-        }
-        break;
-        case Elevation_Average:
-        {
-        vdreproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-        }
-        break;
-        //   Commented cause using a tiff file is not implemented yet
-        //  case Elevation_Tiff:
-        //  {
-        //  }
-        //  break;
+        switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+          {
+          case Elevation_DEM:
+          {
+          vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+          vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+          }
+          break;
+          case Elevation_Average:
+          {
+          vdreproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+          }
+          break;
+          //   Commented cause using a tiff file is not implemented yet
+          //  case Elevation_Tiff:
+          //  {
+          //  }
+          //  break;
+          }
         }
 
       vdreproj->Update();
diff --git a/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx b/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx
index 39fcfdf0af..69a88ae1e5 100644
--- a/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx
+++ b/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx
@@ -223,25 +223,28 @@ private:
       }
   
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      m_StereoFilter->SetUseDEM(true);
-      m_StereoFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_StereoFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      m_StereoFilter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        m_StereoFilter->SetUseDEM(true);
+        m_StereoFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_StereoFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        m_StereoFilter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
 
     m_StereoFilter->SetSubtractInitialElevation(subtractInitialHeight);
diff --git a/Applications/FeatureExtraction/otbLineSegmentDetection.cxx b/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
index d43276b6fc..d749e02940 100644
--- a/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
+++ b/Applications/FeatureExtraction/otbLineSegmentDetection.cxx
@@ -166,26 +166,29 @@ private:
       vproj->SetInputOrigin(GetParameterImage("in")->GetOrigin());
       vproj->SetInputSpacing(GetParameterImage("in")->GetSpacing());
 
-    // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
-      {
-      case Elevation_DEM:
-      {
-      vproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      vproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      vproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
-      }
+      // Elevation through the elevation handler
+      if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
+        {
+        switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+          {
+          case Elevation_DEM:
+          {
+          vproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+          vproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+          }
+          break;
+          case Elevation_Average:
+          {
+          vproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+          }
+          break;
+          //   Commented cause using a tiff file is not implemented yet
+          //  case Elevation_Tiff:
+          //  {
+          //  }
+          //  break;
+          }
+        }
 
       AddProcess(vproj, "Reprojecting output vector data");
       vproj->Update();
diff --git a/Applications/Projections/otbBundleToPerfectSensor.cxx b/Applications/Projections/otbBundleToPerfectSensor.cxx
index 5ebc029b08..36dde4ae4d 100644
--- a/Applications/Projections/otbBundleToPerfectSensor.cxx
+++ b/Applications/Projections/otbBundleToPerfectSensor.cxx
@@ -126,24 +126,27 @@ private:
     resampler->SetInterpolator(interpolator);
     
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      resampler->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      resampler->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      resampler->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        resampler->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        resampler->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        resampler->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
 
     // Set up output image informations
diff --git a/Applications/Projections/otbImageEnvelope.cxx b/Applications/Projections/otbImageEnvelope.cxx
index 3d6a4a9be0..5ecb5f41c1 100644
--- a/Applications/Projections/otbImageEnvelope.cxx
+++ b/Applications/Projections/otbImageEnvelope.cxx
@@ -92,24 +92,27 @@ private:
     m_Envelope->SetInput(input);
     
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      m_Envelope->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_Envelope->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      m_Envelope->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        m_Envelope->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_Envelope->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        m_Envelope->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
     
     if (HasValue("proj"))
diff --git a/Applications/Projections/otbOrthoRectification.cxx b/Applications/Projections/otbOrthoRectification.cxx
index 90e48ee3ee..d070f22cde 100644
--- a/Applications/Projections/otbOrthoRectification.cxx
+++ b/Applications/Projections/otbOrthoRectification.cxx
@@ -388,24 +388,27 @@ private:
       }
 
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      m_ResampleFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_ResampleFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      m_ResampleFilter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        m_ResampleFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_ResampleFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        m_ResampleFilter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
 
     // If activated, generate RPC model
diff --git a/Applications/Projections/otbSuperimpose.cxx b/Applications/Projections/otbSuperimpose.cxx
index 2bac8d734e..78155284a5 100644
--- a/Applications/Projections/otbSuperimpose.cxx
+++ b/Applications/Projections/otbSuperimpose.cxx
@@ -108,24 +108,27 @@ private:
     m_Resampler->SetInterpolator(m_Interpolator);
     
     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      m_Resampler->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_Resampler->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      m_Resampler->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        m_Resampler->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_Resampler->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        m_Resampler->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
     
     // Set up output image informations
diff --git a/Applications/Segmentation/otbConnectedComponentSegmentation.cxx b/Applications/Segmentation/otbConnectedComponentSegmentation.cxx
index 2f9e151dfd..3130e31a82 100644
--- a/Applications/Segmentation/otbConnectedComponentSegmentation.cxx
+++ b/Applications/Segmentation/otbConnectedComponentSegmentation.cxx
@@ -169,24 +169,27 @@ private:
       m_Vproj->SetInputSpacing(inputImage->GetSpacing());
 
       // Elevation through the elevation handler
-      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+      if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
         {
-        case Elevation_DEM:
-        {
-        m_Vproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-        m_Vproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-        }
-        break;
-        case Elevation_Average:
-        {
-        m_Vproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-        }
-        break;
-        //   Commented cause using a tiff file is not implemented yet
-        //  case Elevation_Tiff:
-        //  {
-        //  }
-        //  break;
+        switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+          {
+          case Elevation_DEM:
+          {
+          m_Vproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+          m_Vproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+          }
+          break;
+          case Elevation_Average:
+          {
+          m_Vproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+          }
+          break;
+          //   Commented cause using a tiff file is not implemented yet
+          //  case Elevation_Tiff:
+          //  {
+          //  }
+          //  break;
+          }
         }
       
       m_Vproj->Update();
diff --git a/Applications/Utils/otbKmzExport.cxx b/Applications/Utils/otbKmzExport.cxx
index 35d64452b7..dde345ddbc 100644
--- a/Applications/Utils/otbKmzExport.cxx
+++ b/Applications/Utils/otbKmzExport.cxx
@@ -20,6 +20,8 @@
 
 #include "otbKmzProductWriter.h"
 
+// Elevation handler
+#include "otbWrapperElevationParametersHandler.h"
 
 namespace otb
 {
@@ -73,9 +75,8 @@ private:
     SetParameterDescription("legend", "Path to the image legend to add to the KMZ product.");
     MandatoryOff("legend");
 
-    AddParameter(ParameterType_Directory, "dem",  "DEM directory");
-    SetParameterDescription("dem", "Path to the directory that contains elevation information.");
-    MandatoryOff("dem");
+    // Elevation
+    ElevationParametersHandler::AddElevationParameters(this, "elev");
 
     // Doc example parameter settings
     SetDocExampleParameterValue("in", "qb_RoadExtract2.tif");
@@ -98,13 +99,30 @@ private:
     kmzWriter->SetInput( this->GetParameterImage("in") );
     kmzWriter->SetPath( this->GetParameterString("out") );
 
-    // Use DEM if any
-    if( this->HasValue("dem") )
+    // Elevation through the elevation handler
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      kmzWriter->SetDEMDirectory(this->GetParameterString("dem"));
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        kmzWriter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        kmzWriter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        kmzWriter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
 
-
     // If the tile size is set
     if( this->HasValue("tilesize") )
       {
diff --git a/Applications/Utils/otbOSMDownloader.cxx b/Applications/Utils/otbOSMDownloader.cxx
index 1e968cf0e5..ee8dc71ea5 100644
--- a/Applications/Utils/otbOSMDownloader.cxx
+++ b/Applications/Utils/otbOSMDownloader.cxx
@@ -22,6 +22,8 @@
 #include "otbVectorDataProperties.h"
 #include "otbOSMDataToVectorDataGenerator.h"
 
+// Elevation handler
+#include "otbWrapperElevationParametersHandler.h"
 
 namespace otb
 {
@@ -73,9 +75,8 @@ private:
     SetParameterDescription("key", "OSM tag value to extract (motorway, footway...)");
     MandatoryOff("value");
 
-    AddParameter(ParameterType_Directory, "dem",  "DEM directory");
-    SetParameterDescription("dem", "Path to the directory that contains elevation information.");
-    MandatoryOff("dem");
+    // Elevation
+    ElevationParametersHandler::AddElevationParameters(this, "elev");
 
     AddParameter(ParameterType_Empty, "printclasses", "option to display available key/value classes");
     std::ostringstream oss;
@@ -119,13 +120,33 @@ private:
   VectorDataPropertiesType::Pointer vdProperties = VectorDataPropertiesType::New();
   m_VdOSMGenerator = VectorDataProviderType::New();
 
-
-  //Generate the envelope
+  // Get the support image
   envelopeFilter->SetInput( this->GetParameterImage("support") ); //->Output in WGS84
-  if ( this->HasValue("dem"))
+  
+  //Generate the envelope : Elevation through the elevation handler
+  if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
     {
-    envelopeFilter->SetDEMDirectory(this->GetParameterString("dem"));
+    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+      {
+      case Elevation_DEM:
+      {
+      envelopeFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+      envelopeFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+      }
+      break;
+      case Elevation_Average:
+      {
+      envelopeFilter->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+      }
+      break;
+      //   Commented cause using a tiff file is not implemented yet
+      //  case Elevation_Tiff:
+      //  {
+      //  }
+      //  break;
+      }
     }
+
   envelopeFilter->Update();
 
   vdProperties->SetVectorDataObject(envelopeFilter->GetOutput());
diff --git a/Applications/Utils/otbVectorDataExtractROIApplication.cxx b/Applications/Utils/otbVectorDataExtractROIApplication.cxx
index e6a93d635c..08cecb6754 100644
--- a/Applications/Utils/otbVectorDataExtractROIApplication.cxx
+++ b/Applications/Utils/otbVectorDataExtractROIApplication.cxx
@@ -152,31 +152,34 @@ private:
     m_VdProj->SetOutputOrigin(inImage->GetOrigin());
     m_VdProj->SetOutputSpacing(inImage->GetSpacing());
 
-     // Elevation through the elevation handler
-    switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+    // Elevation through the elevation handler
+    if (ElevationParametersHandler::IsElevationEnabled(this, "elev"))
       {
-      case Elevation_DEM:
-      {
-      m_VdExtract->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_VdExtract->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-
-      m_VdProj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
-      m_VdProj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
-      }
-      break;
-      case Elevation_Average:
-      {
-      m_VdExtract->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
-      m_VdProj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+      switch(ElevationParametersHandler::GetElevationType(this, "elev"))
+        {
+        case Elevation_DEM:
+        {
+        m_VdExtract->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_VdExtract->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+
+        m_VdProj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev"));
+        m_VdProj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev"));
+        }
+        break;
+        case Elevation_Average:
+        {
+        m_VdExtract->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        m_VdProj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev"));
+        }
+        break;
+        //   Commented cause using a tiff file is not implemented yet
+        //  case Elevation_Tiff:
+        //  {
+        //  }
+        //  break;
+        }
       }
-      break;
-      //   Commented cause using a tiff file is not implemented yet
-      //  case Elevation_Tiff:
-      //  {
-      //  }
-      //  break;
-      }
-    
+
     // Set the output vectorData
     SetParameterOutputVectorData("io.out", m_VdProj->GetOutput());
   }
-- 
GitLab