diff --git a/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx b/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx index 259cf6458df0baa13c50be9244db122ddf012436..a30bdeaa91a1850df5c7ea712598b255d7a5cf10 100644 --- a/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx +++ b/Testing/Code/FeatureExtraction/otbImageFittingPolygonListFilter.cxx @@ -21,7 +21,11 @@ #include "otbPolygon.h" #include "otbImage.h" #include "otbVectorData.h" +#include "otbImageFileReader.h" #include "otbVectorDataFileReader.h" +#include "otbVectorDataFileWriter.h" +#include "itkCannyEdgeDetectionImageFilter.h" +#include "otbObjectList.h" #include <fstream> #include <cstdlib> @@ -30,8 +34,8 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[]) const char * imageFileName = argv[1]; const char * polyFileName = argv[2]; const char * outFileName = argv[3]; - const int fittingRadius = ato(argv[4]); - const int fittingIters = ato(argv[5]); + const int fittingRadius = atoi(argv[4]); + const int fittingIters = atoi(argv[5]); const unsigned int Dimension =2; typedef otb::Polygon<double> PolygonType; @@ -51,8 +55,10 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[]) typedef otb::VectorData<> VectorDataType; typedef VectorDataType::DataTreeType DataTreeType; typedef itk::PreOrderTreeIterator<DataTreeType> TreeIteratorType; + typedef VectorDataType::DataNodeType DataNodeType; + typedef DataNodeType::Pointer DataNodePointerType; typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType; - VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); + VectorDataFileReaderType::Pointer readerVector = VectorDataFileReaderType::New(); readerVector->SetFileName(polyFileName); readerVector->Update(); @@ -60,7 +66,7 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[]) typedef otb::ObjectList<PolygonType> PolygonListType; PolygonListType::Pointer polygonList = PolygonListType::New(); - TreeIteratorType it(vectorReader->GetOutput()->GetDataTree()); + TreeIteratorType it(readerVector->GetOutput()->GetDataTree()); it.GoToBegin(); while(!it.IsAtEnd()) @@ -93,25 +99,27 @@ int otbImageFittingPolygonListFilter(int argc, char * argv[]) document->SetNodeType(otb::DOCUMENT); folder->SetNodeType(otb::FOLDER); - polygon->SetNodeType(otb::POLYGON); + polygon->SetNodeType(otb::FEATURE_POLYGON); document->SetNodeId("DOCUMENT"); folder->SetNodeId("FOLDER"); - polygon->SetNodeId("POLYGON"); + polygon->SetNodeId("FEATURE_POLYGON"); DataNodeType::Pointer root = data->GetDataTree()->GetRoot()->Get(); data->GetDataTree()->Add(document,root); data->GetDataTree()->Add(folder,document); + typedef PolygonListType::ConstIterator ListIteratorType; ListIteratorType listIt = fittingPolygon->GetOutput()->Begin(); while(listIt != fittingPolygon->GetOutput()->End()) { - polygon->SetPolygon(listIt.Get()); + polygon->SetPolygonExteriorRing(listIt.Get()); data->GetDataTree()->Add(polygon,folder); } typedef otb::VectorDataFileWriter<VectorDataType> WriterType; + WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outFileName); writer->SetInput(data); writer->Update();