Skip to content
Snippets Groups Projects
Commit ca3c9de4 authored by Julien Michel's avatar Julien Michel
Browse files

TEST: Adding exhaustive (all parameters combination and points type) tests on DEM Handler

parent 34052cb3
No related branches found
No related tags found
No related merge requests found
......@@ -74,16 +74,255 @@ ADD_TEST(uaTvRPCSolverAdapterNotEnoughPointsTest
)
SET_TESTS_PROPERTIES(uaTvRPCSolverAdapterNotEnoughPointsTest PROPERTIES WILL_FAIL TRUE)
ENDIF(OTB_DATA_USE_LARGEINPUT)
# Exhaustive DEM handler testing
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_Geoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
40
8.434583
44.647083
0
383.580313671
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_Geoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
40
8.434583
44.647083
1
339.513
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_NoGeoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
40
8.434583
44.647083
0
339.513
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_NoGeoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
40
8.434583
44.647083
1
339.513
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_NoSRTM_NoGeoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
no
no
40
8.434583
44.647083
0
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_NoSRTM_NoGeoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
no
no
40
8.434583
44.647083
1
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_Geoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
40
8.687917
44.237917
0
45.7464
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_Geoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
40
8.687917
44.237917
1
-5.7464
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_NoGeoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
40
8.687917
44.237917
0
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_NoGeoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
40
8.687917
44.237917
1
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_NoSRTM_NoGeoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
no
no
40
8.687917
44.237917
0
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_NoSRTM_NoGeoid_NoData
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
no
no
40
8.687917
44.237917
1
40
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_Geoid_NoSRTMCoverage
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
20
10. # Point not covered
10. # Point not covered
0
21.569 # Geoid offset
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_Geoid_NoSRTMCoverage
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/DEM/egm96.grd
20
10. # Point not covered
10. # Point not covered
1
-1.569
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_NoGeoid_NoSRTMCoverage
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
20
10. # Point not covered
10. # Point not covered
0
20
0.001
)
ADD_TEST(uaTvDEMHandler_AboveMSL_SRTM_NoGeoid_NoSRTMCoverage
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
no
20
10. # Point not covered
10. # Point not covered
1
20
0.001
)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_BadSRTM_Geoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/poupeesTIF/
${INPUTDATA}/DEM/egm96.grd
40
8.434583
44.647083
0
383.580313671
0.001
)
SET_TESTS_PROPERTIES(uaTvDEMHandler_AboveEllipsoid_BadSRTM_Geoid PROPERTIES WILL_FAIL 1)
ADD_TEST(uaTvDEMHandler_AboveEllipsoid_SRTM_BadGeoid
${UtilitiesAdapters_TESTS1}
otbDEMHandlerTest
${INPUTDATA}/DEM/srtm_directory/
${INPUTDATA}/poupees.jpg
40
8.434583
44.647083
0
339.513
0.001
)
SET(UtilitiesAdapters_SRCS1
otbUtilitiesAdaptersTests1.cxx
otbPlatformPositionAdapter.cxx
otbGeometricSarSensorModelAdapter.cxx
otbRPCSolverAdapterTest.cxx
otbDEMHandlerTest.cxx
)
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "itkMacro.h"
#include "otbDEMHandler.h"
int otbDEMHandlerTest(int argc, char * argv[])
{
if(argc!=9)
{
std::cerr<<"Usage: "<<argv[0]<<" demdir[path|no] geoid[path|no] defaultHeight longitude latitude aboveMSLFlag targetValue tolerance"<<std::endl;
return EXIT_FAILURE;
}
std::string demdir = argv[1];
std::string geoid = argv[2];
double defaultHeight = atof(argv[3]);
double longitude = atof(argv[4]);
double latitude = atof(argv[5]);
bool aboveMSL = atoi(argv[6]);
double target = atof(argv[7]);
double tolerance = atof(argv[8]);
otb::DEMHandler::Pointer demHandler = otb::DEMHandler::Instance();
demHandler->SetDefaultHeightAboveEllipsoid(defaultHeight);
bool fail = false;
std::cout<<std::fixed;
std::cout.precision(12);
if(demdir != "no")
{
if(!demHandler->IsValidDEMDirectory(demdir.c_str()))
{
std::cerr<<"IsValidDEMDirectory("<<demdir<<") = false"<<std::endl;
fail = true;
}
demHandler->OpenDEMDirectory(demdir);
std::cout<<"GetDEMDirectory() = "<<demHandler->GetDEMDirectory()<<std::endl;
}
if(geoid != "no")
{
demHandler->OpenGeoidFile(geoid);
std::cout<<"GetGeoidFile() = "<<demHandler->GetGeoidFile()<<std::endl;
}
std::cout<<"PrintSelf: "<<demHandler<<std::endl;
otb::DEMHandler::PointType point;
point[0] = longitude;
point[1] = latitude;
double height = -32768;
if(aboveMSL)
{
height = demHandler->GetHeightAboveMSL(point);
std::cout<<"height above MSL ("<<longitude<<", "<<latitude<<") = "<<height<<" meters"<<std::endl;
}
else
{
height = demHandler->GetHeightAboveEllipsoid(point);
std::cout<<"height above ellipsoid ("<<longitude<<", "<<latitude<<") = "<<height<<" meters"<<std::endl;
}
// Check for Nan
if(vnl_math_isnan(height))
{
std::cerr<<"Computed value is NaN"<<std::endl;
fail = true;
}
double error = vcl_abs(height-target);
if(error>tolerance)
{
std::cerr<<"Target value is "<<target<<" meters, computed value is "<<height<<" meters. error ("<<error<<" meters) > tolerance ("<<tolerance<<" meters)"<<std::endl;
fail = true;
}
if(fail)
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......@@ -28,4 +28,5 @@ void RegisterTests()
REGISTER_TEST(otbGeometricSarSensorModelAdapterNewTest);
REGISTER_TEST(otbGeometricSarSensorModelAdapterTest);
REGISTER_TEST(otbRPCSolverAdapterTest);
REGISTER_TEST(otbDEMHandlerTest);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment