diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index e9357b851ff30ebe1a5f7c4b00d1218da451a352..6bf4561c6722e5a2834a93404c8b188d65f9c010 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -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 diff --git a/Testing/Code/Projections/otbProjectionsTests3.cxx b/Testing/Code/Projections/otbProjectionsTests3.cxx index 712ecb957e3f7d744fecb3a7eaf677de44ecf0ee..00db5e5f43a801da0f1654ecba813e7de0b43d01 100644 --- a/Testing/Code/Projections/otbProjectionsTests3.cxx +++ b/Testing/Code/Projections/otbProjectionsTests3.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); diff --git a/Testing/Code/Projections/otbVectorDataProjectionFilterFromMapToImage.cxx b/Testing/Code/Projections/otbVectorDataProjectionFilterFromMapToImage.cxx new file mode 100644 index 0000000000000000000000000000000000000000..df59f989f2e0c53592a54b9e368d55ee43f7fef0 --- /dev/null +++ b/Testing/Code/Projections/otbVectorDataProjectionFilterFromMapToImage.cxx @@ -0,0 +1,75 @@ +/*========================================================================= + + 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; +}