From e0b4fc29112000605189620eeef81d0e0e040d62 Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Fri, 25 Nov 2011 16:46:19 +0100 Subject: [PATCH] TEST: split JPEG2000 dependent test in specific cxx --- Testing/Code/IO/CMakeLists.txt | 4 +- ...nfo.cxx => otbMultiDatasetReadingInfo.cxx} | 44 ------------- .../Code/IO/otbMultiResolutionReadingInfo.cxx | 66 +++++++++++++++++++ 3 files changed, 68 insertions(+), 46 deletions(-) rename Testing/Code/IO/{otbMultiReadingInfo.cxx => otbMultiDatasetReadingInfo.cxx} (68%) create mode 100644 Testing/Code/IO/otbMultiResolutionReadingInfo.cxx diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index a28d47ccd2..3285753ebb 100644 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -3554,7 +3554,7 @@ otbIOTests13.cxx otbJPEG2000ImageIOTestCanRead.cxx otbJPEG2000ImageIOTestCanWrite.cxx otbVectorImageTest.cxx -otbMultiReadingInfo.cxx +otbMultiResolutionReadingInfo.cxx otbGenerateClassicalQLWithJPEG2000.cxx ) ENDIF(OTB_COMPILE_JPEG2000) @@ -3667,7 +3667,7 @@ IF(CHECK_GDAL_BUILDED_WITH_HDF) SET(BasicIO_SRCS22 otbIOTests22.cxx otbVectorImageTest.cxx -otbMultiReadingInfo.cxx +otbMultiDatasetReadingInfo.cxx ) ENDIF(CHECK_GDAL_BUILDED_WITH_HDF) diff --git a/Testing/Code/IO/otbMultiReadingInfo.cxx b/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx similarity index 68% rename from Testing/Code/IO/otbMultiReadingInfo.cxx rename to Testing/Code/IO/otbMultiDatasetReadingInfo.cxx index 9306713cf5..52d0841cb7 100644 --- a/Testing/Code/IO/otbMultiReadingInfo.cxx +++ b/Testing/Code/IO/otbMultiDatasetReadingInfo.cxx @@ -22,7 +22,6 @@ #include "itkMacro.h" #include "itksys/SystemTools.hxx" #include "otbGDALImageIO.h" -#include "otbJPEG2000ImageIO.h" int otbMultiDatasetReadingInfo(int argc, char* argv[]) { @@ -82,46 +81,3 @@ int otbMultiDatasetReadingInfo(int argc, char* argv[]) return EXIT_SUCCESS; } - - -int otbMultiResolutionReadingInfo(int argc, char* argv[]) -{ - if (argc != 3) - { - std::cout << argv[0] << "<image JPEG2000> <ouput filename>" << std::endl; - return EXIT_FAILURE; - } - const char * inputFilename = argv[1]; - const char * outputAsciiFilename = argv[2]; - - otb::JPEG2000ImageIO::Pointer readerJPEG2000 = otb::JPEG2000ImageIO::New(); - - readerJPEG2000->SetFileName(inputFilename); - if (readerJPEG2000->CanReadFile(inputFilename)) - std::cout << "can read file OK" << std::endl; - else - { - std::cout << "can read file K0" << std::endl; - return EXIT_FAILURE; - } - - std::vector<unsigned int> res; - std::vector<std::string> desc; - - bool readingResolutionInfo = readerJPEG2000->GetResolutionInfo(res, desc); - if (readingResolutionInfo == false ) - return EXIT_FAILURE; - - std::ofstream file; - file.open(outputAsciiFilename); - - // Parse all the names to delete the path of the filename - for( unsigned int itRes = 0; itRes < (unsigned int)res.size(); itRes++ ) - { - file << "RESOLUTION: " << res[itRes] << "; " << "DESC: " << desc[itRes] << std::endl; - } - - file.close(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/IO/otbMultiResolutionReadingInfo.cxx b/Testing/Code/IO/otbMultiResolutionReadingInfo.cxx new file mode 100644 index 0000000000..c5c233ab0f --- /dev/null +++ b/Testing/Code/IO/otbMultiResolutionReadingInfo.cxx @@ -0,0 +1,66 @@ +/*========================================================================= + + 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 <iostream> +#include <fstream> +#include <string> + +#include "itkMacro.h" +#include "itksys/SystemTools.hxx" +#include "otbJPEG2000ImageIO.h" + +int otbMultiResolutionReadingInfo(int argc, char* argv[]) +{ + if (argc != 3) + { + std::cout << argv[0] << "<image JPEG2000> <ouput filename>" << std::endl; + return EXIT_FAILURE; + } + const char * inputFilename = argv[1]; + const char * outputAsciiFilename = argv[2]; + + otb::JPEG2000ImageIO::Pointer readerJPEG2000 = otb::JPEG2000ImageIO::New(); + + readerJPEG2000->SetFileName(inputFilename); + if (readerJPEG2000->CanReadFile(inputFilename)) + std::cout << "can read file OK" << std::endl; + else + { + std::cout << "can read file K0" << std::endl; + return EXIT_FAILURE; + } + + std::vector<unsigned int> res; + std::vector<std::string> desc; + + bool readingResolutionInfo = readerJPEG2000->GetResolutionInfo(res, desc); + if (readingResolutionInfo == false ) + return EXIT_FAILURE; + + std::ofstream file; + file.open(outputAsciiFilename); + + // Parse all the names to delete the path of the filename + for( unsigned int itRes = 0; itRes < (unsigned int)res.size(); itRes++ ) + { + file << "RESOLUTION: " << res[itRes] << "; " << "DESC: " << desc[itRes] << std::endl; + } + + file.close(); + + return EXIT_SUCCESS; +} -- GitLab