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

TEST: add test for vector data conversion to image coordinates

parent 522e2849
No related branches found
No related tags found
No related merge requests found
......@@ -457,6 +457,17 @@ ADD_TEST(prTvVectorDataProjectionFilterFromMapToGeo ${PROJECTIONS_TESTS3}
${TEMP}/prTvVectorDataProjectionFilterFromMapToGeo.kml
)
ADD_TEST(prTvVectorDataProjectionFilterFromMapToImage ${PROJECTIONS_TESTS3}
--compare-ascii ${NOTOL}
${BASELINE_FILES}/prTvVectorDataProjectionFilterFromMapToImage.kml
${TEMP}/prTvVectorDataProjectionFilterFromMapToImage.kml
otbVectorDataProjectionFilterFromMapToImage
${INPUTDATA}/ToulousePoints-examples.shp
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/prTvVectorDataProjectionFilterFromMapToImage.kml
)
ADD_TEST(prTuGeocentricTransformNew ${PROJECTIONS_TESTS3} otbGeocentricTransformNew )
......@@ -509,6 +520,7 @@ otbVectorDataProjectionFilterNew.cxx
otbVectorDataProjectionFilter.cxx
otbVectorDataProjectionFilterFromMapToSensor.cxx
otbVectorDataProjectionFilterFromMapToGeo.cxx
otbVectorDataProjectionFilterFromMapToImage.cxx
otbGeocentricTransformNew.cxx
otbGeocentricTransform.cxx
otbVectorDataExtractROIandProjection.cxx
......
......@@ -37,6 +37,7 @@ void RegisterTests()
REGISTER_TEST(otbVectorDataProjectionFilter);
REGISTER_TEST(otbVectorDataProjectionFilterFromMapToSensor);
REGISTER_TEST(otbVectorDataProjectionFilterFromMapToGeo);
REGISTER_TEST(otbVectorDataProjectionFilterFromMapToImage);
REGISTER_TEST(otbGeocentricTransformNew);
REGISTER_TEST(otbGeocentricTransform);
REGISTER_TEST(otbVectorDataExtractROIandProjection);
......
/*=========================================================================
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 "itkExceptionObject.h"
#include "otbVectorDataProjectionFilter.h"
#include "otbVectorData.h"
#include "otbVectorDataFileReader.h"
#include "otbVectorDataFileWriter.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
int otbVectorDataProjectionFilterFromMapToImage(int argc, char * argv[])
{
if (argc < 4 )
{
std::cout << argv[0] <<" <input vector filename> <input image filename>"
<< " <output vector filename> " << std::endl;
return EXIT_FAILURE;
}
typedef otb::VectorData<double > InputVectorDataType;
typedef otb::VectorData<double > OutputVectorDataType;
typedef otb::VectorDataFileReader<InputVectorDataType> VectorDataFileReaderType;
VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New();
reader->SetFileName(argv[1]);
reader->UpdateOutputInformation();
typedef otb::Image<unsigned short int, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ImageReaderType;
ImageReaderType::Pointer imageReader = ImageReaderType::New();
imageReader->SetFileName(argv[2]);
imageReader->UpdateOutputInformation();
typedef otb::VectorDataProjectionFilter<InputVectorDataType,OutputVectorDataType> VectorDataFilterType;
VectorDataFilterType::Pointer vectorDataProjection = VectorDataFilterType::New();
vectorDataProjection->SetInput(reader->GetOutput());
vectorDataProjection->SetOutputProjectionRef(imageReader->GetOutput()->GetProjectionRef());
vectorDataProjection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin());
vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSpacing());
typedef otb::VectorDataFileWriter<OutputVectorDataType> VectorDataFileWriterType;
VectorDataFileWriterType::Pointer writer = VectorDataFileWriterType::New();
writer->SetFileName(argv[3]);
writer->SetInput(vectorDataProjection->GetOutput());
writer->Update();
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