Skip to content
Snippets Groups Projects
Commit 773cd6db authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

TEST: add non regression test for ImageFittingPolygon

parent 8b491d92
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment