From e125be1d9d73fd46940644359c31f81984aac6cc Mon Sep 17 00:00:00 2001
From: Aurelien Bricier <aurelien.bricier@c-s.fr>
Date: Thu, 22 Nov 2012 11:49:32 +0100
Subject: [PATCH] ENH: added external GEOM file handling testing

---
 Testing/Code/IO/CMakeLists.txt             | 11 +++++++++
 Testing/Code/IO/otbIOTests1.cxx            |  1 +
 Testing/Code/IO/otbImageFileReaderTest.cxx | 28 ++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt
index 2ce629166f..e2de9c9bb3 100644
--- a/Testing/Code/IO/CMakeLists.txt
+++ b/Testing/Code/IO/CMakeLists.txt
@@ -3725,6 +3725,17 @@ ADD_TEST(raTuWavelengthSpectralBandsNew ${IO_TESTS23}
   ENDFOREACH(NBBANDS ${NBBANDS_LIST})
 
 ENDFOREACH(DATA_PIXELTYPE ${DATA_PIXELTYPES_LIST})
+
+ADD_TEST(ioTvImageFileReaderWithExternalGEOMFile ${IO_TESTS1}
+--compare-ascii ${NOTOL}
+         ${BASELINE}/ioImageFileReaderWithExternalGEOMFile.txt
+         ${TEMP}/ioImageFileReaderWithExternalGEOMFile.txt
+	otbImageFileReaderWithExternalGEOMFile
+        ${INPUTDATA}/ToulouseExtract_WithGeom.tif
+        ${INPUTDATA}/ToulouseExtract_ModifiedGeom.geom
+        ${TEMP}/ioImageFileReaderWithExternalGEOMFile.txt
+        )
+
 #----------------------------------------------------------------------------------
 SET(BasicIO_SRCS1
 otbIOTests1.cxx
diff --git a/Testing/Code/IO/otbIOTests1.cxx b/Testing/Code/IO/otbIOTests1.cxx
index bb05c22a0b..d90899f931 100644
--- a/Testing/Code/IO/otbIOTests1.cxx
+++ b/Testing/Code/IO/otbIOTests1.cxx
@@ -29,6 +29,7 @@ void RegisterTests()
   REGISTER_TEST(otbMWImageIOTestCanRead);
   REGISTER_TEST(otbMWImageIOTestCanWrite);
   REGISTER_TEST(otbImageFileReaderTest);
+  REGISTER_TEST(otbImageFileReaderWithExternalGEOMFile);
   REGISTER_TEST(otbImageFileReaderTestFloat);
   REGISTER_TEST(otbShortImageIOTest);
   REGISTER_TEST(otbImageIOFactoryNew);
diff --git a/Testing/Code/IO/otbImageFileReaderTest.cxx b/Testing/Code/IO/otbImageFileReaderTest.cxx
index 5713e4ac41..fdf2be76ca 100644
--- a/Testing/Code/IO/otbImageFileReaderTest.cxx
+++ b/Testing/Code/IO/otbImageFileReaderTest.cxx
@@ -52,3 +52,31 @@ int otbImageFileReaderTest(int argc, char* argv[])
 
   return EXIT_SUCCESS;
 }
+
+int otbImageFileReaderWithExternalGEOMFile(int argc, char* argv[])
+{
+  // Verify the number of parameters in the command line
+  const char * inputFilename  = argv[1];
+  const char * inputGEOMFilename  = argv[2];
+  const char * outputFilename = argv[3];
+
+  typedef float InputPixelType;
+  const unsigned int Dimension = 2;
+
+  typedef otb::Image<InputPixelType,  Dimension> InputImageType;
+
+  typedef otb::ImageFileReader<InputImageType>  ReaderType;
+
+  ReaderType::Pointer reader = ReaderType::New();
+
+  std::ofstream file;
+  file.open(outputFilename);
+
+  reader->SetFileName(inputFilename);
+  reader->SetExtGEOMFilename(inputGEOMFilename);
+  reader->Update();
+
+  file << reader->GetOutput()->GetImageKeywordlist();
+
+  return EXIT_SUCCESS;
+}
-- 
GitLab