From 0ffeb9cca1681833f4eeedc9216a59b10e3eb7e2 Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Tue, 7 Sep 2010 11:56:58 +0200
Subject: [PATCH] ADD : tests for PhysicalToSensorModel image filter

---
 Testing/Code/Projections/CMakeLists.txt       | 16 +++++
 ...otbPhysicalToRPCSensorModelImageFilter.cxx | 59 +++++++++++++++++++
 ...PhysicalToRPCSensorModelImageFilterNew.cxx | 35 +++++++++++
 .../Code/Projections/otbProjectionsTests4.cxx |  2 +
 4 files changed, 112 insertions(+)
 create mode 100644 Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx
 create mode 100644 Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx

diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt
index ebab0ef270..548c016444 100644
--- a/Testing/Code/Projections/CMakeLists.txt
+++ b/Testing/Code/Projections/CMakeLists.txt
@@ -598,6 +598,20 @@ ENDIF(OTB_DATA_USE_LARGEINPUT)
 
 
 
+ADD_TEST(prTuPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4}
+  otbPhysicalToRPCSensorModelImageFilterNew
+  )
+
+IF(OTB_DATA_USE_LARGEINPUT)
+ADD_TEST(prTvPhysicalToRPCSensorModelImageFilter ${PROJECTIONS_TESTS4}
+  otbPhysicalToRPCSensorModelImageFilter
+  ${LARGEINPUT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_PAN/02APR01105228-P1BS-000000128955_01_P001.TIF
+  1000
+  ${TEMP}/prTvotbPhysicalToRPCSensorModelImageFilter.tif
+  )
+ENDIF(OTB_DATA_USE_LARGEINPUT)
+
+
 
 #=======================================================================================
 SET(Projections_SRCS1
@@ -649,6 +663,8 @@ SET(Projections_SRCS4
 otbProjectionsTests4.cxx
 otbOptResampleImageFilterNew.cxx
 otbOptResampleImageFilter.cxx
+otbPhysicalToRPCSensorModelImageFilterNew.cxx
+otbPhysicalToRPCSensorModelImageFilter.cxx
 )
 
 OTB_ADD_EXECUTABLE(otbProjectionsTests1 "${Projections_SRCS1}" "OTBProjections;OTBIO;OTBTesting")
diff --git a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx
new file mode 100644
index 0000000000..c1fc4d13dd
--- /dev/null
+++ b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilter.cxx
@@ -0,0 +1,59 @@
+/*=========================================================================
+
+  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 "otbPhysicalToRPCSensorModelImageFilter.h"
+#include "otbVectorImage.h"
+#include "otbImageFileReader.h"
+#include "otbStreamingImageFileWriter.h"
+
+int otbPhysicalToRPCSensorModelImageFilter(int argc, char* argv[])
+{
+  const char * infname  = argv[1];
+  unsigned int gridSpacing = atoi(argv[2]);
+  const char * outfname  = argv[3];
+  
+  // Images definition
+  const unsigned int Dimension = 2;
+  typedef double                                      PixelType;
+  typedef otb::VectorImage<PixelType, Dimension>      ImageType;
+  typedef otb::ImageFileReader<ImageType>             ReaderType;
+  
+  typedef otb::PhysicalToRPCSensorModelImageFilter<ImageType> PhysicalToSensorModelType;
+
+  // Object instanciation
+  PhysicalToSensorModelType::Pointer estimator = PhysicalToSensorModelType::New();
+  ReaderType::Pointer                reader    = ReaderType::New();
+  
+  // Set the fileName
+  reader->SetFileName(infname);
+  reader->UpdateOutputInformation();
+  
+  estimator->SetInput(reader->GetOutput());
+  estimator->SetGridSpacing(gridSpacing);
+
+  // Write the resampled image
+  typedef otb::StreamingImageFileWriter<ImageType>    WriterType;
+  WriterType::Pointer writer= WriterType::New();
+  writer->SetTilingStreamDivisions();
+  writer->WriteGeomFileOn();
+  writer->SetFileName(outfname);
+  writer->SetInput(estimator->GetOutput());
+  writer->Update();
+  
+  return 0;
+}
diff --git a/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx
new file mode 100644
index 0000000000..3e0bd49bbb
--- /dev/null
+++ b/Testing/Code/Projections/otbPhysicalToRPCSensorModelImageFilterNew.cxx
@@ -0,0 +1,35 @@
+/*=========================================================================
+
+  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 "otbPhysicalToRPCSensorModelImageFilter.h"
+#include "otbVectorImage.h"
+
+int otbPhysicalToRPCSensorModelImageFilterNew(int argc, char* argv[])
+{
+  // Images definition
+  const unsigned int Dimension = 2;
+  typedef double                                      PixelType;
+  typedef otb::VectorImage<PixelType, Dimension>      ImageType;
+  
+  typedef otb::PhysicalToRPCSensorModelImageFilter<ImageType> PhysicalToSensorModelType;
+
+  // Instanciation of the filter
+  PhysicalToSensorModelType::Pointer resampler = PhysicalToSensorModelType::New();
+  
+  return 0;
+}
diff --git a/Testing/Code/Projections/otbProjectionsTests4.cxx b/Testing/Code/Projections/otbProjectionsTests4.cxx
index 9061dc8abe..aa921f90c5 100644
--- a/Testing/Code/Projections/otbProjectionsTests4.cxx
+++ b/Testing/Code/Projections/otbProjectionsTests4.cxx
@@ -28,4 +28,6 @@ void RegisterTests()
 {
   REGISTER_TEST(otbOptResampleImageFilterNew);
   REGISTER_TEST(otbOptResampleImageFilter);
+  REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilterNew);
+  REGISTER_TEST(otbPhysicalToRPCSensorModelImageFilter);
 }
-- 
GitLab