diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 4b941260185825f0db3804e0f3dcc45908192ceb..bbd06a2a0acc6cc9ff89945fbc6683a45757de98 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 0000000000000000000000000000000000000000..41b9397501d5cce2f512cbb5d9db6af6761420d2 --- /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 83042ced75aff8a3b0463d536b8028ac3b47afaa..b1bb52ce96e0a39a62c9811dc34b781ea7110e8d 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); }