diff --git a/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx b/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx index b53746465f8198bcc403b5b2677c12d205327192..22cf8b2ee5aaf193fbf4f35aabbf21e09ef178f5 100644 --- a/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx +++ b/Applications/CartographicDBValidation/otbComputePolylineFeatureFromImage.cxx @@ -36,6 +36,9 @@ #include "otbParserConditionDataNodeFeatureFunction.h" #include "otbNDVIDataNodeFeatureFunction.h" +// Elevation handler +#include "otbWrapperElevationParametersHandler.h" + namespace otb { namespace Wrapper @@ -91,9 +94,8 @@ private: AddParameter(ParameterType_InputVectorData, "vd", "Vector Data"); SetParameterDescription("vd", "Vector data containing the polylines onto which the feature will be computed."); - AddParameter(ParameterType_Filename, "dem", "DEM repository"); - MandatoryOff("dem"); - SetParameterDescription("dem", "path to SRTM repository"); + // Elevation + ElevationParametersHandler::AddElevationParameters(this, "elev"); AddParameter(ParameterType_String, "expr", "Feature expression"); SetParameterDescription("expr", "The feature formula (b1 > 0.3)"); @@ -144,17 +146,25 @@ private: vprojIm->SetInputVectorData(inVectorData); vprojIm->SetInputImage(inImage); - // Configure DEM directory - if (IsParameterEnabled("dem")) + // Elevation through the elevation handler + switch(ElevationParametersHandler::GetElevationType(this, "elev")) + { + case Elevation_DEM: { - vprojIm->SetDEMDirectory(GetParameterString("dem")); + vprojIm->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev")); + vprojIm->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev")); } - else + break; + case Elevation_Average: { - if (otb::ConfigurationFile::GetInstance()->IsValid()) - { - vprojIm->SetDEMDirectory(otb::ConfigurationFile::GetInstance()->GetDEMDirectory()); - } + 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; @@ -258,17 +268,25 @@ private: vproj->SetOutputOrigin(inImage->GetOrigin()); vproj->SetOutputSpacing(inImage->GetSpacing()); - // Configure DEM directory - if (IsParameterEnabled("dem")) + // Elevation through the elevation handler + switch(ElevationParametersHandler::GetElevationType(this, "elev")) { - vproj->SetDEMDirectory(GetParameterString("dem")); + case Elevation_DEM: + { + vproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev")); + vproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev")); } - else + break; + case Elevation_Average: { - if (otb::ConfigurationFile::GetInstance()->IsValid()) - { - vproj->SetDEMDirectory(otb::ConfigurationFile::GetInstance()->GetDEMDirectory()); - } + vproj->SetAverageElevation(ElevationParametersHandler::GetAverageElevation(this, "elev")); + } + break; + // Commented cause using a tiff file is not implemented yet + // case Elevation_Tiff: + // { + // } + // break; } vproj->Update(); diff --git a/Applications/Classification/otbTrainSVMImagesClassifier.cxx b/Applications/Classification/otbTrainSVMImagesClassifier.cxx index 388340ebb946c6bbd6e41d6be4b3f01e519f4999..1cb733fc92ef179b21134c2b3bdd95b3557baec1 100644 --- a/Applications/Classification/otbTrainSVMImagesClassifier.cxx +++ b/Applications/Classification/otbTrainSVMImagesClassifier.cxx @@ -61,6 +61,9 @@ // Extract a ROI of the vectordata #include "otbVectorDataIntoImageProjectionFilter.h" +// Elevation handler +#include "otbWrapperElevationParametersHandler.h" + namespace otb { namespace Wrapper @@ -145,9 +148,6 @@ private: SetParameterDescription("io.il", "A list of input images."); AddParameter(ParameterType_InputVectorDataList, "io.vd", "Vector Data List"); SetParameterDescription("io.vd", "A list of vector data sample used to train the estimator."); - AddParameter(ParameterType_Filename, "io.dem", "DEM repository"); - MandatoryOff("io.dem"); - SetParameterDescription("io.dem", "Path to SRTM repository"); AddParameter(ParameterType_Filename, "io.imstat", "XML image statistics file"); MandatoryOff("io.imstat"); SetParameterDescription("io.imstat", "Filename of an XML file containing mean and standard deviation of input images."); @@ -155,6 +155,9 @@ private: SetParameterDescription("io.out", "Output SVM model"); SetParameterRole("io.out", Role_Output); + // Elevation + ElevationParametersHandler::AddElevationParameters(this, "elev"); + //Group Sample list AddParameter(ParameterType_Group,"sample","Training and validation samples parameters"); SetParameterDescription("sample","This group of parameters allows to set training and validation sample lists parameters."); @@ -255,17 +258,25 @@ private: vdreproj->SetInput(vectorData); vdreproj->SetUseOutputSpacingAndOriginFromImage(false); - // Configure DEM directory - if (IsParameterEnabled("io.dem")) + // Elevation through the elevation handler + switch(ElevationParametersHandler::GetElevationType(this, "elev")) + { + case Elevation_DEM: { - vdreproj->SetDEMDirectory(GetParameterString("io.dem")); + vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev")); + vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev")); } - else + break; + case Elevation_Average: { - if (otb::ConfigurationFile::GetInstance()->IsValid()) - { - vdreproj->SetDEMDirectory(otb::ConfigurationFile::GetInstance()->GetDEMDirectory()); - } + 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 c957411092c4aa5f326ec5451c9e4fcb4be77d9e..7039f977776a9ecc975c9ea4f48403ae3897fb9a 100644 --- a/Applications/Classification/otbValidateSVMImagesClassifier.cxx +++ b/Applications/Classification/otbValidateSVMImagesClassifier.cxx @@ -51,6 +51,9 @@ // Extract a ROI of the vectordata #include "otbVectorDataIntoImageProjectionFilter.h" +// Elevation handler +#include "otbWrapperElevationParametersHandler.h" + namespace otb { namespace Wrapper @@ -132,12 +135,13 @@ private: SetParameterDescription("il", "Input image list filename."); AddParameter(ParameterType_InputVectorDataList, "vd", "Vector Data List"); SetParameterDescription("vd", "Vector Data of samples used to validate the estimator."); - AddParameter(ParameterType_Filename, "dem", "DEM repository"); - SetParameterDescription("dem", "Path to DEM repository."); - MandatoryOff("dem"); AddParameter(ParameterType_Filename, "imstat", "XML image statistics file"); MandatoryOff("imstat"); SetParameterDescription("imstat", "Filename of an XML file containing mean and standard deviation of input images."); + + // Elevation + ElevationParametersHandler::AddElevationParameters(this, "elev"); + AddParameter(ParameterType_Filename, "out", "Output filename"); SetParameterDescription("out", "Filename, which contains the performances of the SVM model."); MandatoryOff("out"); @@ -201,17 +205,25 @@ private: vdreproj->SetInput(vectorData); vdreproj->SetUseOutputSpacingAndOriginFromImage(false); - // Configure DEM directory - if (IsParameterEnabled("dem")) + // Elevation through the elevation handler + switch(ElevationParametersHandler::GetElevationType(this, "elev")) { - vdreproj->SetDEMDirectory(GetParameterString("dem")); + case Elevation_DEM: + { + vdreproj->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev")); + vdreproj->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev")); } - else + break; + case Elevation_Average: { - if (otb::ConfigurationFile::GetInstance()->IsValid()) - { - vdreproj->SetDEMDirectory(otb::ConfigurationFile::GetInstance()->GetDEMDirectory()); - } + 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 c29b5603b809ea19529a603a3d4e4e0b7f800814..fea008022b3279661c0ae50e4f3f2581ac2eb99f 100644 --- a/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx +++ b/Applications/DisparityMap/otbStereoSensorModelToElevationMap.cxx @@ -27,6 +27,9 @@ #include "itkDiscreteGaussianImageFilter.h" +// Elevation handler +#include "otbWrapperElevationParametersHandler.h" + namespace otb { namespace Wrapper @@ -129,15 +132,8 @@ private: SetDefaultParameterFloat("ae", 0.0); MandatoryOff("ae"); - AddParameter(ParameterType_String, "dem", "DEMDirectory"); - SetParameterDescription("dem", "Use DEM tiles to derive initial height values (AverageElevation option is ignored in this case)"); - MandatoryOff("dem"); - DisableParameter("dem"); - - AddParameter(ParameterType_String, "geoid", "GeoidFile"); - SetParameterDescription("geoid", "Use a geoid file along with the DEM tiles"); - MandatoryOff("geoid"); - DisableParameter("geoid"); + // Elevation + ElevationParametersHandler::AddElevationParameters(this, "elev"); AddParameter(ParameterType_Float, "rgs", "ReferenceGaussianSmoothing"); SetParameterDescription("rgs", "(optional) Perform a gaussian smoothing of the reference image. Parameter is gaussian sigma (in pixels). Default is no smoothing."); @@ -181,10 +177,6 @@ private: bool secondarySmoothing = IsParameterEnabled("sgs"); - bool useDEM = IsParameterEnabled("dem") && HasValue("dem"); - - bool useGeoid = IsParameterEnabled("geoid") && HasValue("geoid"); - bool subtractInitialHeight = IsParameterEnabled("s"); FloatVectorImageType::Pointer inputRef = GetParameterImage("ref"); @@ -229,21 +221,28 @@ private: m_StereoFilter->SetSlaveInput(m_Intensity2->GetOutput()); } - m_StereoFilter->SetUseDEM(useDEM); - if(useDEM) + // Elevation through the elevation handler + switch(ElevationParametersHandler::GetElevationType(this, "elev")) { - m_StereoFilter->SetDEMDirectory(GetParameterString("dem")); - - if(useGeoid) - { - m_StereoFilter->SetGeoidFile(GetParameterString("geoid")); - } + case Elevation_DEM: + { + m_StereoFilter->SetUseDEM(true); + m_StereoFilter->SetDEMDirectory(ElevationParametersHandler::GetDEMDirectory(this, "elev")); + m_StereoFilter->SetGeoidFile(ElevationParametersHandler::GetGeoidFile(this, "elev")); } - else + break; + case Elevation_Average: { - m_StereoFilter->SetAverageElevation(GetParameterFloat("ae")); + 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); m_StereoFilter->SetLowerElevation(GetParameterFloat("minh"));