From 6aaa40bda6ec8c7b44613a4b67e9c564d2bc4f04 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Fri, 23 Feb 2007 16:56:14 +0000 Subject: [PATCH] oubli --- .../IO/otbImageMetadataFileWriterTest.cxx | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 Testing/Code/IO/otbImageMetadataFileWriterTest.cxx diff --git a/Testing/Code/IO/otbImageMetadataFileWriterTest.cxx b/Testing/Code/IO/otbImageMetadataFileWriterTest.cxx new file mode 100755 index 0000000000..b022f70383 --- /dev/null +++ b/Testing/Code/IO/otbImageMetadataFileWriterTest.cxx @@ -0,0 +1,80 @@ +/*========================================================================= + + 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 "otbVectorImage.h" +#include "itkExceptionObject.h" +#include <iostream> + +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbImageMetadataFileWriterTest(int argc, char* argv[]) +{ + try + { + // Verify the number of parameters in the command line + const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; + const char * metadataFilename = argv[3]; + + typedef unsigned char InputPixelType; + typedef unsigned char OutputPixelType; + const unsigned int Dimension = 2; + + typedef otb::VectorImage< InputPixelType, Dimension > InputImageType; + typedef otb::VectorImage< OutputPixelType, Dimension > OutputImageType; + + typedef otb::ImageFileReader< InputImageType > ReaderType; + typedef otb::ImageFileWriter< OutputImageType > WriterType; + + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + + reader->SetFileName( inputFilename ); + writer->SetFileName( outputFilename ); + + writer->SetInput( reader->GetOutput() ); + writer->Update(); + + ReaderType::Pointer metadataReader = ReaderType::New(); + metadataReader->SetFileName(outputFilename); + metadataReader->Update(); + + std::ofstream of; + of.open(metadataFilename); + of<<metadataReader->GetOutput(); + of.close(); + } + catch( itk::ExceptionObject & err ) + { + std::cerr << "Exception OTB attrappee dans exception ITK !" << std::endl; + std::cerr << err << std::endl; + return EXIT_FAILURE; + } + catch( ... ) + { + std::cerr << "Exception OTB non attrappee !" << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} -- GitLab