Skip to content
Snippets Groups Projects
Commit 0592226c authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

TEST: add gistabletovectordatafilter test NEED gdal 1.6

parent 6cfd00d7
No related branches found
No related tags found
No related merge requests found
......@@ -845,11 +845,23 @@ otbGISTableToVectorDataFilterNew
ADD_TEST(coTvLabelMapToGISTableFilter ${COMMON_TESTS10}
otbLabelMapToGISTableFilter
${INPUTDATA}/rcc8_mire1.png
labelmaptogis_test
labelmaptogis_test_table
orfeotoolbox_test_user
Bidfeud0
)
#need gdal 1.6 for POSTGIS tables connection via OGR string
ADD_TEST(coTvGISTableToVectorDataFilter ${COMMON_TESTS10}
otbGISTableToVectorDataFilter
${TEMP}/gistabletovectordatafilter.shp
orfeotoolbox_test
labelmaptogis_test_table
orfeotoolbox_test_user
Bidfeud0
)
ENDIF(OTB_USE_PQXX)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -1064,6 +1076,7 @@ otbLabelMapToGISTableFilterNew.cxx
otbGISTableToLabelMapFilterNew.cxx
otbGISTableToVectorDataFilterNew.cxx
otbLabelMapToGISTableFilter.cxx
otbGISTableToVectorDataFilter.cxx
)
ENDIF(OTB_USE_PQXX)
......
......@@ -40,4 +40,6 @@ void RegisterTests()
REGISTER_TEST(otbUnaryFunctorWithIndexImageFilter);
REGISTER_TEST(otbLabelObjectMapVectorizer);
REGISTER_TEST(otbLabelMapToVectorDataFilter);
REGISTER_TEST(otbGISTableToVectorDataFilter);
}
/*=========================================================================
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 "otbVectorDataFileWriter.h"
//#include "otbImageFileWriter.h"
#include "otbVectorData.h"
//#include "otbVectorDataProjectionFilter.h"
//#include "otbVectorDataExtractROI.h"
#include <fstream>
#include <iostream>
//#include "itkRGBAPixel.h"
#include "otbPostGISTable.h"
#include "otbGISTableToVectorDataFilter.h"
//#include "itkAttributeLabelObject.h"
#include "otbPostGISConnectionImplementation.h"
int otbGISTableToVectorDataFilter(int argc, char * argv[])
{
/** Read a PostGIS table and write it in a VectorData. The Filter is based on the OGR reader/writer factory*/
if ( argc != 6 )
{
std::cerr << "Usage: " << argv[0];
std::cerr << " outputFile(shp) dbName tableName userName userPassword" << std::endl;
return EXIT_FAILURE;
}
const int dim = 2;
const std::string dbName = argv[2];
const std::string tableName = argv[3];
const std::string userName = argv[4];
const std::string userPassword = argv[5];
typedef unsigned char PType;
typedef otb::VectorData<double, dim> VectorDataType;
typedef otb::PostGISConnectionImplementation GISConnectionType;
typedef GISConnectionType::Pointer GISConnectionPointerType;
typedef otb::PostGISTable<GISConnectionType, double, dim> GISTableType;
//Instantiation
GISTableType::Pointer data = GISTableType::New();
GISConnectionPointerType myConnection = GISConnectionType::New();
myConnection->SetHost( "localhost" );
myConnection->SetDBName( dbName );
myConnection->SetUser( userName );
myConnection->SetPassword( userPassword );
data->SetConnection(myConnection);
data->SetTableName(tableName);
typedef otb::GISTableToVectorDataFilter< GISTableType , VectorDataType > GISTableToVectorDataFilter;
GISTableToVectorDataFilter::Pointer MyFilter = GISTableToVectorDataFilter::New();
std::cout << MyFilter << std::endl;
MyFilter->SetInput(data);
MyFilter->Update();
typedef otb::VectorDataFileWriter<VectorDataType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[1]);
writer->SetInput(MyFilter->GetOutput());
writer->Update();
//data->itkGetObjectMacro ( )
return EXIT_SUCCESS;
}
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