From dbd4a67b4d2bcc451ee8f8645bf028a148a6811e Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Wed, 3 Dec 2008 15:10:33 +0800
Subject: [PATCH] TEST: add non regression test for ImageFittingPolygon

---
 Testing/Code/FeatureExtraction/CMakeLists.txt       |  2 +-
 .../otbImageFittingPolygonListFilter.cxx            | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt
index 6381360185..d5448b7151 100644
--- a/Testing/Code/FeatureExtraction/CMakeLists.txt
+++ b/Testing/Code/FeatureExtraction/CMakeLists.txt
@@ -848,7 +848,7 @@ ADD_TEST(feTvImageFittingPolygonListFilter ${FEATUREEXTRACTION_TESTS9}
 --compare-ascii ${EPS}
 		${BASELINE_FILES}/feTvImageFittingPolygonListFilter_Output.kml
 		${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
-         otbImageToSIFTKeyPointSetFilterOutputAscii
+         otbImageFittingPolygonListFilter
 		${INPUTDATA}/polygon.png
 		${INPUTDATA}/polygon-start.kml
 		${TEMP}/feTvImageFittingPolygonListFilter_Output.kml
diff --git a/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx b/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx
index a30bdeaa91..35968ee020 100644
--- a/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx
+++ b/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx
@@ -50,7 +50,6 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[])
   CannyFilterType::Pointer canny = CannyFilterType::New();
   canny->SetInput(reader->GetOutput());
   
-  
   //Read the original polygon list (kml file)
   typedef otb::VectorData<> VectorDataType;
   typedef VectorDataType::DataTreeType         DataTreeType;
@@ -63,6 +62,7 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[])
   readerVector->SetFileName(polyFileName);
   readerVector->Update();
 
+  //Copy the polygons of the data tree in a polygon list
   typedef otb::ObjectList<PolygonType> PolygonListType;
   PolygonListType::Pointer polygonList = PolygonListType::New();
   
@@ -76,6 +76,7 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[])
     {
       polygonList->PushBack(dataNode->GetPolygonExteriorRing());
     }
+    ++it;
   }
   
   //Fit the polygons on the image
@@ -89,21 +90,17 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[])
   fittingPolygon->Update();
 
   
-  //Read the improved polygon list (kml file)
+  //Write the improved polygon list (kml file)
   VectorDataType::Pointer data = VectorDataType::New();
  
   DataNodeType::Pointer document = DataNodeType::New();
   DataNodeType::Pointer folder = DataNodeType::New();
-  DataNodeType::Pointer polygon = DataNodeType::New();
   
-
   document->SetNodeType(otb::DOCUMENT);
   folder->SetNodeType(otb::FOLDER);
-  polygon->SetNodeType(otb::FEATURE_POLYGON);
 
   document->SetNodeId("DOCUMENT");
   folder->SetNodeId("FOLDER");
-  polygon->SetNodeId("FEATURE_POLYGON");
 
   DataNodeType::Pointer root = data->GetDataTree()->GetRoot()->Get();
 
@@ -114,8 +111,12 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[])
   ListIteratorType listIt = fittingPolygon->GetOutput()->Begin();
   while(listIt  != fittingPolygon->GetOutput()->End())
   {
+    DataNodeType::Pointer polygon = DataNodeType::New();
+    polygon->SetNodeType(otb::FEATURE_POLYGON);
+    polygon->SetNodeId("FEATURE_POLYGON");
     polygon->SetPolygonExteriorRing(listIt.Get());
     data->GetDataTree()->Add(polygon,folder);
+    ++listIt;
   }
   
   typedef otb::VectorDataFileWriter<VectorDataType> WriterType;
-- 
GitLab