diff --git a/Testing/Code/Projections/CMakeLists.txt b/Testing/Code/Projections/CMakeLists.txt index 6849156851d2424a2e726f73a1a58717c7dca808..749b03674402d844d126785aae54fb2316fe608c 100644 --- a/Testing/Code/Projections/CMakeLists.txt +++ b/Testing/Code/Projections/CMakeLists.txt @@ -1214,6 +1214,25 @@ SET_TESTS_PROPERTIES(prTvVectorDataProjectionFilterFromGeoToMap PROPERTIES DEPEN +ADD_TEST(prTvGeometriesProjectionFilterFromMapToEPSG_UTM ${PROJECTIONS_TESTS3} + --compare-ogr ${NOTOL} + ${BASELINE_FILES}/prTvVectorDataProjectionFilterLines.shp + ${TEMP}/prTvGeometriesProjectionFilterFromMapToEPSG_UTM.shp + otbGeometriesProjectionFilterFromMapToEPSG + ${INPUTDATA}/ToulouseRoad-examples.shp + ${TEMP}/prTvGeometriesProjectionFilterFromMapToEPSG_UTM.shp + 32631 ) + +ADD_TEST(prTvGeometriesProjectionFilterFromMapToEPSG_WGS84 ${PROJECTIONS_TESTS3} + --compare-ogr ${NOTOL} + ${BASELINE_FILES}/prTvVectorDataProjectionFilterFromMapToGeo.kml + ${TEMP}/prTvGeometriesProjectionFilterFromMapToEPSG_WGS84.kml + otbGeometriesProjectionFilterFromMapToEPSG + ${INPUTDATA}/ToulousePoints-examples.shp + ${TEMP}/prTvGeometriesProjectionFilterFromMapToEPSG_WGS84.kml + 4326 ) + + ################### # TESTS ABOUT REPROJECTION INTO AN IMAGE OF A VECTORDATA IF(OTB_DATA_USE_LARGEINPUT) @@ -1683,6 +1702,7 @@ otbTileMapTransform.cxx otbVectorDataExtractROIandProjection.cxx otbGenericRSTransformGenericConversionCheckingFromGCP.cxx otbForwardBackwardProjectionConsistency.cxx +otbGeometriesProjectionFilterFromMapToEPSG.cxx ) SET(Projections_SRCS4 diff --git a/Testing/Code/Projections/otbGeometriesProjectionFilterFromMapToEPSG.cxx b/Testing/Code/Projections/otbGeometriesProjectionFilterFromMapToEPSG.cxx new file mode 100644 index 0000000000000000000000000000000000000000..beb5907906e5bb3a0ab6d27dc407edd7c443602b --- /dev/null +++ b/Testing/Code/Projections/otbGeometriesProjectionFilterFromMapToEPSG.cxx @@ -0,0 +1,56 @@ +/*========================================================================= + + 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 "itkMacro.h" +#include "otbOGR.h" +#include "otbGeometriesSet.h" +#include "otbGeometriesProjectionFilter.h" + +int otbGeometriesProjectionFilterFromMapToEPSG(int argc, char * argv[]) +{ + if (argc < 4) + { + std::cout << argv[0] << " <input vector filename> <output vector filename> <epsg>" << std::endl; + return EXIT_FAILURE; + } + + const char* inputVDFilename = argv[1]; + const char* outputVDFilename = argv[2]; + int epsg = atoi(argv[3]); + + typedef otb::GeometriesSet InputGeometriesType; + typedef otb::GeometriesSet OutputGeometriesType; + + otb::ogr::DataSource::Pointer input = otb::ogr::DataSource::New( + inputVDFilename, otb::ogr::DataSource::Modes::read); + InputGeometriesType::Pointer in_set = InputGeometriesType::New(input); + + typedef otb::GeometriesProjectionFilter GeometriesFilterType; + GeometriesFilterType::Pointer filter = GeometriesFilterType::New(); + + filter->SetInput(in_set); + filter->SetOutputProjectionRef( otb::GeoInformationConversion::ToWKT(epsg) ); + + otb::ogr::DataSource::Pointer output = otb::ogr::DataSource::New( + outputVDFilename, otb::ogr::DataSource::Modes::write); + OutputGeometriesType::Pointer out_set = OutputGeometriesType::New(output); + + filter->SetOutput(out_set); + filter->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Projections/otbProjectionsTests3.cxx b/Testing/Code/Projections/otbProjectionsTests3.cxx index 36d87277b3bf90ef6d2195fe15e1eb779e553891..298607bcc6d96e86f7efb49ef863b4fdb2e5c6fa 100644 --- a/Testing/Code/Projections/otbProjectionsTests3.cxx +++ b/Testing/Code/Projections/otbProjectionsTests3.cxx @@ -47,4 +47,6 @@ void RegisterTests() REGISTER_TEST(otbVectorDataIntoImageProjectionFilterTest); REGISTER_TEST(otbGenericRSTransformGenericConversionCheckingFromGCP); REGISTER_TEST(otbForwardBackwardProjectionConsistency); + REGISTER_TEST(otbGeometriesProjectionFilterFromMapToEPSG); + }