diff --git a/Examples/Projections/CMakeLists.txt b/Examples/Projections/CMakeLists.txt index f627e3b621ffc38ee0daef5157327736e4c8ca77..b0d60fa5a11df9dfcb88abe0f484d8672fdaf0eb 100644 --- a/Examples/Projections/CMakeLists.txt +++ b/Examples/Projections/CMakeLists.txt @@ -116,8 +116,12 @@ ADD_TEST(prTePlaceNameToLonLatExampleTest ${EXE_TESTS2} Toulouse ) ADD_TEST(prTeCoordinateToNameExampleTest ${EXE_TESTS2} + --compare-ascii ${TOL} + ${BASELINE}/CoordinateToNameExample.txt + ${TEMP}/CoordinateToNameExample.txt CoordinateToNameExampleTest 103.78 1.29 + ${TEMP}/CoordinateToNameExample.txt ) ENDIF( OTB_USE_CURL ) diff --git a/Examples/Projections/CoordinateToNameExample.cxx b/Examples/Projections/CoordinateToNameExample.cxx index 727eaad4ef80475b9d1073815190d017889964fd..bdc7f5628172587af7727f3de89c1afcb32b4868 100644 --- a/Examples/Projections/CoordinateToNameExample.cxx +++ b/Examples/Projections/CoordinateToNameExample.cxx @@ -19,21 +19,22 @@ #pragma warning ( disable : 4786 ) #endif +#include <fstream> #include "otbCoordinateToName.h" - int main( int argc, char* argv[] ) { - if (argc!=3) + if (argc!=4) { - std::cout << argv[0] <<" <lon> <lat>" + std::cout << argv[0] <<" <lon> <lat> <outputfile>" << std::endl; return EXIT_FAILURE; } + const char * outFileName = argv[3]; otb::CoordinateToName::Pointer conv = otb::CoordinateToName::New(); conv->SetLon(atof(argv[1])); @@ -46,6 +47,11 @@ int main( int argc, char* argv[] ) std::cout << "Nearby place: " << name << std::endl; std::cout << "Country: " << country << std::endl; + std::ofstream file; + file.open(outFileName); + file << "Nearby place: " << name << std::endl; + file << "Country: " << country << std::endl; + file.close(); return EXIT_SUCCESS;