diff --git a/Modules/Adapters/GdalAdapters/otb-module.cmake b/Modules/Adapters/GdalAdapters/otb-module.cmake index 637a63ed4226e96af21f3fb7b3a1136c6db100b0..c985c5fb0e477a9f35de9a629e506d865239ee5e 100644 --- a/Modules/Adapters/GdalAdapters/otb-module.cmake +++ b/Modules/Adapters/GdalAdapters/otb-module.cmake @@ -29,6 +29,9 @@ ENABLE_SHARED OTBGDAL OTBITK + TEST_DEPENDS + OTBTestKernel + DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index e3c150a7c40a8ab45b1ee2c08472af9a9cdb5de7..cf846f576dcde5eb4105e5a4366113d92494b7c2 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -38,16 +38,31 @@ target_link_libraries(otbOGRTestsIO ${OTBGdalAdapters-Test_LIBRARIES}) otb_add_test(NAME coTuOGRDataSourceWrapperIO COMMAND otbOGRTestsIO ${INPUTDATA}/ToulousePoints-examples.shp ) -add_executable(otbOGRExtendedFilenameTest otbOGRExtendedFilenameToOptionsTest.cxx) -target_link_libraries(otbOGRExtendedFilenameTest ${OTBGdalAdapters-Test_LIBRARIES}) +set(OTBOGRTests +otbOGRTestDriver.cxx +otbOGRExtendedFilenameToOptionsTest.cxx +otbOGRExtendedFilenameToOptionsGDALTest.cxx +) + +add_executable(otbOGRTestDriver ${OTBOGRTests}) +target_link_libraries(otbOGRTestDriver ${OTBGdalAdapters-Test_LIBRARIES}) +otb_module_target_label(otbOGRTestDriver) otb_add_test(NAME TvOGRExtendedFilename - COMMAND otbOGRExtendedFilenameTest + COMMAND otbOGRTestDriver --compare-ascii ${NOTOL} - ${BASELINE}/TvOGRExtendedFilename.txt - ${TEMP}/TvOGRExtendedFilename.txt + ${BASELINE}/TvOGRExtendedFilename.txt + ${TEMP}/TvOGRExtendedFilenameTest.txt + otbOGRExtendedFileName test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION - ${TEMP}/TvOGRExtendedFilename.txt ) -otb_module_target_label(otbOGRExtendedFilenameTest) + ${TEMP}/TvOGRExtendedFilenameTest.txt ) + +otb_add_test(NAME TvOGRExtendedFilenameGDAL + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDAL + ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION + ${TEMP}/test.shp?&gdal:co:creationOption=OPTION&gdal:lco:layerOption=OPTION + ) + message(STATUS "Test link : ${OTBGdalAdapters-Test_LIBRARIES}") \ No newline at end of file diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a35f21042f9b491c1c302f32770f770ba02a2750 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "cpl_error.h" +#include "otbOGRExtendedFilenameToOptions.h" +#include "otbOGRDataSourceWrapper.h" +#include <iostream> +#include <fstream> + + +int otbOGRExtendedFileNameGDAL(int , char* argv[]) +{ + bool success = true ; + const char * inputOpen = argv[1]; + const char * inputCreation = argv[2]; + auto test = otb::ogr::DataSource::New( inputOpen ); + // std::cout<<"here"<<std::endl; + std::string error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // if ( error.find( "does not support open option openOption" ) != std::string::npos ) + // success = true && success ; + // else + // success = false ; + // std::cout<<success<<std::endl; + + + test = otb::ogr::DataSource::New( inputCreation , otb::ogr::DataSource::Modes::Update_LayerOverwrite); +error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // error = CPLGetLastErrorMsg(); + // std::cout<<error<<std::endl; + // if ( std::string(error).find( "does not support creation option creationOption" ) != std::string::npos ) + // success = true && success ; + // else + // success = false ; + // std::cout<<success<<std::endl; + + test->CreateLayer( "2layertest" , + ITK_NULLPTR , + wkbUnknown , + std::vector< std::string > { "newOption=OPTION" } ); +error = CPLGetLastErrorMsg(); + if ( !error.empty() ) + std::cout<<error<<std::endl; + // error = CPLGetLastErrorMsg(); + // std::cout<<error<<std::endl; + // if ( std::string(error).find( "toto" ) != std::string::npos ) + // success = true && success; + // else + // success = false ; + // std::cout<<success<<std::endl; + + return EXIT_SUCCESS; +} + + diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx index 47636bf5ec0d3e776df421511dc8b2678ba836c5..45c39a2b236095cb52dc2e82612b6320c8786d3b 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsTest.cxx @@ -27,12 +27,13 @@ using namespace otb; typedef OGRExtendedFilenameToOptions FilenameHelperType; -int main(int , char* argv[]) +int otbOGRExtendedFileName(int , char* argv[]) { // Verify the number of parameters in the command line const char * inputExtendedFilename = argv[1]; const char * outputFilename = argv[2]; + std::cout<< argv[1] <<" "<<argv[2]<<std::endl; FilenameHelperType::Pointer helper = FilenameHelperType::New(); helper->SetExtendedFileName(inputExtendedFilename); @@ -69,6 +70,7 @@ int main(int , char* argv[]) layer.push_back("TOTO=first"); FilenameHelperType::Pointer layerHelper = FilenameHelperType::GetGDALLayerOptionsHelper ( layer ); + std::cout<< layerHelper->GetGDALLayerOptions()[0] <<std::endl; FilenameHelperType::GDALOptionType newOptions; // std::vector< std::string> newOptions; newOptions.push_back("TOTO=second"); diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0793f8c07dfcf0b3b0e7a52b65c859df73d9fe35 --- /dev/null +++ b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbTestMain.h" + +void RegisterTests() +{ + REGISTER_TEST(otbOGRExtendedFileName); + REGISTER_TEST(otbOGRExtendedFileNameGDAL); +}