diff --git a/Code/IO/otbPrepareSRTMDirectory.txx b/Code/IO/otbPrepareSRTMDirectory.cxx similarity index 76% rename from Code/IO/otbPrepareSRTMDirectory.txx rename to Code/IO/otbPrepareSRTMDirectory.cxx index fa04b7d1ae0828804e6956d42e387acaa92433d5..c86ac9f28d72efd4ca23f96883b3a7be1ab7a6e8 100644 --- a/Code/IO/otbPrepareSRTMDirectory.txx +++ b/Code/IO/otbPrepareSRTMDirectory.cxx @@ -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/IO/otbPrepareSRTMDirectory.h b/Code/IO/otbPrepareSRTMDirectory.h index 3888d1a95f70d3c2071d0ed2209f79f63691c1c2..973d74d22680eeb57f7b802ef73f4b7913ddce5d 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/Projections/otbPrepareSRTMDirectory.h b/Code/Projections/otbPrepareSRTMDirectory.h deleted file mode 100644 index a63f67247bbf1ec38a3952c42178e6b37acf354e..0000000000000000000000000000000000000000 --- 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/Code/Projections/otbPrepareSRTMDirectory.txx b/Code/Projections/otbPrepareSRTMDirectory.txx deleted file mode 100644 index 19bb4d4dcfeead349bb3ba72cc4b1b8cb57cc6d8..0000000000000000000000000000000000000000 --- a/Code/Projections/otbPrepareSRTMDirectory.txx +++ /dev/null @@ -1,132 +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_txx -#define __otbPrepareSRTMDirectory_txx - -#include "otbPrepareSRTMDirectory.h" - - -namespace otb -{ - -/** - * Constructor - */ - -PrepareSRTMDirectory::PrepareSRTMDirectory() -{ - m_ULLon = 0.0; - m_ULLat = 0.0; - m_LRLon = 0.0; - m_LRLat = 0.0; - m_FullDEMDirectoryPath = ""; - m_DEMDirectoryPath = ""; -} - -/** - * - */ - -void -PrepareSRTMDirectory -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - this->Superclass::PrintSelf(os,indent); - os << indent << " m_ULLon " << m_ULLon << std::endl; - os << indent << " m_ULLat " << m_ULLat << std::endl; - os << indent << " m_LRLon " << m_LRLon << std::endl; - os << indent << " m_LRLat " << m_LRLat << std::endl; - os << indent << " m_FullDEMDirectoryPath" << m_FullDEMDirectoryPath << std::endl; - os << indent << " m_DEMDirectoryPath" << m_DEMDirectoryPath << std::endl; -} - - -bool PrepareSRTMDirectory::Evaluate() -{ - - int startX = static_cast<int>(floor(m_ULLon)); - int endX = static_cast<int>(ceil(m_LRLon)); - int startY = static_cast<int>(floor(m_LRLat)); - int endY = static_cast<int>(ceil(m_ULLat)); - - std::cout << startX << std::endl; - std::cout << endX << std::endl; - std::cout << startY << std::endl; - std::cout << endY << std::endl; - - for (int j=startY; j<endY; j++) - { - for (int i=startX; i< endX; i++) - { - std::ostringstream inputfilename; - inputfilename << m_FullDEMDirectoryPath; - inputfilename << "/"; - - std::ostringstream outputfilename; - outputfilename << m_DEMDirectoryPath; - outputfilename << "/"; - - if (j >= 0) - { - inputfilename << "N"; - inputfilename << setfill('0') << setw(2) << j; - outputfilename << "N"; - outputfilename << setfill('0') << setw(2) << j; - } - else - { - inputfilename << "S"; - inputfilename << setfill('0') << setw(2) << -j; - outputfilename << "S"; - outputfilename << setfill('0') << setw(2) << -j; - } - if (i >= 0) - { - inputfilename << "E"; - inputfilename << setfill('0') << setw(3) << i; - outputfilename << "E"; - outputfilename << setfill('0') << setw(3) << i; - } - else - { - inputfilename << "W"; - inputfilename << setfill('0') << setw(3) << -i; - outputfilename << "W"; - outputfilename << setfill('0') << setw(3) << -i; - } - - inputfilename << ".hgt"; - outputfilename << ".hgt"; - - std::cout << "Copying " << inputfilename.str() << " to " << outputfilename.str() << std::endl; - - //copy input file to output file - ossimFilename inputFile(inputfilename.str().c_str()); - ossimFilename outputFile(outputfilename.str().c_str()); - inputFile.copyFileTo(outputFile); - - - } - } - - return true; -} - -} // namespace otb - -#endif diff --git a/Testing/Code/DisparityMap/otbMIRegistrationFilter.cxx b/Testing/Code/DisparityMap/otbMIRegistrationFilter.cxx index ddf5bc7652316f403426b980e08b495a1d24d98c..6d246710145b74c76f0ce9862b05ff8cf89fb72c 100644 --- a/Testing/Code/DisparityMap/otbMIRegistrationFilter.cxx +++ b/Testing/Code/DisparityMap/otbMIRegistrationFilter.cxx @@ -93,9 +93,11 @@ int otbMIRegistrationFilter(int argc, char* argv []) DFWriterType::Pointer dfWriter = DFWriterType::New(); dfWriter->SetFileName(argv[3]); dfWriter->SetInput( registrator->GetOutput() ); + + std::cout<<"UPDATE"<<std::endl; dfWriter->Update(); + std::cout<<"UPDATE"<<std::endl; return EXIT_SUCCESS; - } diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index c9cf9158f2a1a67d087a9b85d7c0ded674e4166b..76c08420f4cf56136edce0028c91b35b21cd6f8f 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -1758,7 +1758,12 @@ ADD_TEST(ioTvDEMToOrthoImageGeneratorTest ${IO_TESTS17} N # hemisphere ) +# --- otb::PrepareSRTMDirectory --- +ADD_TEST(ioTuPrepareSRTMDirectoryNew ${IO_TESTS17} + otbPrepareSRTMDirectoryNew ) +#ADD_TEST(ioTuPrepareSRTMDirectoryTest ${IO_TESTS17} +# otbPrepareSRTMDirectoryTest ) #---------------------------------------------------------------------------------- SET(BasicIO_SRCS1 @@ -1901,6 +1906,8 @@ otbPointSetFileReader.cxx otbImageIOFactoryNew.cxx otbDEMToOrthoImageGeneratorNew.cxx otbDEMToOrthoImageGeneratorTest.cxx +otbPrepareSRTMDirectoryNew.cxx +#otbPrepareSRTMDirectoryTest.cxx ) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") diff --git a/Testing/Code/IO/otbIOTests17.cxx b/Testing/Code/IO/otbIOTests17.cxx index 00ce05ce088d78f3c5d23f8d66c5b3d7c6fc0aaf..a29c5c86ce837b874768ecc92b58145dc86f7b7d 100644 --- a/Testing/Code/IO/otbIOTests17.cxx +++ b/Testing/Code/IO/otbIOTests17.cxx @@ -33,4 +33,6 @@ REGISTER_TEST(otbPointSetFileReader); REGISTER_TEST(otbImageIOFactoryNew); REGISTER_TEST(otbDEMToOrthoImageGeneratorNew); REGISTER_TEST(otbDEMToOrthoImageGeneratorTest); +REGISTER_TEST(otbPrepareSRTMDirectoryNew); +//REGISTER_TEST(otbPrepareSRTMDirectoryTest); } diff --git a/Testing/Code/IO/otbPrepareSRTMDirectoryNew.cxx b/Testing/Code/IO/otbPrepareSRTMDirectoryNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2e636e2d2ce474320c07bebf97b33905abac9ad6 --- /dev/null +++ b/Testing/Code/IO/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; +} + + diff --git a/Testing/Code/IO/otbVectorDataKeywordlist.cxx b/Testing/Code/IO/otbVectorDataKeywordlist.cxx index f20263450823de33daab3608baa951f7c595cfd9..7a586e0f041d69daddfe377da889ed3b6774d4ad 100644 --- a/Testing/Code/IO/otbVectorDataKeywordlist.cxx +++ b/Testing/Code/IO/otbVectorDataKeywordlist.cxx @@ -26,4 +26,4 @@ int otbVectorDataKeywordlist(int argc, char * argv[]) //TODO test methods return EXIT_SUCCESS; -} \ No newline at end of file +}