From ad58726dec296851cf195a5c3a059fff8862d3a8 Mon Sep 17 00:00:00 2001 From: Thomas Feuvrier <thomas.feuvrier@c-s.fr> Date: Mon, 27 Apr 2009 14:27:35 +0200 Subject: [PATCH] ENH : add preparesrtmdata tests --- Code/IO/otbPrepareSRTMDirectory.h | 31 +++--- Code/IO/otbPrepareSRTMDirectory.txx | 32 +++--- Code/Projections/otbPrepareSRTMDirectory.h | 97 ------------------- Testing/Code/Projections/CMakeLists.txt | 25 ++++- .../otbPrepareSRTMDirectoryNew.cxx | 33 +++++++ 5 files changed, 87 insertions(+), 131 deletions(-) delete mode 100644 Code/Projections/otbPrepareSRTMDirectory.h create mode 100644 Testing/Code/Projections/otbPrepareSRTMDirectoryNew.cxx diff --git a/Code/IO/otbPrepareSRTMDirectory.h b/Code/IO/otbPrepareSRTMDirectory.h index 3888d1a95f..973d74d226 100644 --- a/Code/IO/otbPrepareSRTMDirectory.h +++ b/Code/IO/otbPrepareSRTMDirectory.h @@ -22,6 +22,8 @@ #include "itkObjectFactory.h" #include "base/ossimFilename.h" + + namespace otb { @@ -43,30 +45,30 @@ class ITK_EXPORT PrepareSRTMDirectory : public itk::Object { public: /** Standard class typedefs. */ - typedef PrepareSRTMDirectory Self; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - - typedef itk::Object Superclass; + typedef PrepareSRTMDirectory Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; - itkTypeMacro(PrepareSRTMDirectory, Object); /** Method for creation through the object factory. */ itkNewMacro(Self); + itkTypeMacro(PrepareSRTMDirectory, itk::Object); + + itkGetMacro( ULLon, double ); itkGetMacro( ULLat, double ); itkGetMacro( LRLon, double ); itkGetMacro( LRLat, double ); - itkGetMacro( FullDEMDirectoryPath, string ); - itkGetMacro( DEMDirectoryPath, string ); + itkGetMacro( FullDEMDirectoryPath, std::string ); + itkGetMacro( DEMDirectoryPath, std::string ); itkSetMacro( ULLon, double ); itkSetMacro( ULLat, double ); itkSetMacro( LRLon, double ); itkSetMacro( LRLat, double ); - itkSetMacro( FullDEMDirectoryPath, string ); - itkSetMacro( DEMDirectoryPath, string ); + itkSetMacro( FullDEMDirectoryPath, std::string ); + itkSetMacro( DEMDirectoryPath, std::string ); virtual bool Evaluate(); @@ -84,14 +86,11 @@ private: double m_ULLat; double m_LRLon; double m_LRLat; - string m_FullDEMDirectoryPath; - string m_DEMDirectoryPath; + std::string m_FullDEMDirectoryPath; + std::string m_DEMDirectoryPath; }; } // namespace otb -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbPrepareSRTMDirectory.txx" -#endif #endif diff --git a/Code/IO/otbPrepareSRTMDirectory.txx b/Code/IO/otbPrepareSRTMDirectory.txx index fa04b7d1ae..c86ac9f28d 100644 --- a/Code/IO/otbPrepareSRTMDirectory.txx +++ b/Code/IO/otbPrepareSRTMDirectory.txx @@ -15,11 +15,11 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#ifndef __otbPrepareSRTMDirectory_txx -#define __otbPrepareSRTMDirectory_txx #include "otbPrepareSRTMDirectory.h" - +#include <iostream> +#include <iomanip> +#include "otbMath.h" namespace otb { @@ -58,11 +58,10 @@ PrepareSRTMDirectory bool PrepareSRTMDirectory::Evaluate() { - - int startX = floor(m_ULLon); - int endX = ceil(m_LRLon); - int startY = floor(m_LRLat); - int endY = ceil(m_ULLat); + int startX = static_cast<int>(vcl_floor(m_ULLon)); + int endX = static_cast<int>(vcl_ceil(m_LRLon)); + int startY = static_cast<int>(vcl_floor(m_LRLat)); + int endY = static_cast<int>(vcl_ceil(m_ULLat)); std::cout << startX << std::endl; std::cout << endX << std::endl; @@ -84,30 +83,30 @@ bool PrepareSRTMDirectory::Evaluate() if (j >= 0) { inputfilename << "N"; - inputfilename << setfill('0') << setw(2) << j; + inputfilename << std::setfill('0') << std::setw(2) << j; outputfilename << "N"; - outputfilename << setfill('0') << setw(2) << j; + outputfilename << std::setfill('0') << std::setw(2) << j; } else { inputfilename << "S"; - inputfilename << setfill('0') << setw(2) << -j; + inputfilename << std::setfill('0') << std::setw(2) << -j; outputfilename << "S"; - outputfilename << setfill('0') << setw(2) << -j; + outputfilename << std::setfill('0') << std::setw(2) << -j; } if (i >= 0) { inputfilename << "E"; - inputfilename << setfill('0') << setw(3) << i; + inputfilename << std::setfill('0') << std::setw(3) << i; outputfilename << "E"; - outputfilename << setfill('0') << setw(3) << i; + outputfilename << std::setfill('0') << std::setw(3) << i; } else { inputfilename << "W"; - inputfilename << setfill('0') << setw(3) << -i; + inputfilename << std::setfill('0') << std::setw(3) << -i; outputfilename << "W"; - outputfilename << setfill('0') << setw(3) << -i; + outputfilename << std::setfill('0') << std::setw(3) << -i; } inputfilename << ".hgt"; @@ -129,4 +128,3 @@ bool PrepareSRTMDirectory::Evaluate() } // namespace otb -#endif diff --git a/Code/Projections/otbPrepareSRTMDirectory.h b/Code/Projections/otbPrepareSRTMDirectory.h deleted file mode 100644 index a63f67247b..0000000000 --- a/Code/Projections/otbPrepareSRTMDirectory.h +++ /dev/null @@ -1,97 +0,0 @@ -/*========================================================================= - - 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. - -=========================================================================*/ -#ifndef __otbPrepareSRTMDirectory_h -#define __otbPrepareSRTMDirectory_h - -#include "itkObject.h" -#include "itkObjectFactory.h" -#include "base/ossimFilename.h" - -namespace otb -{ - -/** - * \class PrepareSRTMDirectory - * \brief Prepare SRTM directory for Ossim from a full archive - * - * As ossim has some issue with directories containing too many SRTM tiles - * (>5000) this class enable to copy only the required tiles from - * FullDEMDirectoryPath containing all the SRTM tiles to DEMDirectoryPath - * that will be passed as the argument of the SetDEMDirectoryPath() of - * the otb::DEMToImageGenerator for example - * - * - */ - - -class ITK_EXPORT PrepareSRTMDirectory : public itk::Object -{ -public: - /** Standard class typedefs. */ - typedef PrepareSRTMDirectory Self; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - - typedef itk::Object Superclass; - - itkTypeMacro(PrepareSRTMDirectory, Object); - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - itkGetMacro( ULLon, double ); - itkGetMacro( ULLat, double ); - itkGetMacro( LRLon, double ); - itkGetMacro( LRLat, double ); - itkGetMacro( FullDEMDirectoryPath, string ); - itkGetMacro( DEMDirectoryPath, string ); - - itkSetMacro( ULLon, double ); - itkSetMacro( ULLat, double ); - itkSetMacro( LRLon, double ); - itkSetMacro( LRLat, double ); - itkSetMacro( FullDEMDirectoryPath, string ); - itkSetMacro( DEMDirectoryPath, string ); - - - virtual bool Evaluate(); - -protected: - PrepareSRTMDirectory(); - ~PrepareSRTMDirectory() {}; - void PrintSelf(std::ostream& os, itk::Indent indent) const; - -private: - PrepareSRTMDirectory( const Self& ); //purposely not implemented - void operator=( const Self& ); //purposely not implemented - - double m_ULLon; - double m_ULLat; - double m_LRLon; - double m_LRLat; - string m_FullDEMDirectoryPath; - string m_DEMDirectoryPath; -}; - -} // namespace otb - -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbPrepareSRTMDirectory.txx" -#endif - -#endif diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 4248f8161f..71c7d98f9f 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -17,6 +17,7 @@ SET(EPSILON 0.0001) SET(PROJECTIONS_TESTS1 ${CXX_TEST_PATH}/otbProjectionsTests1) SET(PROJECTIONS_TESTS2 ${CXX_TEST_PATH}/otbProjectionsTests2) SET(PROJECTIONS_TESTS3 ${CXX_TEST_PATH}/otbProjectionsTests3) +SET(PROJECTIONS_TESTS4 ${CXX_TEST_PATH}/otbProjectionsTests4) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbPROJECTIONS_TESTS1 ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -335,6 +336,24 @@ ADD_TEST(prTvGeocentricTransform ${PROJECTIONS_TESTS3} ${TEMP}/prTvGeocentricTransform.txt ) + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbPROJECTIONS_TESTS4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ADD_TEST(prTuPrepareSRTMDirectoryNew ${PROJECTIONS_TESTS4} + otbPrepareSRTMDirectoryNew ) + + + + + + + + + + + #======================================================================================= SET(Projections_SRCS1 otbProjectionBaseNew.cxx @@ -365,7 +384,9 @@ otbVectorDataProjectionFilterFromMapToGeo.cxx otbGeocentricTransformNew.cxx otbGeocentricTransform.cxx ) - +SET(Projections_SRCS4 +otbPrepareSRTMDirectoryNew.cxx +) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") @@ -375,5 +396,7 @@ ADD_EXECUTABLE(otbProjectionsTests2 otbProjectionsTests2.cxx ${Projections_SRCS2 TARGET_LINK_LIBRARIES(otbProjectionsTests2 OTBProjections OTBIO) ADD_EXECUTABLE(otbProjectionsTests3 otbProjectionsTests3.cxx ${Projections_SRCS3}) TARGET_LINK_LIBRARIES(otbProjectionsTests3 OTBProjections OTBIO) +ADD_EXECUTABLE(otbProjectionsTests4 otbProjectionsTests4.cxx ${Projections_SRCS4}) +TARGET_LINK_LIBRARIES(otbProjectionsTests4 OTBProjections OTBIO) ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/Projections/otbPrepareSRTMDirectoryNew.cxx b/Testing/Code/Projections/otbPrepareSRTMDirectoryNew.cxx new file mode 100644 index 0000000000..2e636e2d2c --- /dev/null +++ b/Testing/Code/Projections/otbPrepareSRTMDirectoryNew.cxx @@ -0,0 +1,33 @@ +/*========================================================================= + + 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 "itkExceptionObject.h" +#include "otbPrepareSRTMDirectory.h" + + +int otbPrepareSRTMDirectoryNew(int argc, char * argv[]) +{ + + typedef otb::PrepareSRTMDirectory PrepareSRTMDirectoryType; + + PrepareSRTMDirectoryType::Pointer prepareSRTM = PrepareSRTMDirectoryType::New(); + + + return EXIT_SUCCESS; +} + + -- GitLab