From 6b2ec616d5b484dcfa316da03170f98ed2d6d79e Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Wed, 4 Feb 2009 17:18:01 +0800 Subject: [PATCH] TEST: add validation test for otbGeocentricTransform --- Testing/Code/Projections/CMakeLists.txt | 9 +++ .../Projections/otbGeocentricTransform.cxx | 72 +++++++++++++++++++ .../Code/Projections/otbProjectionsTests3.cxx | 1 + 3 files changed, 82 insertions(+) create mode 100644 Testing/Code/Projections/otbGeocentricTransform.cxx diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 4b94126018..bbd06a2a0a 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -438,6 +438,14 @@ ADD_TEST(prTvVectorDataProjectionFilterFromMapToGeo ${PROJECTIONS_TESTS3} ADD_TEST(prTuGeocentricTransformNew ${PROJECTIONS_TESTS3} otbGeocentricTransformNew ) + +ADD_TEST(prTuGeocentricTransform ${PROJECTIONS_TESTS3} + --compare-ascii ${EPSILON} ${BASELINE_FILES}/prTvGeocentricTransform.txt + ${TEMP}/prTvGeocentricTransform.txt + otbGeocentricTransform + ${TEMP}/prTvGeocentricTransform.txt +) + #======================================================================================= SET(Projections_SRCS1 otbProjectionBaseNew.cxx @@ -468,6 +476,7 @@ otbVectorDataProjectionFilter.cxx otbVectorDataProjectionFilterFromMapToSensor.cxx otbVectorDataProjectionFilterFromMapToGeo.cxx otbGeocentricTransformNew.cxx +otbGeocentricTransform.cxx ) diff --git a/Testing/Code/Projections/otbGeocentricTransform.cxx b/Testing/Code/Projections/otbGeocentricTransform.cxx new file mode 100644 index 0000000000..41b9397501 --- /dev/null +++ b/Testing/Code/Projections/otbGeocentricTransform.cxx @@ -0,0 +1,72 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbMacro.h" +#include "otbImage.h" +#include "otbGeocentricTransform.h" + +int otbGeocentricTransform( int argc, char* argv[] ) +{ + const char * outFileName = argv[1]; + std::ofstream file; + file.open(outFileName); + + typedef otb::GeocentricTransform<otb::FORWARD> ProjectionType; + ProjectionType::Pointer projection = ProjectionType::New(); + + file << std::setprecision(15); + file << "Forward projection: " << std::endl; + itk::Point<double,3> point; + point[0]=0;//lon + point[1]=0;//lat + point[2]=0;//elev + + file << point << " -> "; + file << projection->TransformPoint(point); + file << std::endl << std::endl; + +// itk::Point<double,3> point; + point[0]=1.4835345f;//lon + point[1]=43.559682611111107f;//lat + point[2]=192.15;//elev + + file << point << " -> "; + file << projection->TransformPoint(point); + file << std::endl << std::endl; + + typedef otb::GeocentricTransform<otb::INVERSE> InverseProjectionType; + InverseProjectionType::Pointer inverseProjection = InverseProjectionType::New(); + + file << "Inverse projection: " << std::endl; + + point[0]=3771793.97;//X + point[1]=140253.34;//Y + point[2]=5124421.30;//Z + + file << point << " -> "; + file << inverseProjection->TransformPoint(point); + file << std::endl << std::endl; + + file.close(); + + return EXIT_SUCCESS; + +} diff --git a/Testing/Code/Projections/otbProjectionsTests3.cxx b/Testing/Code/Projections/otbProjectionsTests3.cxx index 83042ced75..b1bb52ce96 100644 --- a/Testing/Code/Projections/otbProjectionsTests3.cxx +++ b/Testing/Code/Projections/otbProjectionsTests3.cxx @@ -36,4 +36,5 @@ void RegisterTests() REGISTER_TEST(otbVectorDataProjectionFilterFromMapToSensor); REGISTER_TEST(otbVectorDataProjectionFilterFromMapToGeo); REGISTER_TEST(otbGeocentricTransformNew); + REGISTER_TEST(otbGeocentricTransform); } -- GitLab