diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14447a38dc8eacbe4120bcdc5930ad6f491e124f..a838014572ca9689b62b75f3d77368071d453296 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,11 +54,11 @@ stages: paths: - build/*/*.log #CMake log - log/*.txt # Others - - build/CookBook-*-html.tar.gz - - build/Documentation/Cookbook/latex/CookBook-*.pdf - - build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2 - - build_packages/OTB-*.run - - build_packages/OTB-*.zip + - CookBook-*-html.tar.gz + - CookBook-*.pdf + - OTB-Doxygen-*.tar.bz2 + - OTB-*.run + - OTB-*.zip - build/compile_commands.json - build/ctest_report.xml - build/cppcheck_report.xml @@ -81,6 +81,7 @@ stages: paths: - sb_branch.txt # Needed to checkout correct branch in build step - build/*/*/*/*.log # Superbuild log + - build/*/*/*/*.cmake #-------------------------- precheck job --------------------------------------- fast-build: @@ -111,12 +112,16 @@ ubuntu-xdk-prepare: script: - ctest -VV -S CI/prepare_superbuild.cmake -DIMAGE_NAME:string=otb-ubuntu-superbuild-base -ubuntu-xdk-build: +ubuntu-xdk-build-doc: extends: .common-build image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-superbuild-base:18.04 script: - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=ubuntu-18.04-llvm-xdk + - mv build/CookBook-*-html.tar.gz . || true + - mv build/Documentation/Cookbook/latex/CookBook-*.pdf . || true + - mv build/Documentation/Doxygen/OTB-Doxygen-*.tar.bz2 . || true - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=otb-ubuntu-superbuild-base -DNAME_SUFFIX:string=-glibc-2.27 + - mv build_packages/OTB-*.run . || true dependencies: - ubuntu-xdk-prepare @@ -133,6 +138,7 @@ centos-xdk-build: script: - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=otb-centos-superbuild-base - xvfb-run -a -n 1 -s "-screen 0 1024x768x24 -dpi 96" ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=otb-centos-superbuild-base + - mv build_packages/OTB-*.run . || true dependencies: - centos-xdk-prepare @@ -151,6 +157,7 @@ macos-xdk-build: script: - ctest -V -S CI/main_superbuild.cmake -DIMAGE_NAME:string=otb-macos-superbuild - ctest -V -S CI/main_packages.cmake -DIMAGE_NAME:string=otb-macos-superbuild + - mv build_packages/OTB-*.run . || true dependencies: - macos-xdk-prepare @@ -190,6 +197,7 @@ windows-10-build: - ctest -V -S CI/main_superbuild.cmake - clcache.exe -s - ctest -V -S CI/main_packages.cmake + - move "build_packages\OTB-*.zip" . || dir build_packages dependencies: - windows-10-prepare @@ -214,6 +222,7 @@ windows-8-build: - ctest -V -S CI/main_superbuild.cmake - clcache.exe -s - ctest -V -S CI/main_packages.cmake + - move "build_packages\OTB-*.zip" . || dir build_packages dependencies: - windows-8-prepare @@ -305,7 +314,7 @@ deploy: script: - ./CI/deploy.sh $CI_COMMIT_REF_NAME $RC_NUMBER dependencies: - - ubuntu-xdk-build + - ubuntu-xdk-build-doc - centos-xdk-build - macos-xdk-build - windows-8-build diff --git a/.gitlab/issue_templates/release.md b/.gitlab/issue_templates/release.md index 5f7441d580c7c1a808d98f3cfe5fb16f0d790f45..fce450b8453dea9babc99fb33f604ed9faa10f89 100644 --- a/.gitlab/issue_templates/release.md +++ b/.gitlab/issue_templates/release.md @@ -8,7 +8,6 @@ We are ready to release OTB version MAJOR.MINOR.PATCH. The following steps need ### 2. Housekeeping * [ ] In this story, make a list of blocking issues for the release (if any) -* [ ] [Update dashboard scripts](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#dashboard) to support new version numbers * [ ] [Update the SuperBuild archive](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#superbuild-archive) (if needed) * [ ] Update release notes (walk the GitLab MR merged history and log all improvements) * [ ] Update the date in RELEASE_NOTES.txt @@ -31,9 +30,8 @@ Once all blocking issues are closed, and the previous steps are done: ### 4. Publish and plan next release * [ ] [Prepare and upload source packages](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#prepare-and-upload-source-packages) -* [ ] [Promote nightly packages](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#promote-nightly-packages) +* [ ] [Promote staging packages](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#promote-staging-packages) * [ ] [Update documentation](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/Help-for-release-actions#update-documentation) - * [ ] Software Guide * [ ] Cookbook * [ ] Doxygen * [ ] WordPress page "Home" and "Download" pages @@ -43,7 +41,6 @@ Once all blocking issues are closed, and the previous steps are done: * [ ] Announcement on social networks (twitter, google+) * [ ] Forward announcement to news_item@osgeo.org ([OSGeo news](https://www.osgeo.org/foundation-news/)) * [ ] Plan the next release (nominate new release manager, setup PSC meeting on IRC) -* [ ] Contact QGis processing plugin maintainer to update XML description for new OTB-Applications (or [supply it](https://wiki.orfeo-toolbox.org/index.php/QGIS_access_to_OTB_applications#updating-the-XML-descriptors)) * [ ] Remove public branches related to MR or bugfix merged before the release /label ~story diff --git a/CI/Dockerfile.nat b/CI/Dockerfile.nat deleted file mode 100644 index 191c5eeb7c1d82041773c58b7baac49a73a1c051..0000000000000000000000000000000000000000 --- a/CI/Dockerfile.nat +++ /dev/null @@ -1,78 +0,0 @@ -FROM ubuntu:18.04 -MAINTAINER Sebastien Dinot <sebastien.dinot@c-s.fr> - -ENV DEBIAN_FRONTEND noninteractive - -RUN echo "Europe/Paris" > /etc/timezone - -# ---------------------------------------------------------------------------- -# First stage : install tools (they rarely evolve) -# ---------------------------------------------------------------------------- -RUN apt-get update -y \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - curl \ - make \ - cmake \ - ninja-build \ - g++ \ - gcc \ - clang \ - clang-tidy \ - clang-format \ - ccache \ - git \ - libtool \ - swig \ - xvfb \ - && rm -rf /var/lib/apt/lists/* - -# ---------------------------------------------------------------------------- -# Second stage : dependencies (they evolve more often) -# ---------------------------------------------------------------------------- -RUN apt-get update -y \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - freeglut3-dev \ - libboost-date-time-dev \ - libboost-filesystem-dev \ - libboost-graph-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-thread-dev \ - libcurl4-gnutls-dev \ - libexpat1-dev \ - libfftw3-dev \ - libgdal-dev \ - libgeotiff-dev \ - libglew-dev \ - libglfw3-dev \ - libgsl-dev \ - libinsighttoolkit4-dev \ - libkml-dev \ - libmuparser-dev \ - libmuparserx-dev \ - libopencv-core-dev \ - libopencv-ml-dev \ - libopenmpi-dev \ - libopenthreads-dev \ - libossim-dev \ - libpng-dev \ - libqt5opengl5-dev \ - libqwt-qt5-dev \ - libsvm-dev \ - libtinyxml-dev \ - qtbase5-dev \ - qttools5-dev \ - default-jdk \ - python-dev \ - python-numpy \ - python-gdal \ - python3-dev \ - python3-numpy \ - python3-gdal \ - && rm -rf /var/lib/apt/lists/* - -ENV PATH /usr/lib/ccache:$PATH -ENV OTB_USE_SHARK OFF diff --git a/CI/Dockerfile.shark3.1.4 b/CI/Dockerfile.shark3.1.4 deleted file mode 100644 index 96f52716c097c5f1ca36fa0de85710a2b619e7d8..0000000000000000000000000000000000000000 --- a/CI/Dockerfile.shark3.1.4 +++ /dev/null @@ -1,126 +0,0 @@ -FROM ubuntu:18.04 as shark-provider -MAINTAINER OrfeoToolbox Core Team - -ENV DEBIAN_FRONTEND noninteractive - -# ---------------------------------------------------------------------------- -# First stage : install tools -# (based on https://github.com/Shark-ML/Shark/blob/master/.travis.yml) -# ---------------------------------------------------------------------------- - -RUN apt-get update -y \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - g++ \ - make \ - cmake \ - libboost-date-time-dev \ - libboost-filesystem-dev \ - libboost-graph-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-thread-dev \ - libcurl4-gnutls-dev \ - curl \ - && rm -rf /var/lib/apt/lists/* - -RUN cd \tmp \ - && curl -o shark.tar.gz https://codeload.github.com/Shark-ML/Shark/tar.gz/v3.1.4 \ - && tar xzf shark.tar.gz \ - && cd Shark-3.1.4\ - && mkdir build \ - && cd build \ - && cmake -DBUILD_EXAMPLES:BOOL=OFF \ - -DBUILD_TESTING:BOOL=OFF \ - -DENABLE_HDF5:BOOL=OFF \ - -DBUILD_SHARED_LIBS=ON \ - -DENABLE_CBLAS:BOOL=OFF \ - -DENABLE_OPENMP:BOOL=OFF \ - ../. \ - && make install - -FROM ubuntu:18.04 -MAINTAINER Sebastien Dinot <sebastien.dinot@c-s.fr> - -ENV DEBIAN_FRONTEND noninteractive - -RUN echo "Europe/Paris" > /etc/timezone - -# ---------------------------------------------------------------------------- -# First stage : install tools (they rarely evolve) -# ---------------------------------------------------------------------------- -RUN apt-get update -y \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - curl \ - make \ - cmake \ - ninja-build \ - g++ \ - gcc \ - clang \ - clang-tidy \ - clang-format \ - ccache \ - git \ - libtool \ - swig \ - xvfb \ - && rm -rf /var/lib/apt/lists/* - -# ---------------------------------------------------------------------------- -# Second stage : dependencies (they evolve more often) -# ---------------------------------------------------------------------------- - -RUN apt-get update -y \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - freeglut3-dev \ - libboost-date-time-dev \ - libboost-filesystem-dev \ - libboost-graph-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-thread-dev \ - libcurl4-gnutls-dev \ - libexpat1-dev \ - libfftw3-dev \ - libgdal-dev \ - libgeotiff-dev \ - libglew-dev \ - libglfw3-dev \ - libgsl-dev \ - libinsighttoolkit4-dev \ - libkml-dev \ - libmuparser-dev \ - libmuparserx-dev \ - libopencv-core-dev \ - libopencv-ml-dev \ - libopenmpi-dev \ - libopenthreads-dev \ - libossim-dev \ - libpng-dev \ - libqt5opengl5-dev \ - libqwt-qt5-dev \ - libsvm-dev \ - libtinyxml-dev \ - qtbase5-dev \ - qttools5-dev \ - default-jdk \ - python-dev \ - python-numpy \ - python-gdal \ - python3-dev \ - python3-numpy \ - python3-gdal \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=shark-provider /usr/local/include/shark/* /usr/include/shark/ -COPY --from=shark-provider /usr/local/lib/libshark* /usr/lib/ -COPY --from=shark-provider /usr/local/bin/SharkVersion /usr/bin/ -COPY --from=shark-provider /usr/local/lib/cmake/ /usr/lib/cmake/ - -ENV PATH /usr/lib/ccache:$PATH -ENV OTB_USE_SHARK ON diff --git a/CI/cdash_handler.py b/CI/cdash_handler.py index 6ac3c9fa44ba1feacd98ade062ca8f48c5426a7a..479bc7ba722dea0395d5332859cb6aad2e8af848 100644 --- a/CI/cdash_handler.py +++ b/CI/cdash_handler.py @@ -36,10 +36,11 @@ trace = False """ Check needed environment parameters """ -def CheckEnvParameters(params): +def CheckEnvParameters(params, verbose=True): for p in params: if not p in os.environ.keys(): - print("Missing environment variable '"+p+"'") + if verbose: + print("Missing environment variable '"+p+"'") return False return True @@ -255,12 +256,13 @@ if __name__ == "__main__": if not CheckEnvParameters(['CI_COMMIT_SHA', 'CI_PROJECT_ID', 'CI_PROJECT_DIR', 'CI_COMMIT_REF_NAME']): sys.exit(1) sha1 = os.environ['CI_COMMIT_SHA'] + refn = os.environ['CI_COMMIT_REF_NAME'] proj = os.environ['CI_PROJECT_ID'] pdir = os.environ['CI_PROJECT_DIR'] - if 'CI_MERGE_REQUEST_REF_PATH' in os.environ.keys(): - refn = os.environ['CI_MERGE_REQUEST_REF_PATH'] - else: - refn = os.environ['CI_COMMIT_REF_NAME'] + if CheckEnvParameters(['CI_MERGE_REQUEST_REF_PATH', 'CI_MERGE_REQUEST_PROJECT_ID'], verbose=False): + targetProj = os.environ['CI_MERGE_REQUEST_PROJECT_ID'] + if proj == targetProj: + refn = os.environ['CI_MERGE_REQUEST_REF_PATH'] if CheckEnvParameters(['K8S_SECRET_API_TOKEN']): token = os.environ['K8S_SECRET_API_TOKEN'] else: @@ -288,7 +290,8 @@ if __name__ == "__main__": 'target_url' : cdash_url , 'description' : error , 'ref' : refn }) gitlab_request = urllib.request.Request(gitlab_url) gitlab_request.add_header('PRIVATE-TOKEN' , token ) - res = urllib.request.urlopen(gitlab_request, data=params.encode('ascii')) if trace: print ("gitlab_request.url: " + gitlab_request.full_url) + res = urllib.request.urlopen(gitlab_request, data=params.encode('ascii')) + if trace: print ("gitlab_request.text: " + res.read().decode()) diff --git a/CI/deploy.sh b/CI/deploy.sh index d3b0385f05c70847526854123d27c4640956042c..e3621361d210e7d5a1f2e3081ed981768db5025d 100755 --- a/CI/deploy.sh +++ b/CI/deploy.sh @@ -37,27 +37,17 @@ else # On release fi # Push package -ls -all build_packages/ echo "Renaming binary packages" -# find build_packages/. -name "*.run" \ -# -exec sh -c 'mv "$1" "${1%.run}${pack_suffix}.run"' _ {} \; -for name in $(find build_packages/. -name "OTB-*.*") - do +for name in $(find . -regex "./OTB-.*\(run\|zip\)"); do len=(${#name}) mv "$name" "${name:0:$len-4}${pack_suffix}${name:$len-4}" done -# TO REMOVE -########### -ls -all build_packages/ -########### echo "Pushing binary packages" -scp build_packages/OTB-*.{run,zip} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/. +scp OTB-*.{run,zip} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/. # Push doc echo "Pushing documentation" -scp build/{CookBook-*-html.tar.gz,\ -/Documentation/{Cookbook/latex/CookBook-*.pdf,Doxygen/OTB-Doxygen-*.tar.bz2}} \ -otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/. +scp {CookBook-*-html.tar.gz,CookBook-*.pdf,OTB-Doxygen-*.tar.bz2} otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/. # Create zip, tar.gz and tar.xy source echo "Creating source tarball and zip" @@ -75,4 +65,4 @@ echo "Pushing new sources" scp OTB-sources-$CI_COMMIT_SHORT_SHA.* \ otbpush@otb5-vm2.orfeo-toolbox.org:${jobs_directory}/ - \ No newline at end of file + diff --git a/CMake/FindNumpy.cmake b/CMake/FindNumpy.cmake index 9022fb0d43d0b8f2389f65600f78eaa43bef985c..f308db88b98cd566e12637bde8c9f1051fa56f65 100644 --- a/CMake/FindNumpy.cmake +++ b/CMake/FindNumpy.cmake @@ -24,10 +24,10 @@ # NUMPY_FOUND - True if Numpy headers are found. # NUMPY_INCLUDE_DIR - where to find numpy/arrayobject.h, etc. -EXEC_PROGRAM ("${PYTHON_EXECUTABLE}" - ARGS "${CMAKE_SOURCE_DIR}/CMake/otbTestNumpy.py" +execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c "import sys, numpy; sys.stdout.write(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIR - RETURN_VALUE NUMPY_NOT_FOUND) + RESULT_VARIABLE NUMPY_NOT_FOUND) if( NUMPY_INCLUDE_DIR MATCHES "Traceback" ) # Did not successfully include numpy diff --git a/CMake/OTBStandaloneModuleMacros.cmake b/CMake/OTBStandaloneModuleMacros.cmake index e877a15ceb405951e27bddf2e55f914b5ad2d980..5771498ab5f0b4040fa02a1a0d40d82532514c8b 100644 --- a/CMake/OTBStandaloneModuleMacros.cmake +++ b/CMake/OTBStandaloneModuleMacros.cmake @@ -23,6 +23,8 @@ # OTB before including OTBModuleMacros. This is the preferred way to build an # OTB module outside of the OTB source tree. +include(GenerateExportHeaderCustom) + macro(otb_module_test) include(../otb-module.cmake) # Load module meta-data set(${otb-module-test}_LIBRARIES "") diff --git a/CMake/UseSWIGLocal.cmake b/CMake/UseSWIGLocal.cmake deleted file mode 100644 index 3f7b7984b6a30472e7412e7aaba2321d9ff66358..0000000000000000000000000000000000000000 --- a/CMake/UseSWIGLocal.cmake +++ /dev/null @@ -1,264 +0,0 @@ -# - SWIG module for CMake -# Defines the following macros: -# SWIG_ADD_MODULE(name language [ files ]) -# - Define swig module with given name and specified language -# SWIG_LINK_LIBRARIES(name [ libraries ]) -# - Link libraries to swig module -# All other macros are for internal use only. -# To get the actual name of the swig module, -# use: ${SWIG_MODULE_${name}_REAL_NAME}. -# Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify -# special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add -# special flags to all swig calls. -# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify -# where to write all the swig generated module (swig -outdir option) -# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used -# to specify extra dependencies for the generated modules. -# If the source file generated by swig need some special flag you can use -# set_source_files_properties( ${swig_generated_file_fullname} -# PROPERTIES COMPILE_FLAGS "-bla") - - -#============================================================================= -# Copyright 2004-2009 Kitware, Inc. -# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.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 License for more information. -#============================================================================= -# (To distributed this file outside of CMake, substitute the full -# License text for the above reference.) - -set(SWIG_CXX_EXTENSION "cxx") -set(SWIG_EXTRA_LIBRARIES "") - -set(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") - -# -# For given swig module initialize variables associated with it -# -macro(SWIG_MODULE_INITIALIZE name language) - string(TOUPPER "${language}" swig_uppercase_language) - string(TOLOWER "${language}" swig_lowercase_language) - set(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}") - set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}") - - if("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xUNKNOWNx$") - message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found") - endif() - - set(SWIG_MODULE_${name}_REAL_NAME "${name}") - if("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$") - # when swig is used without the -interface it will produce in the module.py - # a 'import _modulename' statement, which implies having a corresponding - # _modulename.so (*NIX), _modulename.pyd (Win32). - set(SWIG_MODULE_${name}_REAL_NAME "_${name}") - endif() - if("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xRUBYx$") - string(TOLOWER "${name}" ruby_module_name) - set(SWIG_MODULE_${name}_REAL_NAME "${ruby_module_name}") - endif() - if("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPERLx$") - set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow") - endif() -endmacro() - -# -# For a given language, input file, and output file, determine extra files that -# will be generated. This is internal swig macro. -# - -macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) - get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename - ${infile} SWIG_MODULE_NAME) - if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") - get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) - endif() - foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) - set(${outfiles} ${${outfiles}} - "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") - endforeach() -endmacro() - -# -# Take swig (*.i) file and add proper custom commands for it -# -macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) - set(swig_full_infile ${infile}) - get_filename_component(swig_source_file_path "${infile}" PATH) - get_filename_component(swig_source_file_name_we "${infile}" NAME_WE) - get_source_file_property(swig_source_file_generated ${infile} GENERATED) - get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) - get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) - if("${swig_source_file_flags}" STREQUAL "NOTFOUND") - set(swig_source_file_flags "") - endif() - set(swig_source_file_fullname "${infile}") - if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}") - string(REGEX REPLACE - "^${CMAKE_CURRENT_SOURCE_DIR}" "" - swig_source_file_relative_path - "${swig_source_file_path}") - else() - if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_BINARY_DIR}") - string(REGEX REPLACE - "^${CMAKE_CURRENT_BINARY_DIR}" "" - swig_source_file_relative_path - "${swig_source_file_path}") - set(swig_source_file_generated 1) - else() - set(swig_source_file_relative_path "${swig_source_file_path}") - if(swig_source_file_generated) - set(swig_source_file_fullname "${CMAKE_CURRENT_BINARY_DIR}/${infile}") - else() - set(swig_source_file_fullname "${CMAKE_CURRENT_SOURCE_DIR}/${infile}") - endif() - endif() - endif() - - set(swig_generated_file_fullname - "${CMAKE_CURRENT_BINARY_DIR}") - # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir - if(CMAKE_SWIG_OUTDIR) - set(swig_outdir ${CMAKE_SWIG_OUTDIR}) - # it may not exist, so create it: - file(MAKE_DIRECTORY ${CMAKE_SWIG_OUTDIR}) - else() - set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) - endif() - # cleanup swig_extra_generated_files content for multi-langage wrapping support - set(swig_extra_generated_files) - SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE} - swig_extra_generated_files - "${swig_outdir}" - "${infile}") - set(swig_generated_file_fullname - "${swig_generated_file_fullname}/${swig_source_file_name_we}") - # add the language into the name of the file (i.e. TCL_wrap) - # this allows for the same .i file to be wrapped into different languages - set(swig_generated_file_fullname - "${swig_generated_file_fullname}${SWIG_MODULE_${name}_LANGUAGE}_wrap") - - if(swig_source_file_cplusplus) - set(swig_generated_file_fullname - "${swig_generated_file_fullname}.${SWIG_CXX_EXTENSION}") - else() - set(swig_generated_file_fullname - "${swig_generated_file_fullname}.c") - endif() - - #message("Full path to source file: ${swig_source_file_fullname}") - #message("Full path to the output file: ${swig_generated_file_fullname}") - get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES) - set(swig_include_dirs) - foreach(it ${cmake_include_directories}) - set(swig_include_dirs ${swig_include_dirs} "-I${it}") - endforeach() - - set(swig_special_flags) - # default is c, so add c++ flag if it is c++ - if(swig_source_file_cplusplus) - set(swig_special_flags ${swig_special_flags} "-c++") - endif() - set(swig_extra_flags) - if(SWIG_MODULE_${name}_EXTRA_FLAGS) - set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) - endif() - add_custom_command( - OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files} - COMMAND "${SWIG_EXECUTABLE}" - ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" - ${swig_source_file_flags} - ${CMAKE_SWIG_FLAGS} - -outdir ${swig_outdir} - ${swig_special_flags} - ${swig_extra_flags} - ${swig_include_dirs} - -o "${swig_generated_file_fullname}" - "${swig_source_file_fullname}" - MAIN_DEPENDENCY "${swig_source_file_fullname}" - DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS} - COMMENT "Swig source to generate ${SWIG_MODULE_${name}_LANGUAGE} wrapping") - set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files} - PROPERTIES GENERATED 1) - set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files}) -endmacro() - -# -# Create Swig module -# -macro(SWIG_ADD_MODULE name language) - SWIG_MODULE_INITIALIZE(${name} ${language}) - set(swig_dot_i_sources) - set(swig_other_sources) - foreach(it ${ARGN}) - if(${it} MATCHES ".*\\.i$") - set(swig_dot_i_sources ${swig_dot_i_sources} "${it}") - else() - set(swig_other_sources ${swig_other_sources} "${it}") - endif() - endforeach() - - set(swig_generated_sources) - foreach(it ${swig_dot_i_sources}) - SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it}) - set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}") - endforeach() - get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}") - add_library(${SWIG_MODULE_${name}_REAL_NAME} - MODULE - ${swig_generated_sources} - ${swig_other_sources}) - string(TOLOWER "${language}" swig_lowercase_language) - if("${swig_lowercase_language}" STREQUAL "java") - if(APPLE) - # In java you want: - # System.loadLibrary("LIBRARY"); - # then JNI will look for a library whose name is platform dependent, namely - # MacOS : libLIBRARY.jnilib - # Windows: LIBRARY.dll - # Linux : libLIBRARY.so - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") - endif() - endif() - if("${swig_lowercase_language}" STREQUAL "python") - # this is only needed for the python case where a _modulename.so is generated - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") - # Python extension modules on Windows must have the extension ".pyd" - # instead of ".dll" as of Python 2.5. Older python versions do support - # this suffix. - # http://docs.python.org/whatsnew/ports.html#SECTION0001510000000000000000 - # <quote> - # Windows: .dll is no longer supported as a filename extension for extension modules. - # .pyd is now the only filename extension that will be searched for. - # </quote> - if(WIN32 AND NOT CYGWIN) - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd") - endif() - endif() - if("${swig_lowercase_language}" STREQUAL "ruby") - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") - if(APPLE) - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".bundle") - set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES COMPILE_FLAGS "-bundle") - endif() - endif() -endmacro() - -# -# Like TARGET_LINK_LIBRARIES but for swig modules -# -macro(SWIG_LINK_LIBRARIES name) - if(SWIG_MODULE_${name}_REAL_NAME) - target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN}) - else() - message(SEND_ERROR "Cannot find Swig library \"${name}\".") - endif() -endmacro() - diff --git a/CMake/otbTestNumpy.py b/CMake/otbTestNumpy.py deleted file mode 100644 index 767bbbab113c4106abb0665492a43545bb1c7c8b..0000000000000000000000000000000000000000 --- a/CMake/otbTestNumpy.py +++ /dev/null @@ -1,2 +0,0 @@ -import numpy -print(numpy.get_include()) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2f57de38427ab52b54e3ebf48a777d332253954..df298c16d3902a6f2ff8a6a73fe5b7c6a418ba4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,8 @@ cmake_minimum_required(VERSION 3.10.2) foreach(p CMP0072 # CMake 3.11 + CMP0078 # CMake 3.13 + CMP0086 # CMake 3.14 ) if(POLICY ${p}) cmake_policy(SET ${p} NEW) @@ -105,7 +107,7 @@ set ( Python_ADDITIONAL_VERSIONS "3;2" ) set ( PythonInterp_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) set ( PythonLibs_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) find_package( PythonInterp ) -if ( OTB_WRAP_PYTHON AND ( ${PYTHON_VERSION_MAJOR} EQUAL 2 ) ) +if ( OTB_WRAP_PYTHON AND ( "x${PYTHON_VERSION_MAJOR}" STREQUAL "x2" ) ) message (WARNING "Python3 not found. There is no longer support of \ wrapping in python2 in OTB, but it can still be used.") endif() @@ -399,6 +401,8 @@ install(FILES ${OTB_BINARY_DIR}/CMakeFiles/OTBConfig.cmake CMake/OTBStandaloneModuleMacros.cmake CMake/OTBModuleExternal.cmake CMake/UseOTB.cmake + CMake/GenerateExportHeaderCustom.cmake + CMake/exportheader.cmake.in DESTINATION ${OTB_INSTALL_PACKAGE_DIR} COMPONENT Development) get_property(OTBTargets_MODULES GLOBAL PROPERTY OTBTargets_MODULES) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67732a9168fd3a2bc4601113c7118284bb96adff..0ab1c1c290979cb79a6b393faa0f48f9b913eef6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,27 +107,21 @@ OTB team. ### Using the CI platform -The CI pipelines are triggered automatically when pushing commits. If you push -to a fork, you will need a few settings to trigger properly the CI pipelines: - -* You must add Runners for your fork: the best way is to ask access to the - runners from main repository when doing your first MR. During code review, - someone from CI admins will assign the runners to your fork. -* [Optional] You can create a - [personal access token](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) - (choose the scope API) and add it as a secret variable: on the project page of - your fork, go to Settings -> CI/CD -> Variables, add the variable `K8S_SECRET_API_TOKEN` - with your token as value (you should mask this variable for security reasons). +There isn't much to do in order to use the CI platform. The CI pipelines are +triggered automatically when pushing commits. However, if you push to a fork, +you will first need an access to the Runners from main repository. You +can request it when doing your first MergeRequest. During code review, someone +from CI admins will assign the runners to your fork. When your pipeline ends, there are two cases: * if all the jobs succeed, you see a green pipeline, which means no problem was found on your commit. * if one job fails, you see a red pipeline, which means something is broken in - your commit. The pipeline widget on Gitlab will tell you which job failed. You - will also find special jobs "cdash:..." in the stage `external` that provide - a link to the [Dashboard](https://cdash.orfeo-toolbox.org/index.php?project=OTB) - where you can look more in details into compilation errors and failed tests. + your commit. The pipeline widget on Gitlab will tell you which job failed, so + you can check the logs. There, you may also find links to + [CDash](https://cdash.orfeo-toolbox.org/index.php?project=OTB) submissions + where compilation errors and failed test can be investigated more easily. More details on the CI platform can be found [here](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/wikis/OTB-Continuous-Integration-platform). diff --git a/Data/Baseline/OTB-Applications/Files/apTvClDTVectorRegression.sqlite b/Data/Baseline/OTB-Applications/Files/apTvClDTVectorRegression.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..e4eae4a9372461bd14379078bb31d3d47602c5b5 --- /dev/null +++ b/Data/Baseline/OTB-Applications/Files/apTvClDTVectorRegression.sqlite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:afff9c803aa384fecd0a9b068be71de7c92538cf22767e160478fbcce3b369d5 +size 118784 diff --git a/Data/Baseline/OTB/Images/apTvHyHyperspectralUnmixing_NCLS.tif b/Data/Baseline/OTB/Images/apTvHyHyperspectralUnmixing_NCLS.tif deleted file mode 100644 index 6d556a35f322dadf76eb3eb3a6ce864707fea9d9..0000000000000000000000000000000000000000 --- a/Data/Baseline/OTB/Images/apTvHyHyperspectralUnmixing_NCLS.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:132f26d65cfc0cc72b6a465a915fd22c2852f30b08151c1ade9994e27e665745 -size 13008 diff --git a/Data/Baseline/OTB/Images/hyTvNCLSImageFilterTest.tif b/Data/Baseline/OTB/Images/hyTvNCLSImageFilterTest.tif deleted file mode 100644 index a137c07799294ab1909c86fc4ce909e43d4cb315..0000000000000000000000000000000000000000 --- a/Data/Baseline/OTB/Images/hyTvNCLSImageFilterTest.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2df167f402a5e001ddfd2821a2859483bf8f15f3b4789a650a992b56ca7655e2 -size 13025 diff --git a/Data/Input/Classification/apTvClDTVectorRegression.dt b/Data/Input/Classification/apTvClDTVectorRegression.dt new file mode 100644 index 0000000000000000000000000000000000000000..e19000fd7910ad5de62fc0a1d4995240f96d3607 --- /dev/null +++ b/Data/Input/Classification/apTvClDTVectorRegression.dt @@ -0,0 +1,117 @@ +%YAML:1.0 +my_tree: !!opencv-ml-tree + is_classifier: 0 + var_all: 4 + var_count: 4 + ord_var_count: 4 + cat_var_count: 0 + training_params: + use_surrogates: 1 + regression_accuracy: 9.9999997764825821e-03 + max_depth: 25 + min_sample_count: 10 + cross_validation_folds: 0 + var_type: [ 0, 0, 0, 0 ] + best_tree_idx: -1 + nodes: + - + depth: 0 + sample_count: 1185 + value: 2.1434599156118144e+00 + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 1.3156118143459917e+03 + tree_risk: 0. + tree_error: 0. + splits: + - { var:3, quality:6.5841166992187500e+03, + le:2.3381726074218750e+02 } + - + depth: 1 + sample_count: 593 + value: 1.1635750421585160e+00 + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 8.9133220910623891e+01 + tree_risk: 0. + tree_error: 0. + splits: + - { var:3, quality:8.8817205810546875e+02, + le:1.6510346984863281e+02 } + - + depth: 2 + sample_count: 500 + value: 1. + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 0. + tree_risk: 0. + tree_error: 0. + - + depth: 2 + sample_count: 93 + value: 2.0430107526881720e+00 + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 3.8279569892472978e+00 + tree_risk: 0. + tree_error: 0. + splits: + - { var:0, quality:392., le:2.1638174438476562e+02 } + - + depth: 3 + sample_count: 4 + value: 3. + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 0. + tree_risk: 0. + tree_error: 0. + - + depth: 3 + sample_count: 89 + value: 2. + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 0. + tree_risk: 0. + tree_error: 0. + - + depth: 1 + sample_count: 592 + value: 3.1250000000000000e+00 + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 8.6750000000000000e+01 + tree_risk: 0. + tree_error: 0. + splits: + - { var:1, quality:5.8572387695312500e+03, + le:3.6126699829101562e+02 } + - + depth: 2 + sample_count: 507 + value: 2.9783037475345169e+00 + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 1.0761341222879309e+01 + tree_risk: 0. + tree_error: 0. + - + depth: 2 + sample_count: 85 + value: 4. + Tn: 0 + complexity: 0 + alpha: 0. + node_risk: 0. + tree_risk: 0. + tree_error: 0. diff --git a/Data/Input/apTvUtExportBandMathX.txt b/Data/Input/apTvUtExportBandMathX.txt index baa6a64fc44bd2084a44a5b4ff0044f7b0e3fa21..774aca47ddf40b5931ef58ec124c5394bbb4a511 100644 --- a/Data/Input/apTvUtExportBandMathX.txt +++ b/Data/Input/apTvUtExportBandMathX.txt @@ -1,2 +1,3 @@ -#E cos(im1b1)+im2b1*im3b1-im3b2+ndvi(im3b3,im3b4) +#F val 1 +#E im1b1 + 2*val + im2b1 diff --git a/Documentation/Cookbook/rst/QGISInterface.rst b/Documentation/Cookbook/rst/QGISInterface.rst index eb075ef35dd151285236881f80bced5a7e9d3c7e..df569c32bee87dac7c38da88ca21bdf807146bd2 100644 --- a/Documentation/Cookbook/rst/QGISInterface.rst +++ b/Documentation/Cookbook/rst/QGISInterface.rst @@ -1,36 +1,14 @@ QGIS interface ============== -The QGIS-OTB plugin (requires QGIS > 3.0) +The QGIS-OTB plugin (requires QGIS > 3.2) ----------------------------------------- -With QGIS 3.0.2 or later, you will need to manually install the plugin. -Clone qgis-otb-plugin repository and set ``QGIS_PLUGINPATH``: +With QGIS < 3.8 you will need to manually install the plugin. +You can follow the instruction here: https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin#otb-provider-for-qgis-processing -For Linux/Unix/MacOSX -^^^^^^^^^^^^^^^^^^^^^ -:: - - mkdir $HOME/projects; cd $HOME/projects - git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin - export QGIS_PLUGINPATH=$HOME/projects/qgis-otb-plugin - -For Windows -^^^^^^^^^^^ - -Clone qgis-otb-plugin repository to ``C:\qgis-plugins\qgis-otb-plugin`` - -:: - - git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/qgis-otb-plugin - -Then set the ``QGIS_PLUGINPATH`` variable: - -* System properties (``Windows Key + R -> sysdm.cpl`` ) -* Select Advanced Tab -> Environment variables. -* Under "user variables for " -* Add or Edit variable ``QGIS_PLUGINPATH`` and set value to ``C:\qgis-plugins\qgis-otb-plugin`` +With QGIS > 3.8, the plugin is in the QGIS core. So you just need install OTB and set the plugin up. Download and Install OTB ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,27 +37,6 @@ You can see OTB under "Providers": * Set OTB application folder. This is location of your OTB applications. ``<OTB_FOLDER>/lib/otb/applications`` * Click "ok" to save settings and close dialog. If settings are correct, you will have OTB algorithms loaded in Processing toolbox -Using the processing toolbox (for QGIS < 3.0) ---------------------------------------------- - -In older QGIS version (3.0 or before), OTB applications are available from QGIS. -Use them from the processing toolbox, which is accessible under `Processing --> ToolBox`. Switch to “advanced interface†in the bottom of the -application widget and OTB applications will be there. - -.. figure:: Art/QtImages/qgis-otb.png - -Using a custom OTB -^^^^^^^^^^^^^^^^^^ - -If QGIS cannot find OTB, the “applications folder†and “binaries folder†-can be set from the settings found under Processing :math:`\rightarrow` -Settings :math:`\rightarrow` “service providerâ€. - -.. figure:: Art/QtImages/qgis-otb-settings.png - -On some versions of QGIS, if an existing OTB installation is found, the -textfield settings will not be shown. To use a custom OTB instead of the -existing one, you will need to replace the otbcli, otbgui and library -files in QGIS installation directly. - +Troubleshoot +------------ +As of QGIS 3.8 the otb plugin is in the core. It might get messy if you have a previously installed plugin. Try to remove the old plugin before launching QGIS. diff --git a/Modules/Applications/AppClassification/app/CMakeLists.txt b/Modules/Applications/AppClassification/app/CMakeLists.txt index 9c9404e94b79763e4105eed288eb5bdf7644c113..c981d9ec5bcf06530dae674b5aefa38c109e411a 100644 --- a/Modules/Applications/AppClassification/app/CMakeLists.txt +++ b/Modules/Applications/AppClassification/app/CMakeLists.txt @@ -115,6 +115,11 @@ otb_create_application( SOURCES otbVectorClassifier.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) +otb_create_application( + NAME VectorRegression + SOURCES otbVectorRegression.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + otb_create_application( NAME SampleAugmentation SOURCES otbSampleAugmentation.cxx diff --git a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx index 756ea62890030193ea0b2291b78a44b078a7d587..18b9afc2459e9436d06dc6011682e47f42badc8e 100644 --- a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx @@ -37,11 +37,6 @@ namespace otb { namespace Wrapper { -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) - { - return !std::isalnum(c); - } class ComputeConfusionMatrix : public Application { @@ -198,7 +193,7 @@ private: { std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef(); key = item; - std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum); + std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);}); std::transform(key.begin(), end, key.begin(), tolower); OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index c4ca1ab8346a9c96db6da1370840741934efcc85..db4aca185f9c14cc396465d47bd6e5867e6fa851 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -32,12 +32,6 @@ namespace otb namespace Wrapper { -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) - { - return !std::isalnum(c); - } - class PolygonClassStatistics : public Application { public: @@ -141,7 +135,7 @@ private: { std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef(); key = item; - std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum); + std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);}); std::transform(key.begin(), end, key.begin(), tolower); OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index b94130d3f57a68067d035af1de464e55230d397d..473a82b3b0b6750f18a7e9ed2eafda3e6a94347c 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -27,12 +27,6 @@ namespace otb { namespace Wrapper { -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) - { - return !std::isalnum(c); - } - class SampleExtraction : public Application { public: @@ -139,7 +133,7 @@ private: { std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef(); key = item; - std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum); + std::string::iterator end = std::remove_if(key.begin(),key.end(), [](char c){return !std::isalnum(c);}); std::transform(key.begin(), end, key.begin(), tolower); OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index c2bc93f144a79313db493355e1b39e024905d487..d4770c4d1dd5bd32dfc8294be9be8c47810a4603 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -32,13 +32,6 @@ namespace otb { namespace Wrapper { - -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) - { - return !std::isalnum(c); - } - class SampleSelection : public Application { public: @@ -243,7 +236,7 @@ private: { std::string key, item = feature.ogr().GetFieldDefnRef(iField)->GetNameRef(); key = item; - std::string::iterator end = std::remove_if(key.begin(),key.end(),IsNotAlphaNum); + std::string::iterator end = std::remove_if(key.begin(), key.end(), [](char c){return !std::isalnum(c);}); std::transform(key.begin(), end, key.begin(), tolower); OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 1f0401aeec3586afc10d2964d60c26fc665ef5df..4308f19ac60d97e949d45a9a22353eaba5e8b132 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -18,419 +18,106 @@ * limitations under the License. */ -#include "otbWrapperApplication.h" -#include "otbWrapperApplicationFactory.h" - -#include "otbOGRDataSourceWrapper.h" -#include "otbOGRFeatureWrapper.h" - -#include "itkVariableLengthVector.h" -#include "otbStatisticsXMLFileReader.h" - -#include "itkListSample.h" -#include "otbShiftScaleSampleListFilter.h" - -#include "otbMachineLearningModelFactory.h" - -#include "otbMachineLearningModel.h" - -#include <time.h> +#include "otbVectorPrediction.h" namespace otb { namespace Wrapper { -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) - { - return !std::isalnum(c); - } +using VectorClassifier = VectorPrediction<false>; -class VectorClassifier : public Application +template <> +void VectorClassifier::DoInitSpecialization() { -public: - /** Standard class typedefs. */ - typedef VectorClassifier Self; - typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macro */ - itkNewMacro(Self); - - itkTypeMacro(Self, Application) - - /** Filters typedef */ - typedef float ValueType; - typedef unsigned int LabelType; - typedef itk::FixedArray<LabelType,1> LabelSampleType; - typedef itk::Statistics::ListSample<LabelSampleType> LabelListSampleType; - - typedef otb::MachineLearningModel<ValueType,LabelType> MachineLearningModelType; - typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType; - typedef MachineLearningModelType::Pointer ModelPointerType; - typedef MachineLearningModelType::ConfidenceListSampleType ConfidenceListSampleType; - - /** Statistics Filters typedef */ - typedef itk::VariableLengthVector<ValueType> MeasurementType; - typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; - - typedef itk::VariableLengthVector<ValueType> InputSampleType; - typedef itk::Statistics::ListSample<InputSampleType> ListSampleType; - typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; - - ~VectorClassifier() override - { - MachineLearningModelFactoryType::CleanFactories(); - } - -private: - void DoInit() override - { - SetName("VectorClassifier"); - SetDescription("Performs a classification of the input vector data according to a model file."); + SetName("VectorClassifier"); + SetDescription("Performs a classification of the input vector data according to a model file."); - SetDocAuthors("OTB-Team"); - SetDocLongDescription("This application performs a vector data classification " + SetDocAuthors("OTB-Team"); + SetDocLongDescription( + "This application performs a vector data classification " "based on a model file produced by the TrainVectorClassifier application." "Features of the vector data output will contain the class labels decided by the classifier " "(maximal class label = 65535). \n" "There are two modes: \n" - "1) Update mode: add of the 'cfield' field containing the predicted class in the input file. \n" - "2) Write mode: copies the existing fields of the input file to the output file " - " and add the 'cfield' field containing the predicted class. \n" + "1) Update mode: add of the 'cfield' field containing the predicted class in the input file. \n" + "2) Write mode: copies the existing fields of the input file to the output file " + " and add the 'cfield' field containing the predicted class. \n" "If you have declared the output file, the write mode applies. " "Otherwise, the input file update mode will be applied."); - SetDocLimitations("Shapefiles are supported, but the SQLite format is only supported in update mode."); - SetDocSeeAlso("TrainVectorClassifier"); - AddDocTag(Tags::Learning); - - AddParameter(ParameterType_InputVectorData, "in", "Name of the input vector data"); - SetParameterDescription("in","The input vector data file to classify."); - - AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); - SetParameterDescription("instat", "A XML file containing mean and standard deviation to center" - "and reduce samples before classification, produced by ComputeImagesStatistics application."); - MandatoryOff("instat"); - - AddParameter(ParameterType_InputFilename, "model", "Model file"); - SetParameterDescription("model", "Model file produced by TrainVectorClassifier application."); - - AddParameter(ParameterType_String,"cfield","Field class"); - SetParameterDescription("cfield","Field containing the predicted class." - "Only geometries with this field available will be taken into account.\n" - "The field is added either in the input file (if 'out' off) or in the output file.\n" - "Caution, the 'cfield' must not exist in the input file if you are updating the file."); - SetParameterString("cfield","predicted"); - - AddParameter(ParameterType_ListView, "feat", "Field names to be calculated"); - SetParameterDescription("feat","List of field names in the input vector data used as features for training. " - "Put the same field names as the TrainVectorClassifier application."); - - AddParameter(ParameterType_Bool, "confmap", "Confidence map"); - SetParameterDescription( "confmap", "Confidence map of the produced classification. The confidence index depends on the model: \n\n" - "* LibSVM: difference between the two highest probabilities (needs a model with probability estimates, so that classes probabilities can be computed for each sample)\n" - "* Boost: sum of votes\n" - "* DecisionTree: (not supported)\n" - "* KNearestNeighbors: number of neighbors with the same label\n" - "* NeuralNetwork: difference between the two highest responses\n" - "* NormalBayes: (not supported)\n" - "* RandomForest: Confidence (proportion of votes for the majority class). Margin (normalized difference of the votes of the 2 majority classes) is not available for now.\n" - "* SVM: distance to margin (only works for 2-class models)\n"); - - AddParameter(ParameterType_OutputFilename, "out", "Output vector data file containing class labels"); - SetParameterDescription("out","Output vector data file storing sample values (OGR format)." - "If not given, the input vector data file is updated."); - MandatoryOff("out"); - - // Doc example parameter settings - SetDocExampleParameterValue("in", "vectorData.shp"); - SetDocExampleParameterValue("instat", "meanVar.xml"); - SetDocExampleParameterValue("model", "svmModel.svm"); - SetDocExampleParameterValue("out", "vectorDataLabeledVector.shp"); - SetDocExampleParameterValue("feat", "perimeter area width"); - SetDocExampleParameterValue("cfield", "predicted"); - - SetOfficialDocLink(); - } - - void DoUpdateParameters() override - { - if ( HasValue("in") ) - { - std::string shapefile = GetParameterString("in"); - - otb::ogr::DataSource::Pointer ogrDS; - - OGRSpatialReference oSRS(""); - std::vector<std::string> options; - - ogrDS = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = ogrDS->GetLayer(0); - OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - - ClearChoices("feat"); - - for(int iField=0; iField< layerDefn.GetFieldCount(); iField++) - { - std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); - std::string key(item); - key.erase( std::remove_if(key.begin(),key.end(),IsNotAlphaNum), key.end()); - std::transform(key.begin(), key.end(), key.begin(), tolower); + SetDocLimitations("Shapefiles are supported, but the SQLite format is only supported in update mode."); + SetDocSeeAlso("TrainVectorClassifier"); + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputFilename, "in", "Name of the input vector data"); + SetParameterDescription("in", "The input vector data file to classify."); + + AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); + SetParameterDescription("instat", + "A XML file containing mean and standard deviation to center" + "and reduce samples before classification, produced by ComputeImagesStatistics application."); + MandatoryOff("instat"); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "Model file produced by TrainVectorClassifier application."); + + AddParameter(ParameterType_String, "cfield", "Output field"); + SetParameterDescription("cfield", + "Field containing the predicted class." + "Only geometries with this field available will be taken into account.\n" + "The field is added either in the input file (if 'out' off) or in the output file.\n" + "Caution, the 'cfield' must not exist in the input file if you are updating the file."); + SetParameterString("cfield", "predicted"); + + AddParameter(ParameterType_ListView, "feat", "Field names to be calculated"); + SetParameterDescription("feat", + "List of field names in the input vector data used as features for training. " + "Put the same field names as the TrainVectorClassifier application."); + + AddParameter(ParameterType_Bool, "confmap", "Confidence map"); + SetParameterDescription("confmap", + "Confidence map of the produced classification. The confidence index depends on the model: \n\n" + "* LibSVM: difference between the two highest probabilities (needs a model with probability estimates, so that classes probabilities " + "can be computed for each sample)\n" + "* Boost: sum of votes\n" + "* DecisionTree: (not supported)\n" + "* KNearestNeighbors: number of neighbors with the same label\n" + "* NeuralNetwork: difference between the two highest responses\n" + "* NormalBayes: (not supported)\n" + "* RandomForest: Confidence (proportion of votes for the majority class). Margin (normalized difference of the votes of the 2 " + "majority classes) is not available for now.\n" + "* SVM: distance to margin (only works for 2-class models)\n"); + + AddParameter(ParameterType_OutputFilename, "out", "Output vector data file"); + MandatoryOff("out"); + SetParameterDescription("out", + "Output vector data file storing sample values (OGR format)." + "If not given, the input vector data file is updated."); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "vectorData.shp"); + SetDocExampleParameterValue("instat", "meanVar.xml"); + SetDocExampleParameterValue("model", "svmModel.svm"); + SetDocExampleParameterValue("out", "vectorDataLabeledVector.shp"); + SetDocExampleParameterValue("feat", "perimeter area width"); + SetDocExampleParameterValue("cfield", "predicted"); + + SetOfficialDocLink(); +} - OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - if(fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal) - { - std::string tmpKey="feat."+key; - AddChoice(tmpKey,item); - } - } - } - } +template <> +bool VectorClassifier::shouldComputeConfidenceMap() const +{ + bool computeConfidenceMap(GetParameterInt("confmap") && m_Model->HasConfidenceIndex()); - void DoExecute() override + if (!m_Model->HasConfidenceIndex() && GetParameterInt("confmap")) { - clock_t tic = clock(); - - std::string shapefile = GetParameterString("in"); - - otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); - otb::ogr::Layer layer = source->GetLayer(0); - - ListSampleType::Pointer input = ListSampleType::New(); - - const int nbFeatures = GetSelectedItems("feat").size(); - input->SetMeasurementVectorSize(nbFeatures); - - otb::ogr::Layer::const_iterator it = layer.cbegin(); - otb::ogr::Layer::const_iterator itEnd = layer.cend(); - for( ; it!=itEnd ; ++it) - { - MeasurementType mv; - mv.SetSize(nbFeatures); - for(int idx=0; idx < nbFeatures; ++idx) - { - // Beware that itemIndex differs from ogr layer field index - unsigned int itemIndex = GetSelectedItems("feat")[idx]; - std::string fieldName = GetChoiceNames( "feat" )[itemIndex]; - switch ((*it)[fieldName].GetType()) - { - case OFTInteger: - mv[idx] = static_cast<ValueType>((*it)[fieldName].GetValue<int>()); - break; - case OFTInteger64: - mv[idx] = static_cast<ValueType>((*it)[fieldName].GetValue<int>()); - break; - case OFTReal: - mv[idx] = static_cast<ValueType>((*it)[fieldName].GetValue<double>()); - break; - default: - itkExceptionMacro(<< "incorrect field type: " << (*it)[fieldName].GetType() << "."); - } - - - } - input->PushBack(mv); - } - - // Statistics for shift/scale - MeasurementType meanMeasurementVector; - MeasurementType stddevMeasurementVector; - if (HasValue("instat") && IsParameterEnabled("instat")) - { - StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); - std::string XMLfile = GetParameterString("instat"); - statisticsReader->SetFileName(XMLfile); - meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); - stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); - } - else - { - meanMeasurementVector.SetSize(nbFeatures); - meanMeasurementVector.Fill(0.); - stddevMeasurementVector.SetSize(nbFeatures); - stddevMeasurementVector.Fill(1.); - } - - ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); - trainingShiftScaleFilter->SetInput(input); - trainingShiftScaleFilter->SetShifts(meanMeasurementVector); - trainingShiftScaleFilter->SetScales(stddevMeasurementVector); - trainingShiftScaleFilter->Update(); - otbAppLogINFO("mean used: " << meanMeasurementVector); - otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); - - otbAppLogINFO("Loading model"); - m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), - MachineLearningModelFactoryType::ReadMode); - - if (m_Model.IsNull()) - { - otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); - } - - m_Model->Load(GetParameterString("model")); - otbAppLogINFO("Model loaded"); - - ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput(); - - ConfidenceListSampleType::Pointer quality; - - bool computeConfidenceMap(GetParameterInt("confmap") && m_Model->HasConfidenceIndex() - && !m_Model->GetRegressionMode()); - - if (!m_Model->HasConfidenceIndex() && GetParameterInt("confmap")) - { - otbAppLogWARNING("Confidence map requested but the classifier doesn't support it!"); - } - - LabelListSampleType::Pointer target; - if (computeConfidenceMap) - { - quality = ConfidenceListSampleType::New(); - target = m_Model->PredictBatch(listSample, quality); - } - else - { - target = m_Model->PredictBatch(listSample); - } - - ogr::DataSource::Pointer output; - ogr::DataSource::Pointer buffer = ogr::DataSource::New(); - bool updateMode = false; - if (IsParameterEnabled("out") && HasValue("out")) - { - // Create new OGRDataSource - output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); - otb::ogr::Layer newLayer = output->CreateLayer( - GetParameterString("out"), - const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), - layer.GetGeomType()); - // Copy existing fields - OGRFeatureDefn &inLayerDefn = layer.GetLayerDefn(); - for (int k=0 ; k<inLayerDefn.GetFieldCount() ; k++) - { - OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); - newLayer.CreateField(fieldDefn); - } - } - else - { - // Update mode - updateMode = true; - otbAppLogINFO("Update input vector data."); - // fill temporary buffer for the transfer - otb::ogr::Layer inputLayer = layer; - layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); - // close input data source - source->Clear(); - // Re-open input data source in update mode - output = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Update_LayerUpdate); - } - - otb::ogr::Layer outLayer = output->GetLayer(0); - - OGRErr errStart = outLayer.ogr().StartTransaction(); - if (errStart != OGRERR_NONE) - { - itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); - } - - // Add the field of prediction in the output layer if field not exist - OGRFeatureDefn &layerDefn = layer.GetLayerDefn(); - int idx = layerDefn.GetFieldIndex(GetParameterString("cfield").c_str()); - if (idx >= 0) - { - if (layerDefn.GetFieldDefn(idx)->GetType() != OFTInteger) - itkExceptionMacro("Field name "<< GetParameterString("cfield") << " already exists with a different type!"); - } - else - { - OGRFieldDefn predictedField(GetParameterString("cfield").c_str(), OFTInteger); - ogr::FieldDefn predictedFieldDef(predictedField); - outLayer.CreateField(predictedFieldDef); - } - - // Add confidence field in the output layer - std::string confFieldName("confidence"); - if (computeConfidenceMap) - { - idx = layerDefn.GetFieldIndex(confFieldName.c_str()); - if (idx >= 0) - { - if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) - itkExceptionMacro("Field name "<< confFieldName << " already exists with a different type!"); - } - else - { - OGRFieldDefn confidenceField(confFieldName.c_str(), OFTReal); - confidenceField.SetWidth(confidenceField.GetWidth()); - confidenceField.SetPrecision(confidenceField.GetPrecision()); - ogr::FieldDefn confFieldDefn(confidenceField); - outLayer.CreateField(confFieldDefn); - } - } - - // Fill output layer - unsigned int count=0; - std::string classfieldname = GetParameterString("cfield"); - it = layer.cbegin(); - itEnd = layer.cend(); - for( ; it!=itEnd ; ++it, ++count) - { - ogr::Feature dstFeature(outLayer.GetLayerDefn()); - dstFeature.SetFrom( *it , TRUE); - dstFeature.SetFID(it->GetFID()); - switch (dstFeature[classfieldname].GetType()) - { - case OFTInteger: - dstFeature[classfieldname].SetValue<int>(target->GetMeasurementVector(count)[0]); - break; - case OFTInteger64: - dstFeature[classfieldname].SetValue<int>(target->GetMeasurementVector(count)[0]); - break; - case OFTReal: - dstFeature[classfieldname].SetValue<double>(target->GetMeasurementVector(count)[0]); - break; - case OFTString: - dstFeature[classfieldname].SetValue<std::string>(std::to_string(target->GetMeasurementVector(count)[0])); - break; - default: - itkExceptionMacro(<< "incorrect field type: " << dstFeature[classfieldname].GetType() << "."); - } - if (computeConfidenceMap) - dstFeature[confFieldName].SetValue<double>(quality->GetMeasurementVector(count)[0]); - if (updateMode) - { - outLayer.SetFeature(dstFeature); - } - else - { - outLayer.CreateFeature(dstFeature); - } - } - - if(outLayer.ogr().TestCapability("Transactions")) - { - const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); - if (errCommitX != OGRERR_NONE) - { - itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << outLayer.ogr().GetName() << "."); - } - } - - output->SyncToDisk(); - - clock_t toc = clock(); - otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); - + otbAppLogWARNING("Confidence map requested but the classifier doesn't support it!"); } - ModelPointerType m_Model; -}; - + return computeConfidenceMap; +} } } diff --git a/Modules/Applications/AppClassification/app/otbVectorRegression.cxx b/Modules/Applications/AppClassification/app/otbVectorRegression.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d4e23d4e491a2aa83d21c2f5dde609c2e3eb7d2c --- /dev/null +++ b/Modules/Applications/AppClassification/app/otbVectorRegression.cxx @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2005-2019 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 "otbVectorPrediction.h" + +namespace otb +{ +namespace Wrapper +{ + +using VectorRegression = VectorPrediction<true>; + +template <> +void VectorRegression::DoInitSpecialization() +{ + SetName("VectorRegression"); + SetDescription("Performs regression on the input vector data according to a model file."); + + SetDocAuthors("OTB-Team"); + SetDocLongDescription( + "This application performs a vector data regression " + "based on a model file produced by the TrainVectorRegression application." + "Features of the vector data output will contain the values predicted by the classifier. \n" + "There are two modes: \n" + "1) Update mode: add of the 'cfield' field containing the predicted value in the input file. \n" + "2) Write mode: copies the existing fields of the input file to the output file " + " and add the 'cfield' field containing the predicted value. \n" + "If you have declared the output file, the write mode applies. " + "Otherwise, the input file update mode will be applied."); + + SetDocLimitations("Shapefiles are supported, but the SQLite format is only supported in update mode."); + SetDocSeeAlso("TrainVectorRegression"); + AddDocTag(Tags::Learning); + + AddParameter(ParameterType_InputFilename, "in", "Name of the input vector data"); + SetParameterDescription("in", "The input vector data file to classify."); + + AddParameter(ParameterType_InputFilename, "instat", "Statistics file"); + SetParameterDescription("instat", + "A XML file containing mean and standard deviation to center" + "and reduce samples before classification, produced by ComputeImagesStatistics application."); + MandatoryOff("instat"); + + AddParameter(ParameterType_InputFilename, "model", "Model file"); + SetParameterDescription("model", "Model file produced by TrainVectorRegression application."); + + AddParameter(ParameterType_String, "cfield", "Output field"); + SetParameterDescription("cfield", + "Field containing the predicted value." + "Only geometries with this field available will be taken into account.\n" + "The field is added either in the input file (if 'out' off) or in the output file.\n" + "Caution, the 'cfield' must not exist in the input file if you are updating the file."); + SetParameterString("cfield", "predicted"); + + AddParameter(ParameterType_ListView, "feat", "Field names to be calculated"); + SetParameterDescription("feat", + "List of field names in the input vector data used as features for training. " + "Put the same field names as the TrainVectorRegression application."); + + AddParameter(ParameterType_OutputFilename, "out", "Output vector data file"); + MandatoryOff("out"); + + SetParameterDescription("out", + "Output vector data file storing sample values (OGR format)." + "If not given, the input vector data file is updated."); + MandatoryOff("out"); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "vectorData.shp"); + SetDocExampleParameterValue("instat", "meanVar.xml"); + SetDocExampleParameterValue("model", "rfModel.rf"); + SetDocExampleParameterValue("out", "vectorDataLabeledVector.shp"); + SetDocExampleParameterValue("feat", "perimeter area width"); + SetDocExampleParameterValue("cfield", "predicted"); + + SetOfficialDocLink(); +} + +// Confidence map computation is not supported for regression. +template <> +bool VectorRegression::shouldComputeConfidenceMap() const +{ + return false; +} +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::VectorRegression) diff --git a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.hxx b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.hxx index 0d980c9d7afc0d69223d14cbeafe41defca64190..341cd858252512d8677e59dafd6a7e736d42a2ef 100644 --- a/Modules/Applications/AppClassification/include/otbTrainDecisionTree.hxx +++ b/Modules/Applications/AppClassification/include/otbTrainDecisionTree.hxx @@ -75,17 +75,15 @@ LearningApplicationBase<TInputValue,TOutputValue> "Cluster possible values of a categorical variable into K <= cat clusters to find a " "suboptimal split."); - //CVFolds + + //CVFolds: only exposed for OPENCV 2 because it crashes in OpenCV 3 +#ifndef OTB_OPENCV_3 AddParameter(ParameterType_Int, "classifier.dt.f", "K-fold cross-validations"); -#ifdef OTB_OPENCV_3 - // disable cross validation by default (crash in opencv 3.2) - SetParameterInt("classifier.dt.f",0); -#else SetParameterInt("classifier.dt.f",10); -#endif SetParameterDescription("classifier.dt.f", "If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K " "is equal to cv_folds."); +#endif //Use1seRule AddParameter(ParameterType_Bool, "classifier.dt.r", "Set Use1seRule flag to false"); @@ -118,7 +116,10 @@ LearningApplicationBase<TInputValue,TOutputValue> classifier->SetMinSampleCount(GetParameterInt("classifier.dt.min")); classifier->SetRegressionAccuracy(GetParameterFloat("classifier.dt.ra")); classifier->SetMaxCategories(GetParameterInt("classifier.dt.cat")); + //CVFolds is only exposed for OPENCV 2 because it crashes in OpenCV 3 +#ifndef OTB_OPENCV_3 classifier->SetCVFolds(GetParameterInt("classifier.dt.f")); +#endif if (GetParameterInt("classifier.dt.r")) { classifier->SetUse1seRule(false); diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h index 24b731cbd6b09ef5e81bb45388fddbcd43801ca3..d58b536468e3eb5166e246d424664afdacfda812 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h @@ -43,12 +43,6 @@ namespace otb namespace Wrapper { -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) -{ - return !std::isalnum( c ); -} - template <class TInputValue, class TOutputValue> class TrainVectorBase : public LearningApplicationBase<TInputValue, TOutputValue> { diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx index eaaa8bee3189933a532c3c21abbde7a65dc77e87..ff2947dc7b757432b6230901eb80a945082f9734 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx @@ -124,7 +124,7 @@ TrainVectorBase<TInputValue, TOutputValue> { std::string key, item = feature.ogr().GetFieldDefnRef( iField )->GetNameRef(); key = item; - std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum ); + std::string::iterator end = std::remove_if( key.begin(), key.end(), [](char c){return !std::isalnum(c);} ); std::transform( key.begin(), end, key.begin(), tolower ); OGRFieldType fieldType = feature.ogr().GetFieldDefnRef( iField )->GetType(); diff --git a/Modules/Applications/AppClassification/include/otbVectorPrediction.h b/Modules/Applications/AppClassification/include/otbVectorPrediction.h new file mode 100644 index 0000000000000000000000000000000000000000..65fe591977d3ac690f860a6c3d74dc4fe9ec7b1f --- /dev/null +++ b/Modules/Applications/AppClassification/include/otbVectorPrediction.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2005-2019 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. + */ + +#ifndef otbVectorPrediction_h +#define otbVectorPrediction_h + +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbOGRDataSourceWrapper.h" +#include "otbOGRFeatureWrapper.h" + +#include "itkVariableLengthVector.h" +#include "otbStatisticsXMLFileReader.h" + +#include "itkListSample.h" +#include "otbShiftScaleSampleListFilter.h" + +#include "otbMachineLearningModelFactory.h" + +#include "otbMachineLearningModel.h" + +#include <time.h> + +namespace otb +{ +namespace Wrapper +{ + +template <bool RegressionMode> +class VectorPrediction : public Application +{ +public: + /** Standard class typedefs. */ + using Self = VectorPrediction; + using Superclass = Application; + using Pointer = itk::SmartPointer<Self>; + using ConstPointer = itk::SmartPointer<const Self>; + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(Self, Application) + + /** Filters typedef */ + using ValueType = float; + // Label type is float for regression and unsigned int for classification + using LabelType = typename std::conditional<RegressionMode, float, unsigned int>::type; + + using LabelSampleType = itk::FixedArray<LabelType, 1>; + using LabelListSampleType = itk::Statistics::ListSample<LabelSampleType>; + + using MachineLearningModelType = otb::MachineLearningModel<ValueType, LabelType>; + using MachineLearningModelFactoryType = otb::MachineLearningModelFactory<ValueType, LabelType>; + using ModelPointerType = typename MachineLearningModelType::Pointer; + using ConfidenceListSampleType = typename MachineLearningModelType::ConfidenceListSampleType; + + /** Statistics Filters typedef */ + using MeasurementType = itk::VariableLengthVector<ValueType>; + using StatisticsReader = otb::StatisticsXMLFileReader<MeasurementType>; + + using InputSampleType = itk::VariableLengthVector<ValueType>; + using ListSampleType = itk::Statistics::ListSample<InputSampleType>; + using ShiftScaleFilterType = otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType>; + + ~VectorPrediction() override + { + MachineLearningModelFactoryType::CleanFactories(); + } + +private: + void DoInit() override; + + /** Method defining the parameters used in the application and their documentation, specialized for RegressionMode=1 and RegrssionMode=0 */ + void DoInitSpecialization(); + + void DoUpdateParameters() override; + + void DoExecute() override; + + /** Method returning whether the confidence map should be computed, depending on the regression mode and input parameters */ + bool shouldComputeConfidenceMap() const; + + /** Method returning the input list sample from the input layer */ + typename ListSampleType::Pointer ReadInputListSample(otb::ogr::Layer const& layer); + + /** Normalize a list sample using the statistic file given */ + typename ListSampleType::Pointer NormalizeListSample(ListSampleType::Pointer input); + + /** Create the output DataSource, in update mode the input layer is buffered and the input + * data source is re opened in update mode. */ + otb::ogr::DataSource::Pointer CreateOutputDataSource(otb::ogr::DataSource::Pointer source, + otb::ogr::Layer & layer, + bool updateMode); + + /** Add a prediction field in the output layer if it does not exist. + * If computeConfidenceMap evaluates to true a confidence field will be + * added. */ + void AddPredictionField(otb::ogr::Layer & outLayer, + otb::ogr::Layer const& layer, + bool computeConfidenceMap); + + /** Fill the output layer with the predicted values and optionnaly the confidence */ + void FillOutputLayer(otb::ogr::Layer & outLayer, + otb::ogr::Layer const& layer, + typename LabelListSampleType::Pointer target, + typename ConfidenceListSampleType::Pointer quality, + bool updateMode, + bool computeConfidenceMap); + + ModelPointerType m_Model; + + /** Name used for the confidence field */ + std::string confFieldName = "confidence"; +}; +} +} + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbVectorPrediction.hxx" +#endif + +#endif diff --git a/Modules/Applications/AppClassification/include/otbVectorPrediction.hxx b/Modules/Applications/AppClassification/include/otbVectorPrediction.hxx new file mode 100644 index 0000000000000000000000000000000000000000..fde557da101a9b1b493027711e6efc7ae14a9578 --- /dev/null +++ b/Modules/Applications/AppClassification/include/otbVectorPrediction.hxx @@ -0,0 +1,345 @@ +/* + * Copyright (C) 2005-2019 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. + */ + +#ifndef otbVectorPrediction_hxx +#define otbVectorPrediction_hxx + +#include "otbVectorPrediction.h" + +namespace otb +{ +namespace Wrapper +{ + +template <bool RegressionMode> +void VectorPrediction<RegressionMode>::DoInit() +{ + DoInitSpecialization(); + + // Assert that the all needed parameters have ben definied in DoInitSpecialization + assert(GetParameterByKey("in") != nullptr); + assert(GetParameterByKey("instat") != nullptr); + assert(GetParameterByKey("model") != nullptr); + assert(GetParameterByKey("cfield") != nullptr); + assert(GetParameterByKey("feat") != nullptr); + assert(GetParameterByKey("out") != nullptr); +} + +template <bool RegressionMode> +void VectorPrediction<RegressionMode>::DoUpdateParameters() +{ + if (HasValue("in")) + { + auto shapefileName = GetParameterString("in"); + + auto ogrDS = otb::ogr::DataSource::New(shapefileName, otb::ogr::DataSource::Modes::Read); + auto layer = ogrDS->GetLayer(0); + OGRFeatureDefn& layerDefn = layer.GetLayerDefn(); + + ClearChoices("feat"); + + for (int iField = 0; iField < layerDefn.GetFieldCount(); iField++) + { + auto fieldDefn = layerDefn.GetFieldDefn(iField); + std::string item = fieldDefn->GetNameRef(); + std::string key(item); + key.erase(std::remove_if(key.begin(), key.end(), [](char c){return !std::isalnum(c);}), key.end()); + std::transform(key.begin(), key.end(), key.begin(), tolower); + auto fieldType = fieldDefn->GetType(); + if (fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal) + { + std::string tmpKey = "feat." + key; + AddChoice(tmpKey, item); + } + } + } +} + +template <bool RegressionMode> +typename VectorPrediction<RegressionMode>::ListSampleType::Pointer +VectorPrediction<RegressionMode> +::ReadInputListSample(otb::ogr::Layer const& layer) +{ + typename ListSampleType::Pointer input = ListSampleType::New(); + + const int nbFeatures = GetSelectedItems("feat").size(); + input->SetMeasurementVectorSize(nbFeatures); + + for (auto const& feature : layer) + { + MeasurementType mv(nbFeatures); + for (int idx = 0; idx < nbFeatures; ++idx) + { + // Beware that itemIndex differs from ogr layer field index + unsigned int itemIndex = GetSelectedItems("feat")[idx]; + std::string fieldName = GetChoiceNames("feat")[itemIndex]; + + auto field = feature[fieldName]; + switch (field.GetType()) + { + case OFTInteger: + case OFTInteger64: + mv[idx] = static_cast<ValueType>(field.template GetValue<int>()); + break; + case OFTReal: + mv[idx] = static_cast<ValueType>(field.template GetValue<double>()); + break; + default: + itkExceptionMacro(<< "incorrect field type: " << field.GetType() << "."); + } + } + input->PushBack(mv); + } + return input; +} + +template <bool RegressionMode> +typename VectorPrediction<RegressionMode>::ListSampleType::Pointer +VectorPrediction<RegressionMode> +::NormalizeListSample(ListSampleType::Pointer input) +{ + const int nbFeatures = GetSelectedItems("feat").size(); + + // Statistics for shift/scale + MeasurementType meanMeasurementVector; + MeasurementType stddevMeasurementVector; + if (HasValue("instat") && IsParameterEnabled("instat")) + { + typename StatisticsReader::Pointer statisticsReader = StatisticsReader::New(); + std::string XMLfile = GetParameterString("instat"); + statisticsReader->SetFileName(XMLfile); + meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); + stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); + } + else + { + meanMeasurementVector.SetSize(nbFeatures); + meanMeasurementVector.Fill(0.); + stddevMeasurementVector.SetSize(nbFeatures); + stddevMeasurementVector.Fill(1.); + } + + typename ShiftScaleFilterType::Pointer trainingShiftScaleFilter = ShiftScaleFilterType::New(); + trainingShiftScaleFilter->SetInput(input); + trainingShiftScaleFilter->SetShifts(meanMeasurementVector); + trainingShiftScaleFilter->SetScales(stddevMeasurementVector); + trainingShiftScaleFilter->Update(); + otbAppLogINFO("mean used: " << meanMeasurementVector); + otbAppLogINFO("standard deviation used: " << stddevMeasurementVector); + + otbAppLogINFO("Loading model"); + + return trainingShiftScaleFilter->GetOutput(); +} + + +template <bool RegressionMode> +otb::ogr::DataSource::Pointer +VectorPrediction<RegressionMode> +::CreateOutputDataSource(otb::ogr::DataSource::Pointer source, otb::ogr::Layer & layer, bool updateMode) +{ + ogr::DataSource::Pointer output; + ogr::DataSource::Pointer buffer = ogr::DataSource::New(); + if (updateMode) + { + // Update mode + otbAppLogINFO("Update input vector data."); + // fill temporary buffer for the transfer + otb::ogr::Layer inputLayer = layer; + layer = buffer->CopyLayer(inputLayer, std::string("Buffer")); + // close input data source + source->Clear(); + // Re-open input data source in update mode + output = otb::ogr::DataSource::New(GetParameterString("in"), otb::ogr::DataSource::Modes::Update_LayerUpdate); + } + else + { + // Create new OGRDataSource + output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite); + otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), layer.GetGeomType()); + // Copy existing fields + OGRFeatureDefn& inLayerDefn = layer.GetLayerDefn(); + for (int k = 0; k < inLayerDefn.GetFieldCount(); k++) + { + OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k)); + newLayer.CreateField(fieldDefn); + } + } + + return output; +} + + +template <bool RegressionMode> +void +VectorPrediction<RegressionMode> +::AddPredictionField(otb::ogr::Layer & outLayer, otb::ogr::Layer const& layer, bool computeConfidenceMap) +{ + OGRFeatureDefn& layerDefn = layer.GetLayerDefn(); + + const OGRFieldType labelType = RegressionMode ? OFTReal : OFTInteger; + + int idx = layerDefn.GetFieldIndex(GetParameterString("cfield").c_str()); + if (idx >= 0) + { + if (layerDefn.GetFieldDefn(idx)->GetType() != labelType) + itkExceptionMacro("Field name " << GetParameterString("cfield") << " already exists with a different type!"); + } + else + { + OGRFieldDefn predictedField(GetParameterString("cfield").c_str(), labelType); + ogr::FieldDefn predictedFieldDef(predictedField); + outLayer.CreateField(predictedFieldDef); + } + + // Add confidence field in the output layer + if (computeConfidenceMap) + { + idx = layerDefn.GetFieldIndex(confFieldName.c_str()); + if (idx >= 0) + { + if (layerDefn.GetFieldDefn(idx)->GetType() != OFTReal) + itkExceptionMacro("Field name " << confFieldName << " already exists with a different type!"); + } + else + { + OGRFieldDefn confidenceField(confFieldName.c_str(), OFTReal); + confidenceField.SetWidth(confidenceField.GetWidth()); + confidenceField.SetPrecision(confidenceField.GetPrecision()); + ogr::FieldDefn confFieldDefn(confidenceField); + outLayer.CreateField(confFieldDefn); + } + } +} + +template <bool RegressionMode> +void +VectorPrediction<RegressionMode> +::FillOutputLayer(otb::ogr::Layer & outLayer, otb::ogr::Layer const& layer, typename LabelListSampleType::Pointer target, + typename ConfidenceListSampleType::Pointer quality, bool updateMode, bool computeConfidenceMap) +{ + unsigned int count = 0; + std::string classfieldname = GetParameterString("cfield"); + for (auto const& feature : layer) + { + ogr::Feature dstFeature(outLayer.GetLayerDefn()); + dstFeature.SetFrom(feature, TRUE); + dstFeature.SetFID(feature.GetFID()); + auto field = dstFeature[classfieldname]; + switch (field.GetType()) + { + case OFTInteger64: + case OFTInteger: + field.template SetValue<int>(target->GetMeasurementVector(count)[0]); + break; + case OFTReal: + field.template SetValue<double>(target->GetMeasurementVector(count)[0]); + break; + case OFTString: + field.template SetValue<std::string>(std::to_string(target->GetMeasurementVector(count)[0])); + break; + default: + itkExceptionMacro(<< "incorrect field type: " << field.GetType() << "."); + } + if (computeConfidenceMap) + dstFeature[confFieldName].template SetValue<double>(quality->GetMeasurementVector(count)[0]); + if (updateMode) + { + outLayer.SetFeature(dstFeature); + } + else + { + outLayer.CreateFeature(dstFeature); + } + count++; + } +} + +template <bool RegressionMode> +void VectorPrediction<RegressionMode>::DoExecute() +{ + m_Model = MachineLearningModelFactoryType::CreateMachineLearningModel(GetParameterString("model"), MachineLearningModelFactoryType::ReadMode); + + if (m_Model.IsNull()) + { + otbAppLogFATAL(<< "Error when loading model " << GetParameterString("model") << " : unsupported model type"); + } + + m_Model->SetRegressionMode(RegressionMode); + + m_Model->Load(GetParameterString("model")); + otbAppLogINFO("Model loaded"); + + auto shapefileName = GetParameterString("in"); + + auto source = otb::ogr::DataSource::New(shapefileName, otb::ogr::DataSource::Modes::Read); + auto layer = source->GetLayer(0); + + auto input = ReadInputListSample(layer); + + ListSampleType::Pointer listSample = NormalizeListSample(input); + + typename LabelListSampleType::Pointer target; + + // The quality listSample containing confidence values is defined here, but is only used when + // computeConfidenceMap evaluates to true. This listSample is also used in FillOutputLayer(...) + const bool computeConfidenceMap = shouldComputeConfidenceMap(); + typename ConfidenceListSampleType::Pointer quality; + + if (computeConfidenceMap) + { + quality = ConfidenceListSampleType::New(); + target = m_Model->PredictBatch(listSample, quality); + } + else + { + target = m_Model->PredictBatch(listSample); + } + + const bool updateMode = !(IsParameterEnabled("out") && HasValue("out")); + + auto output = CreateOutputDataSource(source, layer, updateMode); + otb::ogr::Layer outLayer = output->GetLayer(0); + + OGRErr errStart = outLayer.ogr().StartTransaction(); + if (errStart != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + + AddPredictionField(outLayer, layer, computeConfidenceMap); + FillOutputLayer(outLayer, layer, target, quality, updateMode, computeConfidenceMap); + + if (outLayer.ogr().TestCapability("Transactions")) + { + const OGRErr errCommitX = outLayer.ogr().CommitTransaction(); + if (errCommitX != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << outLayer.ogr().GetName() << "."); + } + } + + output->SyncToDisk(); +} + +} // end namespace wrapper +} // end namespace otb + +#endif diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index 607867c1936a594cbdbe1ed3ff8fdb382efb529e..b47c420c21388528cccb295d466a9304b810c781 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -716,11 +716,25 @@ if(OTB_USE_OPENCV) -out ${TEMP}/apTvClSVMLabeledVector.shp -feat meanB0 meanB1 meanB2 meanB3 varB0 varB1 varB2 varB3 -cfield class - VALID --compare-ogr 0.0 + VALID --compare-ogr ${NOTOL} ${OTBAPP_BASELINE_FILES}/apTvClSVMLabeledVector.shp ${TEMP}/apTvClSVMLabeledVector.shp) endif() +#----------- VectorRegression TESTS ---------------- +if(OTB_USE_OPENCV) + otb_test_application(NAME apTvClDTVectorRegression + APP VectorRegression + OPTIONS -in ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -model ${INPUTDATA}/Classification/apTvClDTVectorRegression.dt + -out ${TEMP}/apTvClDTVectorRegression.sqlite + -feat value_0 value_1 value_2 value_3 + -cfield predicted + VALID --compare-ogr ${NOTOL} + ${OTBAPP_BASELINE_FILES}/apTvClDTVectorRegression.sqlite + ${TEMP}/apTvClDTVectorRegression.sqlite) +endif() + #----------- ComputeImagesStatistics TESTS ---------------- otb_test_application(NAME apTvClComputeImagesStatisticsQB1 APP ComputeImagesStatistics diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx index 2629ce715998a58b38902703e53d5e85d6889b46..d3c4a29b45aeff39e3a1fb364146a494f961bc8b 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbVectorDimensionalityReduction.cxx @@ -32,13 +32,6 @@ namespace otb { namespace Wrapper { - -/** Utility function to negate std::isalnum */ -bool IsNotAlphaNum(char c) -{ -return !std::isalnum(c); -} - /** * \class VectorDimensionalityReduction * @@ -180,7 +173,7 @@ private: { std::string item = layerDefn.GetFieldDefn(iField)->GetNameRef(); std::string key(item); - std::string::iterator end = std::remove_if( key.begin(), key.end(), IsNotAlphaNum ); + std::string::iterator end = std::remove_if( key.begin(), key.end(), [](char c){return !std::isalnum(c);}); std::transform( key.begin(), end, key.begin(), tolower ); std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx index f4a0bd1e5f04dcac2d33eb6229c1c2805f4b9564..371b301c40e4d51548c26dead99926726b7abccf 100644 --- a/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx +++ b/Modules/Applications/AppHyperspectral/app/otbHyperspectralUnmixing.cxx @@ -23,8 +23,6 @@ #include "otbUnConstrainedLeastSquareImageFilter.h" #include "otbISRAUnmixingImageFilter.h" -#include "otbNCLSUnmixingImageFilter.h" -//#include "otbFCLSUnmixingImageFilter.h" #include "otbMDMDNMFImageFilter.h" @@ -34,8 +32,6 @@ namespace Wrapper { typedef otb::UnConstrainedLeastSquareImageFilter<DoubleVectorImageType, DoubleVectorImageType, double> UCLSUnmixingFilterType; typedef otb::ISRAUnmixingImageFilter<DoubleVectorImageType, DoubleVectorImageType, double> ISRAUnmixingFilterType; -typedef otb::NCLSUnmixingImageFilter<DoubleVectorImageType, DoubleVectorImageType, double> NCLSUnmixingFilterType; -//typedef otb::FCLSUnmixingImageFilter<DoubleVectorImageType, DoubleVectorImageType, double> FCLSUnmixingFilterType; typedef otb::MDMDNMFImageFilter<DoubleVectorImageType, DoubleVectorImageType> MDMDNMFUnmixingFilterType; typedef otb::VectorImageToMatrixImageFilter<DoubleVectorImageType> VectorImageToMatrixImageFilterType; @@ -65,12 +61,12 @@ enum UnMixingMethod { UnMixingMethod_UCLS, //UnMixingMethod_FCLS, - UnMixingMethod_NCLS, + // UnMixingMethod_NCLS, UnMixingMethod_ISRA, UnMixingMethod_MDMDNMF, }; -const char* UnMixingMethodNames [] = { "UCLS", "FCLS", "NCLS", "ISRA", "MDMDNMF", }; +const char* UnMixingMethodNames [] = { "UCLS", "ISRA", "MDMDNMF", }; class HyperspectralUnmixing : public Application @@ -104,9 +100,7 @@ private: "be estimated using the VertexComponentAnalysis application.\n\n" "The application allows estimating the abundance maps with several algorithms:\n\n" "* Unconstrained Least Square (ucls)\n" -// "* Fully Constrained Least Square (fcls)\n" "* Image Space Reconstruction Algorithm (isra)\n" - "* Non-negative constrained\n" "* Least Square (ncls)\n" "* Minimum Dispersion Constrained Non Negative Matrix Factorization (MDMDNMF)." ); @@ -135,12 +129,6 @@ private: AddChoice("ua.ucls", "UCLS"); SetParameterDescription("ua.ucls", "Unconstrained Least Square"); -// AddChoice("ua.fcls", "FCLS"); -// SetParameterDescription("ua.fcls", "Fully constrained Least Square"); - - AddChoice("ua.ncls", "NCLS"); - SetParameterDescription("ua.ncls", "Non-negative constrained Least Square"); - AddChoice("ua.isra", "ISRA"); SetParameterDescription("ua.isra", "Image Space Reconstruction Algorithm"); @@ -217,36 +205,6 @@ private: } break; - case UnMixingMethod_NCLS: - { - otbAppLogINFO("NCLS Unmixing"); - - NCLSUnmixingFilterType::Pointer unmixer = - NCLSUnmixingFilterType::New(); - - unmixer->SetInput(inputImage); - unmixer->GetModifiableFunctor().SetEndmembersMatrix(endMembersMatrix); - abundanceMap = unmixer->GetOutput(); - m_ProcessObjects.push_back(unmixer.GetPointer()); - - } - break; - /* - case UnMixingMethod_FCLS: - { - otbAppLogINFO("FCLS Unmixing"); - - FCLSUnmixingFilterType::Pointer unmixer = - FCLSUnmixingFilterType::New(); - - unmixer->SetInput(inputImage); - unmixer->SetEndmembersMatrix(endMembersMatrix); - abundanceMap = unmixer->GetOutput(); - m_ProcessObjects.push_back(unmixer.GetPointer()); - - } - break; - */ case UnMixingMethod_MDMDNMF: { otbAppLogINFO("MDMD-NMF Unmixing"); diff --git a/Modules/Applications/AppHyperspectral/test/CMakeLists.txt b/Modules/Applications/AppHyperspectral/test/CMakeLists.txt index a430980733388e9732cf69f2270e0396902f904c..9d7a04bf7e2451f4075256ec446f6c3ccedfe36f 100644 --- a/Modules/Applications/AppHyperspectral/test/CMakeLists.txt +++ b/Modules/Applications/AppHyperspectral/test/CMakeLists.txt @@ -30,17 +30,6 @@ otb_test_application(NAME apTvHyHyperspectralUnmixing_UCLS ${BASELINE}/apTvHyHyperspectralUnmixing_UCLS.tif ${TEMP}/apTvHyHyperspectralUnmixing_UCLS.tif) -otb_test_application(NAME apTvHyHyperspectralUnmixing_NCLS - APP HyperspectralUnmixing - OPTIONS -in ${INPUTDATA}/Hyperspectral/synthetic/hsi_cube.tif - -ie ${INPUTDATA}/Hyperspectral/synthetic/endmembers.tif - -out ${TEMP}/apTvHyHyperspectralUnmixing_NCLS.tif double - -ua ncls - VALID --compare-image ${EPSILON_9} - ${BASELINE}/apTvHyHyperspectralUnmixing_NCLS.tif - ${TEMP}/apTvHyHyperspectralUnmixing_NCLS.tif) - - #----------- VertexComponentAnalysis TESTS ---------------- otb_test_application(NAME apTvHyVertexComponentAnalysis APP VertexComponentAnalysis diff --git a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx index 2a770fe79d68659858925fdb5295fbafea2bd6b0..f4dd4f431398397fe96ded78706c6d8823695d2b 100644 --- a/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx +++ b/Modules/Applications/AppMathParserX/app/otbBandMathX.cxx @@ -121,54 +121,42 @@ private: void DoUpdateParameters() override { // check if input context should be used - bool useContext = this->ContextCheck(); + bool context_exists = this->ContextCheck(); // Check if the expression is correctly set - if (HasValue("il") && HasValue("exp")) - { - this->LiveCheck(useContext); - } + BandMathImageFilterType::Pointer math_filter = BandMathImageFilterType::New(); + math_filter->SetManyExpressions(false); + // first thing, load context if there is one + if (context_exists) + math_filter->ImportContext(GetParameterString("incontext")); + // Only one expression is allowed '-exp'>'-incontext' + if ( !HasValue("exp") ) + SetParameterString("exp", math_filter->GetExpression(0)); + if ( HasValue("il") && HasValue("exp") ) + { + math_filter->ClearExpression(); // remove expression set by context + math_filter->SetExpression(GetParameterString("exp")); //set expression + LiveCheck(math_filter); + } } + // Check if the given filename is valid bool ContextCheck(void) - { - bool useContext = false; + { + bool context_exists = false; if (IsParameterEnabled("incontext") && HasValue("incontext")) - { + { std::string contextPath = GetParameterString("incontext"); // check that file exists if (itksys::SystemTools::FileExists(contextPath,true)) - { - BandMathImageFilterType::Pointer dummyFilter = - BandMathImageFilterType::New(); - dummyFilter->SetManyExpressions(false); - try - { - dummyFilter->ImportContext(contextPath); - useContext = true; - } - catch(itk::ExceptionObject& err) - { - //trick to prevent unreferenced local variable warning on MSVC - (void)err; - // silent catch - useContext = false; - } - if (useContext) - { - // only set the first expression, 'ManyExpression' is disabled. - this->SetParameterString("exp",dummyFilter->GetExpression(0)); - } - } + { + context_exists = true; } - return useContext; } + return context_exists; + } - void LiveCheck(bool useContext=false) + void LiveCheck( BandMathImageFilterType::Pointer math_filter ) { - BandMathImageFilterType::Pointer dummyFilter = - BandMathImageFilterType::New(); - dummyFilter->SetManyExpressions(false); - std::vector<MultiChannelExtractorType::Pointer> extractors; FloatVectorImageListType::Pointer inList = GetParameterImageList("il"); for (unsigned int i = 0; i < inList->Size(); i++) @@ -189,19 +177,11 @@ private: { extract->SetChannel(j+1); } - dummyFilter->SetNthInput(i,extract->GetOutput()); - } - if (useContext) - { - dummyFilter->ImportContext(GetParameterString("incontext")); - } - else - { - dummyFilter->SetExpression(GetParameterString("exp")); + math_filter->SetNthInput(i,extract->GetOutput()); } try { - dummyFilter->UpdateOutputInformation(); + math_filter->UpdateOutputInformation(); SetParameterDescription("exp", "Valid expression"); } catch(itk::ExceptionObject& err) @@ -209,8 +189,15 @@ private: // Change the parameter description to be able to have the // parser errors in the tooltip SetParameterDescription("exp", err.GetDescription()); + // std::string error_string(err.GetDescription()); + // otbAppLogINFO("There was an error while parsing the expression given " + // "its input:" + error_string ); } + catch(...) + { + SetParameterDescription("exp", "Other exception catched"); } + } void DoExecute() override { @@ -227,11 +214,11 @@ private: if ( (!IsParameterEnabled("exp")) && (!IsParameterEnabled("incontext")) ) { - itkExceptionMacro("No expression set...; please set and enable at least one one expression"); + itkExceptionMacro("No expression set...; please set and enable at least one expression"); } - m_Filter = BandMathImageFilterType::New(); - m_Filter->SetManyExpressions(false); + BandMathImageFilterType::Pointer math_filter = BandMathImageFilterType::New(); + math_filter->SetManyExpressions(false); for (unsigned int i = 0; i < nbImages; i++) { @@ -242,31 +229,33 @@ private: << currentImage->GetNumberOfComponentsPerPixel() << " components"); - m_Filter->SetNthInput(i,currentImage); + math_filter->SetNthInput(i,currentImage); } - bool useContext = this->ContextCheck(); + bool context_exists = this->ContextCheck(); + // first thing, load context if there is one + if (context_exists) + { + std::string context_string = GetParameterString("incontext"); + math_filter->ImportContext(context_string); + otbAppLogINFO("Using Context: " << context_string + << " for variables (and expression if no parameter -exp has been given)." ); + } + // Only one expression is allowed '-exp'>'-incontext' + math_filter->ClearExpression(); // remove expression set by context std::string expStr = GetParameterString("exp"); - if (useContext) - { - otbAppLogINFO("Using input context: " << expStr ); - m_Filter->ImportContext(GetParameterString("incontext")); - } - else - { - otbAppLogINFO("Using expression: " << expStr ); - m_Filter->SetExpression(expStr); - } + otbAppLogINFO("Using expression: " << expStr ); + math_filter->SetExpression(expStr); if ( IsParameterEnabled("outcontext") && HasValue("outcontext") ) - m_Filter->ExportContext(GetParameterString("outcontext")); + math_filter->ExportContext(GetParameterString("outcontext")); // Set the output image - SetParameterOutputImage("out", m_Filter->GetOutput()); + SetParameterOutputImage("out", math_filter->GetOutput()); + RegisterPipeline(); } - BandMathImageFilterType::Pointer m_Filter; }; } // namespace Wrapper diff --git a/Modules/Applications/AppMathParserX/otb-module.cmake b/Modules/Applications/AppMathParserX/otb-module.cmake index 54b1fc571ac6aedc6cdfa26f7c1c4949ce4c3baa..eda0082072a811e8947f5962ccacd390f71e8af5 100644 --- a/Modules/Applications/AppMathParserX/otb-module.cmake +++ b/Modules/Applications/AppMathParserX/otb-module.cmake @@ -26,6 +26,9 @@ otb_module(OTBAppMathParserX OTBMathParserX OTBObjectList + TEST_DEPENDS + OTBTestKernel + DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/Applications/AppMathParserX/test/CMakeLists.txt b/Modules/Applications/AppMathParserX/test/CMakeLists.txt index b5d584699738fa153a1a7a5c93a80138bd52c904..65e464ffec60931c951646d2e77d2a31575c841f 100644 --- a/Modules/Applications/AppMathParserX/test/CMakeLists.txt +++ b/Modules/Applications/AppMathParserX/test/CMakeLists.txt @@ -20,15 +20,15 @@ otb_module_test() -#----------- BandMathX TESTS ---------------- -otb_test_application(NAME apTvUtBandMathX - APP BandMathX - OPTIONS -il ${INPUTDATA}/poupees_sub_c1.png - ${INPUTDATA}/poupees_sub_c2.png - ${INPUTDATA}/poupees_sub.png - -out ${TEMP}/apTvUtBandMathXOutput.tif - -incontext ${INPUTDATA}/apTvUtExportBandMathX.txt - VALID --compare-image ${NOTOL} - ${INPUTDATA}/apTvUtBandMathOutput.tif - ${TEMP}/apTvUtBandMathXOutput.tif) +set(OTBBandMathXAppTest +otbBandMathXAppTests.cxx +) +add_executable(OTBBandMathXAppTest ${OTBBandMathXAppTest}) +target_link_libraries(OTBBandMathXAppTest ${OTBAppMathParserX-Test_LIBRARIES}) +otb_module_target_label(OTBBandMathXAppTest) + +otb_add_test(NAME apTvUtBandMathX COMMAND OTBBandMathXAppTest + $<TARGET_FILE_DIR:otbapp_BandMathX> + ${INPUTDATA}/apTvUtExportBandMathX.txt + ) \ No newline at end of file diff --git a/Modules/Applications/AppMathParserX/test/otbBandMathXAppTests.cxx b/Modules/Applications/AppMathParserX/test/otbBandMathXAppTests.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b2d425fc0632ff9f3c4cd85adb3572160bcfee87 --- /dev/null +++ b/Modules/Applications/AppMathParserX/test/otbBandMathXAppTests.cxx @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2005-2019 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 "otbVectorImage.h" +#include "otbWrapperApplicationRegistry.h" +#include "otbWrapperTypes.h" +#include <string> + +typedef otb::VectorImage<unsigned char> VectorImageType; +typedef VectorImageType::PixelType PixelType; + +/* This function is creating and filling a vector image */ +VectorImageType::Pointer create_vector_image( int pxl_s , int nb_comp , unsigned char value ) +{ + VectorImageType::SizeType size; + size.Fill(pxl_s); + VectorImageType::IndexType index; + index.Fill(0); + VectorImageType::RegionType region; + region.SetSize(size); + region.SetIndex(index); + + VectorImageType::Pointer image = VectorImageType::New(); + + image->SetLargestPossibleRegion( region ); + image->SetBufferedRegion( region ); + image->SetRequestedRegion( region ); + image->SetNumberOfComponentsPerPixel(nb_comp); + image->Allocate(); + PixelType val(nb_comp); + val.Fill(value); + image->FillBuffer(val); + return image; +} + +#define dyn_cast( im_base , vect_im ) \ +{ \ + vect_im = dynamic_cast<otb::VectorImage<float> *>(im_base); \ + if( ! vect_im ) \ + { \ + std::cout<<"Not the right conversion, cannot retrieve the output"<<std::endl; \ + return EXIT_FAILURE ; \ + } \ +} + +int main(int , char * argv[] ) +{ + std::cout<<"Begin bandMathX Test"<<std::endl; + int return_val = 0; + auto img1 = create_vector_image(5,2,1); + auto img2 = create_vector_image(5,1,2); + VectorImageType::IndexType index; + index.Fill(3); // Center of the images + std::cout<<"Create application"<<std::endl; + otb::Wrapper::ApplicationRegistry::SetApplicationPath(argv[1]); + auto app = otb::Wrapper::ApplicationRegistry::CreateApplication("BandMathX"); + app->AddImageToParameterInputImageList("il", img1); + app->UpdateParameters(); + app->AddImageToParameterInputImageList("il", img2); + app->UpdateParameters(); + std::cout<<"Inputs are set"<<std::endl; + + // Case one: only expression + app->SetParameterString("exp", "im1b1+im2b1"); + app->UpdateParameters(); + app->SetParameterOutputImagePixelType("out", otb::Wrapper::ImagePixelType::ImagePixelType_uint8); + std::cout<<"Case one: parameter exp is set"<<std::endl; + app->Execute(); + auto output = app->GetParameterImageBase("out"); + output->Update(); + float im_val = 0; + // We need to be carefull as we are taking the direct output of the underlying + // filter in the application + otb::VectorImage<float> * output_int = nullptr; + dyn_cast( output , output_int ) + im_val = output_int->GetPixel(index).GetElement(0); + if ( im_val != 3 ) + { + std::cout<<"Wrong value in test, was expecting 3, got "<<im_val<<std::endl; + return_val++; + } + else + { + std::cout<<"Case one passed"<<std::endl; + } + + // Case two: expression and context + app->SetParameterString("exp", "im1b1+val-im2b1"); + app->UpdateParameters(); + std::cout<<"Case two: use context to define a constant"<<std::endl; + auto desc = app->GetParameterDescription("exp"); + if (desc.find("Following variables not allowed : val") == std::string::npos) + { + std::cout<<"Cannot find usual value in the parameter description."<<std::endl; + std::cout<<"The test was looking for \"Following variables not allowed : val\"" + <<" in the parameter description and got \""<<desc<<"\" instead."<<std::endl; + return_val++; + } + + app->SetParameterString("incontext",argv[2]); + // val is set in the context to 1 + app->UpdateParameters(); + desc = app->GetParameterDescription("exp"); + if (desc.find("Valid expression") == std::string::npos ) + { + std::cout<<"Cannot find usual value in the parameter description."<<std::endl; + std::cout<<"The test was looking for \"Valid expression\"" + <<" in the parameter description and got \""<<desc<<"\" instead."<<std::endl; + return_val++; + } + + app->Execute(); + output = app->GetParameterImageBase("out"); + output->Update(); + // We need to be carefull as we are taking the direct output of the underlying + // filter in the application + dyn_cast( output , output_int ) + im_val = output_int->GetPixel(index).GetElement(0); + if ( im_val != 0 ) + { + std::cout<<"Wrong value in test, was expecting 0, got "<<im_val<<std::endl; + return_val++; + } + else + { + std::cout<<"Case two passed"<<std::endl; + } + + // Case three: no expression and context + app->SetParameterString("exp", ""); + app->UpdateParameters(); + std::cout<<"Case three: no parameter exp"<<std::endl; + auto exp = app->GetParameterString("exp"); + if (exp.find("im1b1 + 2*val + im2b1") == std::string::npos ) + { + std::cout<<"The expression value is not set correctly."<<std::endl; + std::cout<<"The test was looking for \"im1b1 + 2*val + im2b1\"" + <<" in the parameter value and got \""<<exp<<"\" instead."<<std::endl; + return_val++; + } + app->Execute(); + output = app->GetParameterImageBase("out"); + output->Update(); + // We need to be carefull as we are taking the direct output of the underlying + // filter in the application + dyn_cast( output , output_int ) + im_val = output_int->GetPixel(index).GetElement(0); + if (im_val != 5 ) + { + std::cout<<"Wrong value in test, was expecting 5, got "<<im_val<<std::endl; + return_val++; + } + else + { + std::cout<<"Case three passed"<<std::endl; + } + return return_val; +} \ No newline at end of file diff --git a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx index 467a0d8a0510821701ba4b8298fad4d8c0cb6261..506fbef994c92acd47e454912460fd6d4167b41b 100644 --- a/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx +++ b/Modules/Applications/AppSegmentation/app/otbLSMSVectorization.cxx @@ -292,7 +292,7 @@ private: //Creation of a multipolygon where are stored the geometries to be merged OGRMultiPolygon geomToMerge; - geomToMerge.addGeometry(firstFeature.GetGeometry()); + AddValidGeometry(geomToMerge, firstFeature.GetGeometry()); bool merging = true; otb::ogr::Feature nextFeature(nullptr); bool haveMerged=false; @@ -309,7 +309,7 @@ private: //Storing of the new geometry if labels are identical if(merging) { - geomToMerge.addGeometry(nextFeature.GetGeometry()); + AddValidGeometry(geomToMerge, nextFeature.GetGeometry()); layer.DeleteFeature(nextFeature.GetFID()); haveMerged=true; } @@ -378,6 +378,18 @@ private: otbAppLogINFO(<<"Elapsed time: "<<(double)(toc - tic) / CLOCKS_PER_SEC<<" seconds"); } + void AddValidGeometry(OGRMultiPolygon &multi, OGRGeometry const * g) + { + if (g->IsValid()) + { + multi.addGeometry(g); + } + else + { + multi.addGeometryDirectly( g->Simplify(0.0) ); + } + } + }; } } diff --git a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.hxx b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.hxx index dcd43c075fe385163904dc59014297722b57abf6..741f7b617dc6ed9f96f6724b7a14592f23fd7ab4 100644 --- a/Modules/Core/Transform/include/otbStreamingWarpImageFilter.hxx +++ b/Modules/Core/Transform/include/otbStreamingWarpImageFilter.hxx @@ -230,24 +230,9 @@ StreamingWarpImageFilter<TInputImage, TOutputImage, TDisplacementField> { inputPtr->SetRequestedRegion(inputRequestedRegion); } - else - { - - inputFinalSize.Fill(0); - inputRequestedRegion.SetSize(inputFinalSize); - inputFinalIndex.Fill(0); - inputRequestedRegion.SetIndex(inputFinalIndex); - - // store what we tried to request (prior to trying to crop) - inputPtr->SetRequestedRegion(inputRequestedRegion); - -// // build an exception -// itk::InvalidRequestedRegionError e(__FILE__, __LINE__); -// e.SetLocation(ITK_LOCATION); -// e.SetDescription("Requested region is (at least partially) outside the largest possible region."); -// e.SetDataObject(inputPtr); -// throw e; - } + // Here we do not throw an exception, we just do nothing since + // resampling filter can legitimately ask for a region outside of + // input's largest possible region. } diff --git a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h index 9822cd6ab731a520109484ec9e4bd32947f65468..ce76dd8e44ded0f672a328bb72bcabdf6566dced 100644 --- a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h +++ b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.h @@ -112,8 +112,8 @@ public: /** Set an expression to be parsed */ void SetExpression(const std::string& expression); - /** Return the nth expression to be parsed */ - std::string GetExpression(int) const; + /** Return the nth expression to be parsed*/ + std::string GetExpression(unsigned int IDExpression) const; /** Set a matrix (or a vector) */ void SetMatrix(const std::string& name, const std::string& definition); @@ -127,9 +127,15 @@ public: /** Import constants and expressions from a given filename */ void ImportContext(const std::string& filename); + /** Clear all previously set expression*/ + void ClearExpression(); /** Return the variable and constant names */ std::vector<std::string> GetVarNames() const; + bool GlobalStatsDetected() const + { + return !m_StatsVarDetected.empty(); + } protected : BandMathXImageFilter(); @@ -145,11 +151,6 @@ protected : private : - bool globalStatsDetected() const - { - return (m_StatsVarDetected.size()>0); - } - typedef struct { std::string name; ValueType value; diff --git a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx index 6092926c7d22d861d0a88a811de26f9f537d016c..44cde5bed777f89ebfada6a1e1c24de73a2802d1 100644 --- a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx +++ b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx @@ -261,7 +261,13 @@ void BandMathXImageFilter<TImage> this->Modified(); } - +template< typename TImage > +void BandMathXImageFilter<TImage> +::ClearExpression() +{ + m_Expression.clear(); + this->Modified(); +} template< typename TImage > void BandMathXImageFilter<TImage> ::SetMatrix(const std::string& name, const std::string& definition) @@ -517,9 +523,11 @@ void BandMathXImageFilter<TImage> template< typename TImage > std::string BandMathXImageFilter<TImage> -::GetExpression(int IDExpression) const +::GetExpression(unsigned int IDExpression) const { - return m_Expression[IDExpression]; + if ( IDExpression < m_Expression.size() ) + return m_Expression[IDExpression]; + return ""; } @@ -913,7 +921,7 @@ void BandMathXImageFilter< TImage > CheckImageDimensions(); PrepareParsers(); - if (globalStatsDetected()) + if (GlobalStatsDetected()) PrepareParsersGlobStats(); OutputsDimensions(); diff --git a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h deleted file mode 100644 index aa3ef08ce40742422f2a3db3e12875be8ad46fe1..0000000000000000000000000000000000000000 --- a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2005-2019 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. - */ - -#ifndef otbNCLSUnmixingImageFilter_h -#define otbNCLSUnmixingImageFilter_h - -#include "itkMacro.h" -#include "itkNumericTraits.h" -#include "otbFunctorImageFilter.h" -#include "vnl/algo/vnl_svd.h" -#include <boost/shared_ptr.hpp> - -namespace otb -{ - -namespace Functor { - -/** \class NCLSUnmixingFunctor - * - * \brief Performs fully constrained least squares on a pixel - * - * \sa NCLSUnmixingImageFilter - * - * \ingroup OTBUnmixing - */ -template<class TInput, class TOutput, class TPrecision> -class NCLSUnmixingFunctor -{ -public: - typedef NCLSUnmixingFunctor<TInput, TOutput, TPrecision> Self; - - typedef TInput InputType; - typedef TOutput OutputType; - typedef TPrecision PrecisionType; - - typedef vnl_vector<PrecisionType> VectorType; - typedef vnl_matrix<PrecisionType> MatrixType; - - NCLSUnmixingFunctor(); - virtual ~NCLSUnmixingFunctor() = default; - - size_t OutputSize(const std::array<size_t, 1>& nbBands) const; - - void SetEndmembersMatrix(const MatrixType& U); - const MatrixType& GetEndmembersMatrix(void) const; - - void SetMaxIteration(unsigned int val) - { - m_MaxIteration = val; - } - - unsigned int GetMaxIteration() const - { - return m_MaxIteration; - } - - OutputType operator ()(const InputType& in) const; - -private: - - static bool IsNonNegative(PrecisionType val) - { - return val >= 0; - } - - typedef vnl_svd<PrecisionType> SVDType; - typedef boost::shared_ptr<SVDType> SVDPointerType; - - MatrixType m_U; - MatrixType m_Ut; - MatrixType m_UtUinv; - SVDPointerType m_Svd; // SVD of U - unsigned int m_OutputSize; - unsigned int m_MaxIteration; -}; -} - -/** \class NCLSUnmixingImageFilter - * - * \brief Performs fully constrained least squares on each pixel of a VectorImage - * - * This filter takes as input a multiband image and a matrix. - * If the matrix is called \f$A\f$, it solves, for each pixel \f$p\f$, the system - * \f$A \cdot x = p\f$ in the least square sense, with additional constraints on the solution - * \f$\hat{x}\f$ ensuring positivity (each component is positive) and additivity (the sum of - * all components is 1). - * - * The main use of this filter is to unmix an hyperspectral dataset, - * where \f$A\f$ is the mixing matrix, in which each row corresponds to an endmember signature. - * - * The number of rows in \f$A\f$ must match the input image number of bands. - * The number of bands in the output image will be the number of columns of $A$ - * - * References - * "Fully Constrained Least-Squares Based Linear Unmixing." Daniel Heinz, - * Chein-I Chang, and Mark L.G. Althouse. IEEE. 1999. - * - * \ingroup Hyperspectral - * \ingroup Streamed - * \ingroup Threaded - * - * \ingroup OTBUnmixing - */ -template <typename TInputImage, typename TOutputImage, typename TPrecision> -using NCLSUnmixingImageFilter = FunctorImageFilter<Functor::NCLSUnmixingFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TPrecision>>; - -} // end namespace otb - -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbNCLSUnmixingImageFilter.hxx" -#endif - -#endif - diff --git a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.hxx b/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.hxx deleted file mode 100644 index fc36006d0716dee9a1605fd5dea32b22f1db1da3..0000000000000000000000000000000000000000 --- a/Modules/Hyperspectral/Unmixing/include/otbNCLSUnmixingImageFilter.hxx +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2005-2019 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. - */ - -#ifndef otbNCLSUnmixingImageFilter_hxx -#define otbNCLSUnmixingImageFilter_hxx - -#include "otbNCLSUnmixingImageFilter.h" -#include <algorithm> - -namespace otb -{ - -namespace Functor -{ - -template <class TInput, class TOutput, class TPrecision> -NCLSUnmixingFunctor<TInput, TOutput, TPrecision> -::NCLSUnmixingFunctor() - : m_OutputSize(0), - m_MaxIteration(100) -{ -} - -template <class TInput, class TOutput, class TPrecision> -size_t -NCLSUnmixingFunctor<TInput, TOutput, TPrecision> -::OutputSize(const std::array<size_t,1> &) const -{ - return m_OutputSize; -} - -template <class TInput, class TOutput, class TPrecision> -void -NCLSUnmixingFunctor<TInput, TOutput, TPrecision> -::SetEndmembersMatrix(const MatrixType& U) -{ - m_U = U; - m_Ut = m_U.transpose(); - m_UtUinv = SVDType(m_Ut * m_U).inverse(); - m_OutputSize = m_U.cols(); - m_Svd.reset( new SVDType(m_U) ); -} - - -template <class TInput, class TOutput, class TPrecision> -const typename NCLSUnmixingFunctor<TInput, TOutput, TPrecision>::MatrixType& -NCLSUnmixingFunctor<TInput, TOutput, TPrecision> -::GetEndmembersMatrix() const -{ - return m_U; -} - -template <class TInput, class TOutput, class TPrecision> -typename NCLSUnmixingFunctor<TInput, TOutput, TPrecision>::OutputType -NCLSUnmixingFunctor<TInput, TOutput, TPrecision> -::operator ()(const InputType& in) const -{ - // TODO : support different types between input and output ? - VectorType inVector(in.Size()); - for (unsigned int i = 0; i < in.GetSize(); ++i ) - { - inVector[i] = in[i]; - } - - // Initialize with Unconstrained Least Square solution - VectorType uclsVector = m_Svd->solve(inVector); - - unsigned int nbEndmembers = m_OutputSize; - - // Apply NCLS iterations - VectorType lambda(nbEndmembers); - VectorType nclsVector = uclsVector; - VectorType correction(uclsVector.size()); - - for (unsigned int i = 0; i < m_MaxIteration; ++i) - { - // Error in original paper : divergence - // lambda = m_Ut * (inVector - m_U * nclsVector); - lambda = m_Ut * (m_U * nclsVector - inVector); - correction = m_UtUinv * lambda; - nclsVector -= correction; - } - - OutputType out(nclsVector.size()); - for (unsigned int i = 0; i < out.GetSize(); ++i ) - { - out[i] = nclsVector[i]; - } - return out; -} - -} // end namespace Functor -} // end namespace otb - -#endif diff --git a/Modules/Hyperspectral/Unmixing/test/CMakeLists.txt b/Modules/Hyperspectral/Unmixing/test/CMakeLists.txt index 5430a0a12ebc70f5b61b08e4f1bf3551b5dbc050..5982a7a388390d56198f4b1a30f44d29e48b82a7 100644 --- a/Modules/Hyperspectral/Unmixing/test/CMakeLists.txt +++ b/Modules/Hyperspectral/Unmixing/test/CMakeLists.txt @@ -23,7 +23,6 @@ otb_module_test() set(OTBUnmixingTests otbUnmixingTestDriver.cxx otbMDMDNMFImageFilter.cxx -otbNCLSUnmixingImageFilter.cxx otbISRAUnmixingImageFilter.cxx otbUnConstrainedLeastSquareImageFilter.cxx otbSparseUnmixingImageFilter.cxx @@ -51,16 +50,6 @@ otb_add_test(NAME hyTvMDMDNMFImageFilterTest COMMAND otbUnmixingTestDriver ${TEMP}/hyTvMDMDNMFImageFilterTest.tif 100) -otb_add_test(NAME hyTvNCLSUnmixingImageFilterTest COMMAND otbUnmixingTestDriver - --compare-image ${EPSILON_9} - ${BASELINE}/hyTvNCLSImageFilterTest.tif - ${TEMP}/hyTvNCLSImageFilterTest.tif - otbNCLSUnmixingImageFilterTest - ${INPUTDATA}/Hyperspectral/synthetic/hsi_cube.tif - ${INPUTDATA}/Hyperspectral/synthetic/endmembers.tif - ${TEMP}/hyTvNCLSImageFilterTest.tif - 10) - otb_add_test(NAME hyTvISRAUnmixingImageFilterTest COMMAND otbUnmixingTestDriver --compare-image ${EPSILON_9} ${BASELINE}/hyTvISRAUnmixingImageFilterTest.tif diff --git a/Modules/Hyperspectral/Unmixing/test/otbNCLSUnmixingImageFilter.cxx b/Modules/Hyperspectral/Unmixing/test/otbNCLSUnmixingImageFilter.cxx deleted file mode 100644 index c119b4b987a9bc002456ff513b6e57043b8a5af0..0000000000000000000000000000000000000000 --- a/Modules/Hyperspectral/Unmixing/test/otbNCLSUnmixingImageFilter.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005-2019 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 "otbNCLSUnmixingImageFilter.h" - -#include "otbVectorImage.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" -#include "otbVectorImageToMatrixImageFilter.h" -#include "otbStandardWriterWatcher.h" - -const unsigned int Dimension = 2; -typedef double PixelType; - -typedef otb::VectorImage<PixelType, Dimension> ImageType; -typedef otb::ImageFileReader<ImageType> ReaderType; -typedef otb::NCLSUnmixingImageFilter<ImageType, ImageType, PixelType> UnmixingImageFilterType; -typedef otb::VectorImageToMatrixImageFilter<ImageType> VectorImageToMatrixImageFilterType; -typedef otb::ImageFileWriter<ImageType> WriterType; - -int otbNCLSUnmixingImageFilterTest(int itkNotUsed(argc), char * argv[]) -{ - const char * inputImage = argv[1]; - const char * inputEndmembers = argv[2]; - const char * outputImage = argv[3]; - int maxIter = atoi(argv[4]); - - ReaderType::Pointer readerImage = ReaderType::New(); - readerImage->SetFileName(inputImage); - - ReaderType::Pointer readerEndMembers = ReaderType::New(); - readerEndMembers->SetFileName(inputEndmembers); - VectorImageToMatrixImageFilterType::Pointer endMember2Matrix = VectorImageToMatrixImageFilterType::New(); - endMember2Matrix->SetInput(readerEndMembers->GetOutput()); - - endMember2Matrix->Update(); - - typedef VectorImageToMatrixImageFilterType::MatrixType MatrixType; - MatrixType endMembers = endMember2Matrix->GetMatrix(); - MatrixType pinv = vnl_matrix_inverse<PixelType>(endMembers); - - UnmixingImageFilterType::Pointer unmixer = UnmixingImageFilterType::New(); - - unmixer->SetInput(readerImage->GetOutput()); - unmixer->GetModifiableFunctor().SetMaxIteration(maxIter); - //unmixer->SetNumberOfThreads(1); - unmixer->GetModifiableFunctor().SetEndmembersMatrix(endMember2Matrix->GetMatrix()); - - WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(outputImage); - writer->SetInput(unmixer->GetOutput()); - writer->SetNumberOfDivisionsStrippedStreaming(10); - - otb::StandardWriterWatcher w4(writer, unmixer,"NCLSUnmixingImageFilter"); - - writer->Update(); - - return EXIT_SUCCESS; -} diff --git a/Modules/Hyperspectral/Unmixing/test/otbUnmixingTestDriver.cxx b/Modules/Hyperspectral/Unmixing/test/otbUnmixingTestDriver.cxx index 22727d311a867a90dc53e01c0f650cee999cf0b2..155b26f20f03ae5421a62839375d304f4f3c7978 100644 --- a/Modules/Hyperspectral/Unmixing/test/otbUnmixingTestDriver.cxx +++ b/Modules/Hyperspectral/Unmixing/test/otbUnmixingTestDriver.cxx @@ -24,7 +24,6 @@ void RegisterTests() { REGISTER_TEST(otbMDMDNMFImageFilterTest); REGISTER_TEST(otbMDMDNMFImageFilterTest2); - REGISTER_TEST(otbNCLSUnmixingImageFilterTest); REGISTER_TEST(otbISRAUnmixingImageFilterTest); REGISTER_TEST(otbUnConstrainedLeastSquareImageFilterTest); REGISTER_TEST(otbSparseUnmixingImageFilterTest); diff --git a/Modules/Remote/diapotb.remote.cmake b/Modules/Remote/diapotb.remote.cmake index c679c41bdabb67ad4218279bc93b331d49387e3f..cc771e7f1d620088b347badb112eb4572b23719d 100644 --- a/Modules/Remote/diapotb.remote.cmake +++ b/Modules/Remote/diapotb.remote.cmake @@ -2,5 +2,5 @@ otb_fetch_module(DiapOTBModule "OTB module for SAR processing in Diapason." GIT_REPOSITORY https://gitlab.orfeo-toolbox.org/remote_modules/diapotb.git - GIT_TAG master + GIT_TAG d38457a019d2ef15a47d04c21f235c9e9fe4acd5 ) diff --git a/Modules/ThirdParty/OssimPlugins/src/gdal/ossimOgcWktTranslator.cpp b/Modules/ThirdParty/OssimPlugins/src/gdal/ossimOgcWktTranslator.cpp index 6f2f0289ca28962cf3d8c93dc358b8cd8665f724..91f433d65752a83ec1736eb915543e7c14953b96 100644 --- a/Modules/ThirdParty/OssimPlugins/src/gdal/ossimOgcWktTranslator.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/gdal/ossimOgcWktTranslator.cpp @@ -128,7 +128,7 @@ ossimString ossimOgcWktTranslator::fromOssimKwl(const ossimKeywordlist &kwl, << ": " << ( ossimUnitTypeLut::instance()-> getEntryString(units).c_str() ) - << endl; + << std::endl; break; } } // End of switch (units) @@ -491,11 +491,11 @@ ossimString ossimOgcWktTranslator::fromOssimKwl(const ossimKeywordlist &kwl, } else { - cerr << "ossimOgcWktTranslator::fromOssimKwl:\n" + std::cerr << "ossimOgcWktTranslator::fromOssimKwl:\n" << "Projection translation for " << projType << " not supported " - << endl; + << std::endl; } if(pcsCodeVal >= EPSG_CODE_MAX) @@ -532,10 +532,10 @@ ossimString ossimOgcWktTranslator::fromOssimKwl(const ossimKeywordlist &kwl, } else { - cerr << "ossimOgcWktTranslator::fromOssimKwl: Datum translation for " + std::cerr << "ossimOgcWktTranslator::fromOssimKwl: Datum translation for " << datumType <<" not supported" - << endl; + << std::endl; } } @@ -700,7 +700,7 @@ bool ossimOgcWktTranslator::toOssimKwl( const ossimString& wktString, { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << "DEBUG:" - << "\nossimProj = " << ossimProj << endl; + << "\nossimProj = " << ossimProj << std::endl; } kwl.add(prefix, ossimKeywordNames::TYPE_KW, ossimProj.c_str(), true); @@ -916,7 +916,7 @@ bool ossimOgcWktTranslator::toOssimKwl( const ossimString& wktString, << "Projection conversion to OSSIM not supported !!!!!!!!!\n" << "Please send the following string to the development staff\n" << "to be added to the transaltion to OSSIM\n" - << wkt << endl; + << wkt << std::endl; } return false; } @@ -1055,7 +1055,7 @@ ossimString ossimOgcWktTranslator::wktToOssimDatum(const ossimString& datum)cons ossimString ossimOgcWktTranslator::ossimToWktDatum(const ossimString& datum)const { ossimString result; - map<std::string, std::string>::const_iterator i = theOssimToWktDatumTranslation.find(datum); + std::map<std::string, std::string>::const_iterator i = theOssimToWktDatumTranslation.find(datum); if(i != theOssimToWktDatumTranslation.end()) { result = (*i).second; @@ -1066,7 +1066,7 @@ ossimString ossimOgcWktTranslator::ossimToWktDatum(const ossimString& datum)cons ossimString ossimOgcWktTranslator::wktToOssimProjection(const ossimString& datum)const { std::string result; - map<std::string, std::string>::const_iterator i = + std::map<std::string, std::string>::const_iterator i = theWktToOssimProjectionTranslation.find(datum); if(i != theWktToOssimProjectionTranslation.end()) { @@ -1078,7 +1078,7 @@ ossimString ossimOgcWktTranslator::wktToOssimProjection(const ossimString& datum ossimString ossimOgcWktTranslator::ossimToWktProjection(const ossimString& datum)const { ossimString result; - map<std::string, std::string>::const_iterator i = + std::map<std::string, std::string>::const_iterator i = theOssimToWktProjectionTranslation.find(datum); if(i != theOssimToWktProjectionTranslation.end()) { diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimAlosPalsarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimAlosPalsarModel.cpp index 215d10d7ee059b9845eeec03f19d3add0011d087..b9986ffb17898d70e6179304b461209fd830da44 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimAlosPalsarModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimAlosPalsarModel.cpp @@ -217,7 +217,7 @@ namespace ossimplugins /* * Leader file data reading */ - std::ifstream leaderFile(leaFilename.c_str(), ios::in | ios::binary); + std::ifstream leaderFile(leaFilename.c_str(), std::ios::in | std::ios::binary); leaderFile >> *theAlosPalsarLeader; leaderFile.close(); @@ -241,7 +241,7 @@ namespace ossimplugins /* * Read header of data file for image size info */ - std::ifstream dataFile(datFilename.c_str(), ios::in | ios::binary); + std::ifstream dataFile(datFilename.c_str(), std::ios::in | std::ios::binary); dataFile >> *theAlosPalsarData; dataFile.close(); @@ -682,7 +682,7 @@ namespace ossimplugins bool ossimAlosPalsarModel::isAlosPalsarLeader(const ossimFilename& file) const { - std::ifstream candidate(file.c_str(), ios::in | ios::binary); + std::ifstream candidate(file.c_str(), std::ios::in | std::ios::binary); char alosFileName[16]; candidate.seekg(48); @@ -745,7 +745,7 @@ namespace ossimplugins bool ossimAlosPalsarModel::isAlosPalsarData(const ossimFilename& file) const { - std::ifstream candidate(file.c_str(), ios::in | ios::binary); + std::ifstream candidate(file.c_str(), std::ios::in | std::ios::binary); char alosFileName[16]; candidate.seekg(48); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp index b11d6dc1fda61880c96f2196d9aeb68ede39b38e..ca9d72ece58a9fa1152c685af6d5c9fad184afd1 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimCosmoSkymedModel.cpp @@ -119,14 +119,14 @@ namespace ossimplugins // Capture stream flags since we are going to mess with them. std::ios_base::fmtflags f = out.flags(); - out << "\nDump of ossimCosmoSkymedModel at address " << hex << this - << dec + out << "\nDump of ossimCosmoSkymedModel at address " << std::hex << this + << std::dec << "\n------------------------------------------------" << "\n theImageID = " << theImageID << "\n theImageSize = " << theImageSize << "\n------------------------------------------------" - << "\n " << endl; + << "\n " << std::endl; // Set the flags back. out.flags(f); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp index a2b8c4c5e7f12fe109d910c32a8c3b3ca13b1d8b..d04f06725eb857cf89b91f7c5da8c20cd5c20211 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimEnvisatAsarModel.cpp @@ -125,7 +125,7 @@ namespace ossimplugins * Opening and test of the file */ ossimFilename Filename = file; - ifstream dataFile(Filename.c_str(), ios::in | ios::binary); + std::ifstream dataFile(Filename.c_str(), std::ios::in | std::ios::binary); if (dataFile.eof()) { dataFile.close(); @@ -368,7 +368,7 @@ namespace ossimplugins // Capture the original flags. std::ios_base::fmtflags f = out.flags(); - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\nossimEnvisatAsarModel data members:\n" << "_pixel_spacing: " << _pixel_spacing << "\n" << "_n_srgr: " << _n_srgr << "\n"; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimErsSarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimErsSarModel.cpp index d781754df838192dd61615cb7c2a6c8a83796843..446f09d4151c51cde941d47267314b82745ceeff 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimErsSarModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimErsSarModel.cpp @@ -195,7 +195,7 @@ namespace ossimplugins /* * Leader file data reading */ - std::ifstream leaderFile(leaFilename.c_str(), ios::in | ios::binary); + std::ifstream leaderFile(leaFilename.c_str(), std::ios::in | std::ios::binary); leaderFile >> *theErsSarleader; leaderFile.close(); @@ -613,8 +613,8 @@ namespace ossimplugins ossimString filename(kwl.find("filename")); filename.upcase(); //std::transform(filename.begin(), filename.end(), filename.begin(), toupper); - string::size_type loc = filename.find("PRI"); - if (loc != string::npos) + std::string::size_type loc = filename.find("PRI"); + if (loc != std::string::npos) { _isProductGeoreferenced = true; } @@ -646,7 +646,7 @@ namespace ossimplugins bool ossimErsSarModel::isErsLeader(const ossimFilename& file) const { - std::ifstream candidate(file.c_str(), ios::in | ios::binary); + std::ifstream candidate(file.c_str(), std::ios::in | std::ios::binary); char ersFileName[16]; candidate.seekg(48); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.cpp index 43ae793f91c706c72f44a184cdbde251571a58bd..0aab7c5bc214fcf77986d220ad75708359977ac2 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.cpp @@ -326,7 +326,7 @@ bool ossimFormosatDimapSupportData::loadXmlFile(const ossimFilename& file) //--- // Check that it is a FORMOSAT DIMAP file format //--- - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; xml_nodes.clear(); ossimString xpath = "/Dimap_Document/Dataset_Sources/Source_Information/Scene_Source/MISSION"; xmlDocument->findNodes(xpath, xml_nodes); @@ -803,7 +803,7 @@ void ossimFormosatDimapSupportData::getGeoPosPoint (ossim_uint32 point, } } -void ossimFormosatDimapSupportData::printInfo(ostream& os) const +void ossimFormosatDimapSupportData::printInfo(std::ostream& os) const { ossimString corr_att = "NO"; if (theStarTrackerUsed) @@ -1522,7 +1522,7 @@ bool ossimFormosatDimapSupportData::parsePart1( static const char MODULE[] = "ossimFormosatDimapSupportData::parsePart1"; ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the ImageSize: @@ -2351,7 +2351,7 @@ bool ossimFormosatDimapSupportData::initMetadataVersion(ossimRefPtr<ossimXmlDocu { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath - << endl; + << std::endl; } return false; } @@ -2386,7 +2386,7 @@ bool ossimFormosatDimapSupportData::initImageId( ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the Image ID: @@ -2400,7 +2400,7 @@ bool ossimFormosatDimapSupportData::initImageId( { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath - << endl; + << std::endl; } return false; } @@ -2412,7 +2412,7 @@ bool ossimFormosatDimapSupportData::initSceneSource( ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the mission index (Formosat 1 or 2): @@ -2591,7 +2591,7 @@ bool ossimFormosatDimapSupportData::initFramePoints( ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Corner points: diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.h index c8146ba259b8a9cffa7387f5bf2fde426e6611a2..a63dfc7da6278429303a0f105e3602ef782927f8 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatDimapSupportData.h @@ -162,7 +162,7 @@ public: //--- // Convenient method to print important image info: //--- - void printInfo (ostream& os) const; + void printInfo (std::ostream& os) const; virtual bool saveState(ossimKeywordlist& kwl, const char* prefix = 0)const; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.cpp index c6aa8a24157333efa1d7d565ae4bc6b4007262e8..212fd1e5b3f76933705e7e58504a7a20d5d0cc7b 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.cpp @@ -472,8 +472,8 @@ std::ostream& ossimplugins::ossimFormosatModel::print(std::ostream& out) const // Capture stream flags since we are going to mess with them. std::ios_base::fmtflags f = out.flags(); - out << "\nDump of ossimFormosatModel at address " << (hex) << this - << (dec) + out << "\nDump of ossimFormosatModel at address " << (std::hex) << this + << (std::dec) << "\n------------------------------------------------" << "\n theImageID = " << theImageID << "\n theMetadataFile = " << theMetaDataFile @@ -495,7 +495,7 @@ std::ostream& ossimplugins::ossimFormosatModel::print(std::ostream& out) const << "\n theYawRate = " << theYawRate << "\n theFocalLenOffset = " << theFocalLenOffset << "\n------------------------------------------------" - << "\n " << endl; + << "\n " << std::endl; // Set the flags back. out.flags(f); @@ -596,14 +596,14 @@ void ossimplugins::ossimFormosatModel::imagingRay(const ossimDpt& image_point, { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\n\t Psi_x = " << Psi_x - << "\n\t Psi_y = " << Psi_y << endl; + << "\n\t Psi_y = " << Psi_y << std::endl; } ossimColumnVector3d u_sat (-tan(Psi_y), tan(Psi_x), -(1.0 + theFocalLenOffset)); if (traceDebug() || runtime_dbflag) { ossimNotify(ossimNotifyLevel_DEBUG) - << "DEBUG \n\t u_sat = " << u_sat << endl; + << "DEBUG \n\t u_sat = " << u_sat << std::endl; } // @@ -617,7 +617,7 @@ void ossimplugins::ossimFormosatModel::imagingRay(const ossimDpt& image_point, { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\n\t theSatToOrbRotation = " << satToOrbit - << "\n\t u_orb = " << u_orb << endl; + << "\n\t u_orb = " << u_orb << std::endl; } // @@ -648,7 +648,7 @@ void ossimplugins::ossimFormosatModel::imagingRay(const ossimDpt& image_point, { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\n\t orbToEcfRotation = " << orbToEcfRotation - << "\n\t u_ecf = " << u_ecf << endl; + << "\n\t u_ecf = " << u_ecf << std::endl; } // diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.h index e2b335345db7d5762efc4dbe49bb4ddeeb9a7fd1..d080c7524dd3c631ed0e6cf90f01c2d823205173 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimFormosatModel.h @@ -94,7 +94,7 @@ public: * Writes a template of geom keywords processed by loadState and saveState * to output stream. */ - static void writeGeomTemplate(ostream& os); + static void writeGeomTemplate(std::ostream& os); /*! * Given an image point and height, initializes worldPoint. diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.cpp index 5b1d2d08e13aaa840a92854f6b0b0c64c37adb58..73632e755f4910aca7b1aba7ef47c552c0db4986 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.cpp @@ -133,7 +133,7 @@ namespace ossimplugins return time; } - bool ossimGeometricSarSensorModel::getPlatformPositionAtLine(double line, vector<double>& position, vector<double>& speed) + bool ossimGeometricSarSensorModel::getPlatformPositionAtLine(double line, std::vector<double>& position, std::vector<double>& speed) { JSDDateTime time = getTime(line); return _platformPosition->getPlatformPositionAtTime(time,position,speed); @@ -532,13 +532,13 @@ namespace ossimplugins // if (result) // { // ossimNotify(ossimNotifyLevel_DEBUG) -// << "calling saveState to verify loadState..." << endl; +// << "calling saveState to verify loadState..." << std::endl; // ossimKeywordlist kwl2; // saveState(kwl2, 0); // ossimNotify(ossimNotifyLevel_DEBUG) -// << "saveState result after loadState:" << kwl2 << endl; +// << "saveState result after loadState:" << kwl2 << std::endl; // } if (traceDebug()) @@ -574,7 +574,7 @@ namespace ossimplugins std::ostream& ossimGeometricSarSensorModel::print(std::ostream& out) const { - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\nossimGeometricSarSensorModel class data members:\n"; const char* prefix = 0; @@ -631,7 +631,7 @@ bool ossimGeometricSarSensorModel::createReplacementOCG() if (traceDebug()) { - ossimNotify(ossimNotifyLevel_NOTICE)<<"\nComputing coarse grid..."<<endl; + ossimNotify(ossimNotifyLevel_NOTICE)<<"\nComputing coarse grid..."<<std::endl; } _replacementOcgModel->buildGrid(theImageClipRect, this, 500.00, true, false); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.h index 40f33c522a99623027be72c0394cdb7c419f4dfa..967b289e95c4d8949b33643e949fa7d37dcaa1f6 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimGeometricSarSensorModel.h @@ -118,7 +118,7 @@ public: * @param position Position of the sensor at line line * @param speed Speed of the sensor at line line */ - virtual bool getPlatformPositionAtLine(double line, vector<double>& position, vector<double>& speed); + virtual bool getPlatformPositionAtLine(double line, std::vector<double>& position, std::vector<double>& speed); /** * @brief This function is able to convert image coordinates into world diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp index aa0691d81010e5d1e0499884aff5e2056c6dfe8c..fe0de3e05b90e5fd53f43a85aef92196ec599683 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.cpp @@ -99,7 +99,7 @@ namespace ossimplugins ossimString xpath, ossimString& nodeValue) { - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; xmlDocument->findNodes(xpath, xml_nodes); if (xml_nodes.size() == 0) @@ -286,7 +286,7 @@ namespace ossimplugins theSwathLastCol = 0; } - void ossimPleiadesDimapSupportData::printInfo(ostream& os) const + void ossimPleiadesDimapSupportData::printInfo(std::ostream& os) const { os << "\n----------------- Info on Pleiades Image -------------------" @@ -1249,7 +1249,7 @@ namespace ossimplugins ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the Image ID: @@ -1292,7 +1292,7 @@ namespace ossimplugins ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Corner points: @@ -1574,7 +1574,7 @@ namespace ossimplugins { static const char MODULE[] = "ossimPleiadesDimapSupportData::parseRPCMetadata"; ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the Global RFM - Direct Model - Bias: @@ -1919,7 +1919,7 @@ namespace ossimplugins { // static const char MODULE[] = "ossimPleiadesDimapSupportData::parseMetadataIdentification"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; theXmlDocumentRoot = "/PHR_Dimap_Document"; @@ -1971,7 +1971,7 @@ namespace ossimplugins { // static const char MODULE[] = "ossimPleiadesDimapSupportData::parseMetadataIdentification"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; theXmlDocumentRoot = "/DIMAP_Document"; @@ -1990,7 +1990,7 @@ namespace ossimplugins theXmlDocumentRoot = "/PHR_DIMAP_Document"; if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the old root: " << theXmlDocumentRoot << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the old root: " << theXmlDocumentRoot << std::endl; } xml_nodes.clear(); @@ -2005,7 +2005,7 @@ namespace ossimplugins theXmlDocumentRoot = "/Dimap_Document"; if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the new root: " << theXmlDocumentRoot << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the new root: " << theXmlDocumentRoot << std::endl; } xml_nodes.clear(); @@ -2017,7 +2017,7 @@ namespace ossimplugins setErrorStatus(); if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath << std::endl; } return false; } @@ -2113,7 +2113,7 @@ namespace ossimplugins { // static const char MODULE[] = "ossimPleiadesDimapSupportData::parseProcessingInformation"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; //--- @@ -2156,7 +2156,7 @@ namespace ossimplugins bool ossimPleiadesDimapSupportData::parseRasterData(ossimRefPtr<ossimXmlDocument> xmlDocument) { static const char MODULE[] = "ossimPleiadesDimapSupportData::parseRasterData"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; //--- // Fetch if the product file is linked to one or many JP2 files: @@ -2471,7 +2471,7 @@ namespace ossimplugins bool ossimPleiadesDimapSupportData::parseGeometricData(ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; xml_nodes.clear(); if (theDIMAPVersion == OSSIM_PLEIADES_DIMAPv1) @@ -2760,7 +2760,7 @@ namespace ossimplugins { // static const char MODULE[] = "ossimPleiadesDimapSupportData::parseDatasetSources"; ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the mission index (1A or 1B) ? diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.h index 0eb9e3fb1c0ab7a31e8088f450d8055efb987f0b..a58259fe617cde9b5fa6530b54687d1fd5c4ec84 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesDimapSupportData.h @@ -82,7 +82,7 @@ namespace ossimplugins //--- // Convenient method to print important image info: //--- - void printInfo (ostream& os) const; + void printInfo (std::ostream& os) const; /** * Method to save the state of the object to a keyword list. diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesModel.cpp index 0515c186c6486272f7ac58b5befb6d6274a72359..de1148fcdbc42f78de5dddf01037d1a35e7429fd 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPleiadesModel.cpp @@ -107,8 +107,8 @@ namespace ossimplugins // Capture stream flags since we are going to mess with them. std::ios_base::fmtflags f = out.flags(); - out << "\nDump of ossimPleiadesModel at address " << (hex) << this - << (dec) + out << "\nDump of ossimPleiadesModel at address " << (std::hex) << this + << (std::dec) << "\n------------------------------------------------" << "\n theImageID = " << theImageID << "\n theImageSize = " << theImageSize @@ -116,7 +116,7 @@ namespace ossimplugins << "\n theRefImgPt = " << theRefImgPt << "\n theProcessingLevel = " << theSupportData->getProcessingLevel() << "\n------------------------------------------------" - << "\n " << endl; + << "\n " << std::endl; // Set the flags back. out.flags(f); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2Model.cpp index c004e4231222942d79431bc84b9db74a9f150f13..a1c313364f5568e6b3c0e63355646edcf551154f 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2Model.cpp @@ -115,7 +115,7 @@ double ossimRadarSat2Model::getSlantRangeFromGeoreferenced(double col) const << "\n(col-_refPoint->get_pix_col()) " << (col-_refPoint->get_pix_col()) << "\n_refPoint->get_pix_col() : " << _refPoint->get_pix_col() - << "\n relativeGroundRange : " << relativeGroundRange << endl; + << "\n relativeGroundRange : " << relativeGroundRange << std::endl; } int numSet = FindSRGRSetNumber((_refPoint->get_ephemeris())->get_date()) ; @@ -303,7 +303,7 @@ bool ossimRadarSat2Model::open(const ossimFilename& file) ossimNotify(ossimNotifyLevel_DEBUG) << "theImageClipRect : " << theImageClipRect << "ul, ur, lr, ll " << ul << ", " << ur - << ", " << lr << " , " << ll << endl; + << ", " << lr << " , " << ll << std::endl; } setGroundRect(ul, ur, lr, ll); // ossimSensorModel method. @@ -328,7 +328,7 @@ std::ostream& ossimRadarSat2Model::print(std::ostream& out) const // Capture the original flags. std::ios_base::fmtflags f = out.flags(); - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\nossimRadarSat2Model class data members:\n" << "_n_srgr: " << _n_srgr << "\n"; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2ProductDoc.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2ProductDoc.cpp index 6e857e58e801ce2f1cd66053ff65547c1552ace5..02a67f4d50d25f9d799f787af3939b69666727b7 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2ProductDoc.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSat2ProductDoc.cpp @@ -711,10 +711,10 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons double longitudeScale = 0; double heightScale = 0; - vector<double> lineNumeratorCoefficients = vector<double>(20,0); - vector<double> lineDenominatorCoefficients = vector<double>(20,0); - vector<double> pixelNumeratorCoefficients = vector<double>(20,0); - vector<double> pixelDenominatorCoefficients = vector<double>(20,0); + std::vector<double> lineNumeratorCoefficients = std::vector<double>(20,0); + std::vector<double> lineDenominatorCoefficients = std::vector<double>(20,0); + std::vector<double> pixelNumeratorCoefficients = std::vector<double>(20,0); + std::vector<double> pixelDenominatorCoefficients = std::vector<double>(20,0); //the final string outputs to the text file @@ -724,66 +724,66 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons if (rs2Check) { if (!ossim::getPath(searchbiasError, xdoc, biasErrorStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; biasError = biasErrorStr.toDouble(); if (!ossim::getPath(searchrandomError, xdoc, randomErrorStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; randomError = randomErrorStr.toDouble(); if (!ossim::getPath(searchlineFitQuality, xdoc, lineFitQualityStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; lineFitQuality = lineFitQualityStr.toDouble(); if (!ossim::getPath(searchpixelFitQuality, xdoc, pixelFitQualityStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; pixelFitQuality = pixelFitQualityStr.toDouble(); if (!ossim::getPath(searchlineOffset, xdoc, lineOffsetStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; lineOffset = lineOffsetStr.toDouble(); if (!ossim::getPath(searchpixelOffset, xdoc, pixelOffsetStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; pixelOffset = pixelOffsetStr.toDouble(); if (!ossim::getPath(searchlatitudeOffset, xdoc, latitudeOffsetStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; latitudeOffset = latitudeOffsetStr.toDouble(); if (!ossim::getPath(searchlongitudeOffset, xdoc, longitudeOffsetStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; longitudeOffset = longitudeOffsetStr.toDouble(); if (!ossim::getPath(searchheightOffset, xdoc, heightOffsetStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; heightOffset = heightOffsetStr.toDouble(); // -------------- if (!ossim::getPath(searchlineScale, xdoc, lineScaleStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; lineScale = lineScaleStr.toDouble(); if (!ossim::getPath(searchpixelScale, xdoc, pixelScaleStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; pixelScale = pixelScaleStr.toDouble(); if (!ossim::getPath(searchlatitudeScale, xdoc, latitudeScaleStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; latitudeScale = latitudeScaleStr.toDouble(); // ----------------------- if (!ossim::getPath(searchlongitudeScale, xdoc, longitudeScaleStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; longitudeScale = longitudeScaleStr.toDouble(); if (!ossim::getPath(searchheightScale, xdoc, heightScaleStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; heightScale = heightScaleStr.toDouble(); // ---- parameters for reading in coeefs ------------ @@ -794,7 +794,7 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons if (!ossim::getPath(searchlineNumeratorCoefficients, xdoc, lineNumeratorCoefficientsStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; string lineNumeratorCoefficientsStr_N = lineNumeratorCoefficientsStr[0]; @@ -810,7 +810,7 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons // ------------------ if (!ossim::getPath(searchlineDenominatorCoefficients, xdoc, lineDenominatorCoefficientsStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; string lineDenominatorCoefficientsStr_N = lineDenominatorCoefficientsStr[0]; @@ -827,7 +827,7 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons // ------------------ if (!ossim::getPath(searchpixelNumeratorCoefficients, xdoc, pixelNumeratorCoefficientsStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; string pixelNumeratorCoefficientsStr_N = pixelNumeratorCoefficientsStr[0]; @@ -843,7 +843,7 @@ RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) cons // ------------------ if (!ossim::getPath(searchpixelDenominatorCoefficients, xdoc, pixelDenominatorCoefficientsStr)) - ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl; + ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << std::endl; string pixelDenominatorCoefficientsStr_N = pixelDenominatorCoefficientsStr[0]; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSatModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSatModel.cpp index c859a162ecb694ae48b0fff4c5cf6595be8f305c..a8199355737f96100976c9f97d510312b7af12d1 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSatModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimRadarSatModel.cpp @@ -158,24 +158,24 @@ bool ossimRadarSatModel::open(const ossimFilename& file) ossimFilename dataFilePath; ossimFilename volumeDirectoryFilePath; std::string input_file = file; - string::size_type loc_DAT = input_file.find( "DAT_01", 0 ); - string::size_type loc_dat = input_file.find( "dat_01", 0 ); - if ( (loc_DAT != string::npos ) || ( loc_dat != string::npos ) ) + std::string::size_type loc_DAT = input_file.find( "DAT_01", 0 ); + std::string::size_type loc_dat = input_file.find( "dat_01", 0 ); + if ( (loc_DAT != std::string::npos ) || ( loc_dat != std::string::npos ) ) { dataFilePath = input_file.c_str(); - if (loc_DAT != string::npos ) input_file.replace(loc_DAT, 6, "VDF_DAT"); - if (loc_dat != string::npos ) input_file.replace(loc_dat, 6, "vdf_dat"); + if (loc_DAT != std::string::npos ) input_file.replace(loc_DAT, 6, "VDF_DAT"); + if (loc_dat != std::string::npos ) input_file.replace(loc_dat, 6, "vdf_dat"); volumeDirectoryFilePath = input_file.c_str(); } else { - string::size_type loc_VDF = input_file.find( "VDF_DAT", 0 ); - string::size_type loc_vdf = input_file.find( "vdf_dat", 0 ); - if ( (loc_VDF != string::npos ) || ( loc_vdf != string::npos ) ) + std::string::size_type loc_VDF = input_file.find( "VDF_DAT", 0 ); + std::string::size_type loc_vdf = input_file.find( "vdf_dat", 0 ); + if ( (loc_VDF != std::string::npos ) || ( loc_vdf != std::string::npos ) ) { volumeDirectoryFilePath = input_file.c_str(); - if (loc_VDF != string::npos ) input_file.replace(loc_VDF, 7, "DAT_01"); - if (loc_vdf != string::npos ) input_file.replace(loc_vdf, 7, "dat_01"); + if (loc_VDF != std::string::npos ) input_file.replace(loc_VDF, 7, "DAT_01"); + if (loc_vdf != std::string::npos ) input_file.replace(loc_vdf, 7, "dat_01"); dataFilePath = input_file.c_str(); } else @@ -224,7 +224,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) RadarSatRecordHeader headerVDF; VolumeDirFactory factoryVDF; - ifstream volumeDirFile (volumeDirectoryFilePath.c_str(), ios::in|ios::binary); + std::ifstream volumeDirFile (volumeDirectoryFilePath.c_str(), std::ios::in|std::ios::binary); volumeDirFile>>headerVDF; if(volumeDirFile.eof()) { @@ -269,7 +269,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) //Reading of the remaining of the volume directory file volumeDirFile.close(); - volumeDirFile.open(volumeDirectoryFilePath.c_str(), ios::in | ios::binary); + volumeDirFile.open(volumeDirectoryFilePath.c_str(), std::ios::in | std::ios::binary); volumeDirFile >> *_volumeDir; volumeDirFile.close(); @@ -280,7 +280,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) RadarSatRecordHeader headerDAT; DataFactory factoryDAT; - ifstream dataFile (dataFilePath.c_str(), ios::in|ios::binary); + std::ifstream dataFile (dataFilePath.c_str(), std::ios::in|std::ios::binary); dataFile>>headerDAT; if(dataFile.eof()) { @@ -302,7 +302,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) /* * Reading the remaining of the data file */ - dataFile.open(dataFilePath.c_str(), ios::in|ios::binary); + dataFile.open(dataFilePath.c_str(), std::ios::in|std::ios::binary); dataFile>>*_data; dataFile.close(); @@ -329,12 +329,12 @@ bool ossimRadarSatModel::open(const ossimFilename& file) * Warning : the filename case has to be homogenous */ std::string leader_file = dataFilePath; - string::size_type loc = leader_file.find( "DAT_01", 0 ); - if( loc != string::npos ) leader_file.replace(loc, 6, "LEA_01" ); // upper case test + std::string::size_type loc = leader_file.find( "DAT_01", 0 ); + if( loc != std::string::npos ) leader_file.replace(loc, 6, "LEA_01" ); // upper case test else { loc = leader_file.find( "dat_01", 0 ); - if( loc != string::npos ) leader_file.replace(loc, 6, "lea_01" ); // lower case test + if( loc != std::string::npos ) leader_file.replace(loc, 6, "lea_01" ); // lower case test else { ossimNotify(ossimNotifyLevel_DEBUG) << "File Name not coherent (searching for *DAT_01* or *dat_01*) : " << file << std::endl; @@ -355,7 +355,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) /* * Leader file data reading */ - ifstream leaderFile (leaderFilePath.c_str(), ios::in|ios::binary); + std::ifstream leaderFile (leaderFilePath.c_str(), std::ios::in|std::ios::binary); leaderFile>>*_leader; leaderFile.close(); if(traceDebug()) @@ -370,11 +370,11 @@ bool ossimRadarSatModel::open(const ossimFilename& file) */ std::string trailer_file = dataFilePath; loc = trailer_file.find( "DAT_01", 0 ); - if( loc != string::npos ) trailer_file.replace(loc, 6, "TRA_01" ); // upper case test + if( loc != std::string::npos ) trailer_file.replace(loc, 6, "TRA_01" ); // upper case test else { loc = trailer_file.find( "dat_01", 0 ); - if( loc != string::npos ) trailer_file.replace(loc, 6, "tra_01" ); // lower case test + if( loc != std::string::npos ) trailer_file.replace(loc, 6, "tra_01" ); // lower case test else { ossimNotify(ossimNotifyLevel_DEBUG) << "File Name not coherent (searching for *DAT_01* or *dat_01*) : " << file << std::endl; @@ -395,7 +395,7 @@ bool ossimRadarSatModel::open(const ossimFilename& file) /* * Trailer file data reading */ - ifstream trailerFile (trailerFilePath.c_str(), ios::in|ios::binary); + std::ifstream trailerFile (trailerFilePath.c_str(), std::ios::in|std::ios::binary); trailerFile>>*_trailer; trailerFile.close(); if(traceDebug()) diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp index 3832701fe39a34a17079a43d8ff1a38a85aa6877..caad19359c90da6c982376cfb2230887e9dfd28d 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -116,14 +116,14 @@ namespace ossimplugins // Capture stream flags since we are going to mess with them. std::ios_base::fmtflags f = out.flags(); - out << "\nDump of ossimSentinel1Model at address " << hex << this - << dec + out << "\nDump of ossimSentinel1Model at address " << std::hex << this + << std::dec << "\n------------------------------------------------" << "\n theImageID = " << theImageID << "\n theImageSize = " << theImageSize << "\n------------------------------------------------" - << "\n " << endl; + << "\n " << std::endl; // Set the flags back. out.flags(f); @@ -377,7 +377,7 @@ namespace ossimplugins const ossimString prefix = "support_data."; const ossimString xpath = "/xfdu:XFDU/dataObjectSection/dataObject"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; theManifestDoc->findNodes(xpath, xml_nodes); @@ -1264,9 +1264,9 @@ namespace ossimplugins double ossimSentinel1Model::getBandTerrainHeight(ossimXmlDocument const& productXmlDocument) { double heightSum = 0.0; - vector< ossimXmlNodePtr > heightList; + std::vector< ossimXmlNodePtr > heightList; productXmlDocument.findNodes("/product/generalAnnotation/terrainHeightList/terrainHeight", heightList); - vector<ossimXmlNodePtr >::const_iterator it = heightList.begin(); + std::vector<ossimXmlNodePtr >::const_iterator it = heightList.begin(); for ( ; it != heightList.end() ; ++it) { heightSum += getOptionalTextFromFirstNode(**it, "value").toFloat64(); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp deleted file mode 100644 index e7c46c34030de013816e6d164608d23d6979d250..0000000000000000000000000000000000000000 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (C) 2005-2019 by Centre National d'Etudes Spatiales (CNES) - * - * This file is licensed under MIT license: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#include <ossimSentinel1SarSensorModel.h> -#include <ossim/base/ossimXmlDocument.h> -#include "ossim/ossimXmlTools.h" - -namespace {// Anonymous namespace - const ossimString attAzimuthTime = "azimuthTime"; - const ossimString attFirstValidSample = "firstValidSample"; - const ossimString attLastValidSample = "lastValidSample"; - const ossimString attGr0 = "gr0"; - const ossimString attGrsrCoefficients = "grsrCoefficients"; - const ossimString attHeight = "height"; - const ossimString attLatitude = "latitude"; - const ossimString attLine = "line"; - const ossimString attLongitude = "longitude"; - const ossimString attPixel = "pixel"; - const ossimString attPosition = "position"; - const ossimString attSlantRangeTime = "slantRangeTime"; - const ossimString attSr0 = "sr0"; - const ossimString attSrgrCoefficients = "srgrCoefficients"; - const ossimString attTime = "time"; - const ossimString attVelocity = "velocity"; - const ossimString attX = "x"; - const ossimString attY = "y"; - const ossimString attZ = "z"; -}// Anonymous namespace - -#if defined(USE_BOOST_TIME) - using boost::posix_time::microseconds; - using boost::posix_time::seconds; -#else - using ossimplugins::time::microseconds; - using ossimplugins::time::seconds; -#endif -void ossimplugins::ossimSentinel1SarSensorModel::readCoordinates( - ossimXmlDocument const& xmlDoc, ossimString const& xpath, - ossimString const& rg0_xpath, ossimString const& coeffs_xpath, - std::vector<CoordinateConversionRecordType> & outputRecords) -{ - std::vector<ossimRefPtr<ossimXmlNode> > xnodes; - xmlDoc.findNodes(xpath, xnodes); - - for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) - { - CoordinateConversionRecordType coordRecord; - - coordRecord.azimuthTime = getTimeFromFirstNode(**itNode, attAzimuthTime); - - coordRecord.rg0 = getDoubleFromFirstNode(**itNode, rg0_xpath);; - - ossimString const& s = getTextFromFirstNode(**itNode, coeffs_xpath); - std::vector<ossimString> ssplit = s.split(" "); - - if (ssplit.empty()) - { - throw std::runtime_error(("The "+rg0_xpath+" record has an empty coef vector").string()); - } - for (std::vector<ossimString>::const_iterator cIt = ssplit.begin(), e = ssplit.end() - ; cIt != e - ; ++cIt - ) - { - coordRecord.coefs.push_back(cIt->toDouble()); - } - assert(!coordRecord.coefs.empty()&&"The rg0 record has empty coefs vector."); - - outputRecords.push_back(coordRecord); - } -} - -namespace ossimplugins -{ -void ossimSentinel1SarSensorModel::readAnnotationFile(const std::string & annotationXml) -{ - ossimRefPtr<ossimXmlDocument> xmlDoc = new ossimXmlDocument(annotationXml); - const ossimXmlNode & xmlRoot = *xmlDoc->getRoot(); - - //Parse specific metadata for Sentinel1 - //TODO add as members to the Sentinel1SarSensorModel - const std::string & product_type = getTextFromFirstNode(xmlRoot, "adsHeader/productType"); - const std::string & mode = getTextFromFirstNode(xmlRoot, "adsHeader/mode"); - const std::string & swath = getTextFromFirstNode(xmlRoot, "adsHeader/swath"); - const std::string & polarisation = getTextFromFirstNode(xmlRoot, "adsHeader/polarisation"); - - theProductType = ProductType(product_type); - - // First, lookup position/velocity records - std::vector<ossimRefPtr<ossimXmlNode> > xnodes; - xmlDoc->findNodes("/product/generalAnnotation/orbitList/orbit",xnodes); - - //TODO uncomment and adapt following code from s1_inverse to fill - //SarSensorModel structure - - for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) - { - OrbitRecordType orbitRecord; - - // Retrieve acquisition time - orbitRecord.azimuthTime = getTimeFromFirstNode(**itNode, attTime); - - // Retrieve ECEF position - ossimXmlNode const& positionNode = getExpectedFirstNode(**itNode, attPosition); - orbitRecord.position[0] = getDoubleFromFirstNode(positionNode, attX); - orbitRecord.position[1] = getDoubleFromFirstNode(positionNode, attY); - orbitRecord.position[2] = getDoubleFromFirstNode(positionNode, attZ); - - // Retrieve ECEF velocity - ossimXmlNode const& velocityNode = getExpectedFirstNode(**itNode, attVelocity); - orbitRecord.velocity[0] = getDoubleFromFirstNode(velocityNode, attX); - orbitRecord.velocity[1] = getDoubleFromFirstNode(velocityNode, attY); - orbitRecord.velocity[2] = getDoubleFromFirstNode(velocityNode, attZ); - - //Add one orbits record - theOrbitRecords.push_back(orbitRecord); - } - - //Parse the near range time (in seconds) - theNearRangeTime = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/slantRangeTime"); - - //Parse the range sampling rate - theRangeSamplingRate = getDoubleFromFirstNode(xmlRoot, "generalAnnotation/productInformation/rangeSamplingRate"); - - //Parse the range resolution - theRangeResolution = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/rangePixelSpacing"); - - //Parse the radar frequency - theRadarFrequency = getDoubleFromFirstNode(xmlRoot, "generalAnnotation/productInformation/radarFrequency"); - - //Parse azimuth time interval - const double azimuthTimeInterval = getDoubleFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/azimuthTimeInterval"); -#if defined(USE_BOOST_TIME) - theAzimuthTimeInterval = boost::posix_time::precise_duration(azimuthTimeInterval * 1000000.); -#else - theAzimuthTimeInterval = seconds(azimuthTimeInterval); -#endif - ossimNotify(ossimNotifyLevel_DEBUG) << "theAzimuthTimeInterval " << theAzimuthTimeInterval.total_microseconds() << "us\n"; - - - // Now read burst records as well - xnodes.clear(); - xmlDoc->findNodes("/product/swathTiming/burstList/burst",xnodes); - - if(xnodes.empty()) - { - BurstRecordType burstRecord; - - burstRecord.startLine = 0; - burstRecord.azimuthStartTime = getTimeFromFirstNode(xmlRoot,"imageAnnotation/imageInformation/productFirstLineUtcTime"); - - ossimNotify(ossimNotifyLevel_DEBUG)<< burstRecord.azimuthStartTime<<'\n'; - - burstRecord.azimuthStopTime = getTimeFromFirstNode(xmlRoot,"imageAnnotation/imageInformation/productLastLineUtcTime"); - burstRecord.endLine = getTextFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/numberOfLines").toUInt16()-1; - - burstRecord.startSample = 0; - burstRecord.endSample = getTextFromFirstNode(xmlRoot, "imageAnnotation/imageInformation/numberOfSamples").toUInt16()-1;; - - theBurstRecords.push_back(burstRecord); - } - else - { - const unsigned int linesPerBurst = xmlRoot.findFirstNode("swathTiming/linesPerBurst")->getText().toUInt16(); - const unsigned int samplesPerBurst = xmlRoot.findFirstNode("swathTiming/samplesPerBurst")->getText().toUInt16(); - - unsigned int burstId(0); - - for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode,++burstId) - { - BurstRecordType burstRecord; - - const ossimSarSensorModel::TimeType azTime = getTimeFromFirstNode(**itNode, attAzimuthTime); - - // Scan firstValidSample to define the first valid sample and valid lines - ossimString const& s = getTextFromFirstNode(**itNode, attFirstValidSample); - - long first_valid(0), last_valid(0); - bool begin_found(false), end_found(false); - long first_sample_valid(0), last_sample_valid(samplesPerBurst-1); - - std::vector<ossimString> ssp = s.split(" "); - - for (std::vector<ossimString>::const_iterator sIt = ssp.begin(), e = ssp.end() - ; sIt != e && !end_found - ; ++sIt - ) - { - // Find valid lines - if(!begin_found) - { - if(*sIt!="-1") - { - begin_found = true; - } - else - { - ++first_valid; - } - ++last_valid; - } - else - { - if(!end_found && *sIt=="-1") - { - end_found = true; - --last_valid; - } - else - { - ++last_valid; - } - } - - // Find first valid samples - if(*sIt!="-1") - { - int Fvs = samplesPerBurst; - try - { - Fvs = std::stoi(*sIt); - } - catch( ... ) - { - // Throw an execption - throw std::runtime_error("Failed to convert firstValidSample value."); - } - if (Fvs > first_sample_valid && Fvs < samplesPerBurst) - { - first_sample_valid = Fvs; - } - } - } - - // Scan lastValidSample to define the last valid sample - ossimString const& sLast = getTextFromFirstNode(**itNode, attLastValidSample); - std::vector<ossimString> sspLast = sLast.split(" "); - - for (auto const& token : sspLast) - { - // Last first valid samples - if(token != "-1") - { - int Lvs = 0; - try - { - Lvs = std::stoi(token); - } - catch( ... ) - { - // Throw an execption - throw std::runtime_error("Failed to convert lastValidSample value."); - } - - if (Lvs < last_sample_valid && Lvs > 0) - { - last_sample_valid = Lvs; - } - } - } - - burstRecord.startLine = burstId*linesPerBurst + first_valid; - burstRecord.endLine = burstId*linesPerBurst + last_valid; - - burstRecord.azimuthStartTime = azTime + (first_valid*theAzimuthTimeInterval); - burstRecord.azimuthStopTime = azTime + (last_valid*theAzimuthTimeInterval); - - burstRecord.startSample = first_sample_valid; - burstRecord.endSample = last_sample_valid; - - theBurstRecords.push_back(burstRecord); - } - } - - if(isGRD()) - { - readCoordinates(*xmlDoc, - "/product/coordinateConversion/coordinateConversionList/coordinateConversion", - attSr0, attSrgrCoefficients, - theSlantRangeToGroundRangeRecords); - - readCoordinates(*xmlDoc, - "/product/coordinateConversion/coordinateConversionList/coordinateConversion", - attGr0, attGrsrCoefficients, - theGroundRangeToSlantRangeRecords); - } - - xnodes.clear(); - xmlDoc->findNodes("/product/geolocationGrid/geolocationGridPointList/geolocationGridPoint",xnodes); - - for(std::vector<ossimRefPtr<ossimXmlNode> >::iterator itNode = xnodes.begin(); itNode!=xnodes.end();++itNode) - { - GCPRecordType gcpRecord; - - // Retrieve acquisition time - gcpRecord.azimuthTime = getTimeFromFirstNode(**itNode, attAzimuthTime); - - gcpRecord.slantRangeTime = getDoubleFromFirstNode(**itNode, attSlantRangeTime); - - gcpRecord.imPt.x = getDoubleFromFirstNode(**itNode, attPixel); - - // In TOPSAR products, GCPs are weird (they fall in black lines - // between burst. This code allows moving them to a valid area of - // the image. - if(theBurstRecords.size()>2) - { - ossimSarSensorModel::TimeType acqStart; - bool burstFound(false); - unsigned long acqStartLine(0); - - for(std::vector<BurstRecordType>::reverse_iterator bIt = theBurstRecords.rbegin();bIt!=theBurstRecords.rend() && !burstFound;++bIt) - { - if(gcpRecord.azimuthTime >= bIt->azimuthStartTime && gcpRecord.azimuthTime < bIt->azimuthStopTime) - { - burstFound = true; - acqStart = bIt->azimuthStartTime; - acqStartLine = bIt->startLine; - } - } - - if(!burstFound) - { - if(gcpRecord.azimuthTime < theBurstRecords.front().azimuthStartTime) - { - acqStart = theBurstRecords.front().azimuthStartTime; - acqStartLine = theBurstRecords.front().startLine; - } - else if (gcpRecord.azimuthTime >= theBurstRecords.front().azimuthStopTime) - { - acqStart = theBurstRecords.back().azimuthStartTime; - acqStartLine = theBurstRecords.back().startLine; - } - } - const DurationType timeSinceStart = gcpRecord.azimuthTime - acqStart; - - gcpRecord.imPt.y= timeSinceStart/theAzimuthTimeInterval + acqStartLine; - ossimNotify(ossimNotifyLevel_DEBUG) << "timeSinceStart: " << timeSinceStart << " = " << gcpRecord.azimuthTime << " - " << acqStart << " (azTime-acqStart)"<< "\n"; - ossimNotify(ossimNotifyLevel_DEBUG) << "imPt_y: " << gcpRecord.imPt.y << " = " << timeSinceStart.total_microseconds() << "/" << theAzimuthTimeInterval.total_microseconds() << "+" << acqStartLine << "\n"; - } - else - { - gcpRecord.imPt.y = getDoubleFromFirstNode(**itNode, attLine);; - } - ossimGpt geoPoint; - gcpRecord.worldPt.lat = getDoubleFromFirstNode(**itNode, attLatitude); - gcpRecord.worldPt.lon = getDoubleFromFirstNode(**itNode, attLongitude); - gcpRecord.worldPt.hgt = getDoubleFromFirstNode(**itNode, attHeight); - - theGCPRecords.push_back(gcpRecord); - } - - this->optimizeTimeOffsetsFromGcps(); -} - -} // namespace ossimplugins diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.h deleted file mode 100644 index ef1270a8259b5d84201834ace7ec927520358a4f..0000000000000000000000000000000000000000 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1SarSensorModel.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2005-2019 by Centre National d'Etudes Spatiales (CNES) - * - * This file is licensed under MIT license: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -#ifndef ossimSentinel1SarSensorModel_HEADER -#define ossimSentinel1SarSensorModel_HEADER - -#include <boost/config.hpp> -#include "ossim/ossimSarSensorModel.h" -#include <string> - -class ossimXmlDocument; -class ossimString; - -namespace ossimplugins -{ - -class OSSIM_PLUGINS_DLL ossimSentinel1SarSensorModel : public ossimSarSensorModel -{ -public: - -#if ! (defined(BOOST_NO_DEFAULTED_FUNCTIONS) || defined(BOOST_NO_CXX1_DEFAULTED_FUNCTIONS)) - /** Constructor */ - ossimSentinel1SarSensorModel()=default; - - /** Copy constructor */ - ossimSentinel1SarSensorModel(ossimSentinel1SarSensorModel const& m)=default; - /** Move constructor */ - ossimSentinel1SarSensorModel(ossimSentinel1SarSensorModel && m)=default; - - /** Destructor */ - virtual ~ossimSentinel1SarSensorModel()=default; -#endif - - void readAnnotationFile(const std::string & annotationXml); - -private: - void readCoordinates( - ossimXmlDocument const& xmlDoc, ossimString const& xpath, - ossimString const& rg0_xpath, ossimString const& coeffs_xpath, - std::vector<CoordinateConversionRecordType> & outputRecords - ); - - -protected: - /* - std::string theProductType; - std::string theMode; - std::string theSwath; - std::string thePolarisation; - */ -}; - -} // end namespace - -#endif diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp index 185f29d37c715f6ba75cb4d45dabcab0a01adb37..e8b44481840f91a0e753699ec9c39df62176a895 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.cpp @@ -99,7 +99,7 @@ namespace ossimplugins ossimString xpath, ossimString& nodeValue) { - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; xmlDocument->findNodes(xpath, xml_nodes); if (xml_nodes.size() == 0) @@ -269,7 +269,7 @@ namespace ossimplugins theSpecId = ""; } - void ossimSpot6DimapSupportData::printInfo(ostream& os) const + void ossimSpot6DimapSupportData::printInfo(std::ostream& os) const { os << "\n----------------- Info on Spot6 Image -------------------" @@ -1110,7 +1110,7 @@ namespace ossimplugins ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the Image ID: @@ -1139,7 +1139,7 @@ namespace ossimplugins ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Corner points: @@ -1401,7 +1401,7 @@ namespace ossimplugins { static const char MODULE[] = "ossimSpot6DimapSupportData::parseRPCMetadata"; ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the Global RFM - Direct Model - Bias: @@ -1612,7 +1612,7 @@ namespace ossimplugins { static const char MODULE[] = "ossimSpot6DimapSupportData::parseMetadataIdentification"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; theXmlDocumentRoot = "/DIMAP_Document"; @@ -1632,7 +1632,7 @@ namespace ossimplugins theXmlDocumentRoot = "/SPOT_DIMAP_Document"; if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the old root: " << theXmlDocumentRoot << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the old root: " << theXmlDocumentRoot << std::endl; } xml_nodes.clear(); @@ -1647,7 +1647,7 @@ namespace ossimplugins theXmlDocumentRoot = "/Dimap_Document"; if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the new root: " << theXmlDocumentRoot << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nTry to use the new root: " << theXmlDocumentRoot << std::endl; } xml_nodes.clear(); @@ -1659,7 +1659,7 @@ namespace ossimplugins setErrorStatus(); if (traceDebug()) { - ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath << endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:\nCould not find: " << xpath << std::endl; } return false; } @@ -1758,7 +1758,7 @@ namespace ossimplugins { static const char MODULE[] = "ossimSpot6DimapSupportData::parseProcessingInformation"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; //--- @@ -1787,7 +1787,7 @@ namespace ossimplugins bool ossimSpot6DimapSupportData::parseRasterData(ossimRefPtr<ossimXmlDocument> xmlDocument) { static const char MODULE[] = "ossimSpot6DimapSupportData::parseRasterData"; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; ossimString xpath, nodeValue; //--- // Fetch if the product file is linked to one or many JP2 files: @@ -2005,7 +2005,7 @@ namespace ossimplugins bool ossimSpot6DimapSupportData::parseGeometricData(ossimRefPtr<ossimXmlDocument> xmlDocument) { ossimString xpath; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; xml_nodes.clear(); xpath = "/Geometric_Data/Use_Area/Located_Geometric_Values"; //DIMAPv2 @@ -2125,7 +2125,7 @@ namespace ossimplugins { static const char MODULE[] = "ossimSpot6DimapSupportData::parseDatasetSources"; ossimString xpath, nodeValue; - vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + std::vector<ossimRefPtr<ossimXmlNode> > xml_nodes; //--- // Fetch the mission index (1A or 1B) ? diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.h index 1431d0d2053c92a4270240b556052388483ba8d2..f0860ce8e02ec984333ae3aba377a259a09c93f6 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6DimapSupportData.h @@ -81,7 +81,7 @@ namespace ossimplugins //--- // Convenient method to print important image info: //--- - void printInfo (ostream& os) const; + void printInfo (std::ostream& os) const; /** * Method to save the state of the object to a keyword list. diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6Model.cpp index ba5725b4ee465cf9303b53b6a47d8aff24858c43..76caf5a0c97357a5991b179228ab82b58f5ea6c7 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6Model.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSpot6Model.cpp @@ -107,8 +107,8 @@ namespace ossimplugins // Capture stream flags since we are going to mess with them. std::ios_base::fmtflags f = out.flags(); - out << "\nDump of ossimSpot6Model at address " << (hex) << this - << (dec) + out << "\nDump of ossimSpot6Model at address " << (std::hex) << this + << (std::dec) << "\n------------------------------------------------" << "\n theImageID = " << theImageID << "\n theImageSize = " << theImageSize @@ -116,7 +116,7 @@ namespace ossimplugins << "\n theRefImgPt = " << theRefImgPt << "\n theProcessingLevel = " << theSupportData->getProcessingLevel() << "\n------------------------------------------------" - << "\n " << endl; + << "\n " << std::endl; // Set the flags back. out.flags(f); diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp index 85896683028bc4a29f4e4a3d0ab8d828cfee64f3..215572c815b1a3ffe8f56b357d7b015f44197992 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.cpp @@ -856,7 +856,7 @@ std::ostream& ossimplugins::ossimTerraSarModel::print(std::ostream& out) const // Capture the original flags. std::ios_base::fmtflags f = out.flags(); - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\nossimTerraSarModelclass data members:\n" << SR_GR_R0_KW << _SrToGr_R0 << "\n"; @@ -1546,7 +1546,7 @@ bool ossimplugins::ossimTerraSarModel::initSensorParams(const ossimXmlDocument* if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) - << "result for tsDoc.initSensorParams " << result << endl; + << "result for tsDoc.initSensorParams " << result << std::endl; } if (!result) @@ -2436,7 +2436,7 @@ bool ossimplugins::ossimTerraSarModel::findTSXLeader(const ossimFilename& file, } -void ossimplugins::ossimTerraSarModel::printInfo(ostream& os) const +void ossimplugins::ossimTerraSarModel::printInfo(std::ostream& os) const { os << "\n----------------- General Info on TSX-1 Image -------------------" << "\n " diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.h index de847a3868071303f70899e7e14cd4f84487c6c0..46715aa3cb64552bc9c5722526daed694bdde4cf 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTerraSarModel.h @@ -118,7 +118,7 @@ namespace ossimplugins //--- // Convenient method to print important image info: //--- - void printInfo (ostream& os) const; + void printInfo (std::ostream& os) const; private: diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.cpp index 6d887e7f905344c18ed6f05513dc9baa4fed8100..f568252889aeeb34fd4d3a1464bf6a8f1a79b1d8 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.cpp @@ -184,7 +184,7 @@ namespace ossimplugins std::ostream& ossimTileMapModel::print(std::ostream& os) const { os << "\nDump of ossimTileMapModel object at " - << hex << this << ":\n" + << std::hex << this << ":\n" << "\nTileMapModel -- Dump of all data members: " << "\n theImageID: " << theImageID.chars() << "\n theImageSize: " << theImageSize @@ -193,7 +193,7 @@ namespace ossimplugins << "\n theGSD.line: " << theGSD.line << "\n theGSD.samp: " << theGSD.samp << "\n qDepth: " << qDepth - << endl; + << std::endl; return ossimSensorModel::print(os); } @@ -282,7 +282,7 @@ namespace ossimplugins // Writes a sample kwl to output stream. // //***************************************************************************** - void ossimTileMapModel::writeGeomTemplate(ostream& os) + void ossimTileMapModel::writeGeomTemplate(std::ostream& os) { if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimTileMapModel::writeGeomTemplate: entering..." << std::endl; @@ -290,7 +290,7 @@ namespace ossimplugins "//**************************************************************\n" "// Template for TileMap model keywordlist\n" "//**************************************************************\n" - << ossimKeywordNames::TYPE_KW << ": " << "ossimTileMapModel" << endl; + << ossimKeywordNames::TYPE_KW << ": " << "ossimTileMapModel" << std::endl; if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimTileMapModel::writeGeomTemplate: returning..." << std::endl; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.h index 33d9f30748c9eb85b090cf75fe1646e970ee390a..8d98e2e987e3ad75160730fff5affc6af5c2aa54 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimTileMapModel.h @@ -95,7 +95,7 @@ public: * Writes a template of geom keywords processed by loadState and saveState * to output stream. */ - static void writeGeomTemplate(ostream& os); + static void writeGeomTemplate(std::ostream& os); //*** // Overrides base class pure virtual. diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/IncidenceAngles.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/IncidenceAngles.cpp index 8dc860f17f33c06b1a34b24777af9e46c566106b..d030d025fe7d757cdb3675c48f22e1de6467b9a7 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/IncidenceAngles.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/IncidenceAngles.cpp @@ -148,7 +148,7 @@ bool IncidenceAngles::loadState(const ossimKeywordlist& kwl, const char* prefix) std::ostream& IncidenceAngles::print(std::ostream& out) const { - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\n IncidentAngles class data members:\n"; const char* prefix = 0; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/Noise.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/Noise.cpp index dfa8168b253687d44598826227bfe402eadf3c53..7b9ca1c5274ba71b7d16489f8aefa643754c5332 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/Noise.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/Noise.cpp @@ -149,7 +149,7 @@ bool Noise::loadState(const ossimKeywordlist& kwl, const char* prefix) std::ostream& Noise::print(std::ostream& out) const { - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\n Noise class data members:\n"; const char* prefix = 0; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/RadarSat2NoiseLevel.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/RadarSat2NoiseLevel.cpp index 2742fcdd785030bbb6f38ddfa6cf7df5d4360c00..f2f64cb48db94fa4ca8f7df80a9df7af8a141220 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/RadarSat2NoiseLevel.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/RadarSat2NoiseLevel.cpp @@ -313,7 +313,7 @@ bool RadarSat2NoiseLevel::loadState(const ossimKeywordlist& kwl, const char* pre std::ostream& RadarSat2NoiseLevel::print(std::ostream& out) const { - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\n RadarSat2NoiseLevel class data members:\n"; //const char* prefix = 0; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/SceneCoord.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/SceneCoord.cpp index 8eacd1c958dfe01ba7f0776b8bff018e6d249c70..1bbc15c7d6224a612c2e15c07200e32bfd0d181d 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/otb/SceneCoord.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/otb/SceneCoord.cpp @@ -152,7 +152,7 @@ bool SceneCoord::loadState(const ossimKeywordlist& kwl, const char* prefix) std::ostream& SceneCoord::print(std::ostream& out) const { - out << setprecision(15) << setiosflags(ios::fixed) + out << std::setprecision(15) << std::setiosflags(std::ios::fixed) << "\n SceneCoord class data members:\n"; const char* prefix = 0; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 6d857dfde441ad207bd449f3c0e88ac9a7b24a59..ab2ef3c0d3657d07c8b7bb9777bbbe77c7107399 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -152,72 +152,72 @@ public: /* Get the internal application parameter specified * if the follow flag is on, the function returns the target of proxy parameters * WARNING: this method may disappear from the API */ - Parameter* GetParameterByKey(std::string parameter, bool follow=true); + Parameter* GetParameterByKey(std::string const& parameter, bool follow=true); /* Get the internal application parameter specified * * WARNING: this method may disappear from the API */ - const Parameter* GetParameterByKey(std::string parameter, bool follow=true) const; + const Parameter* GetParameterByKey(std::string const& parameter, bool follow=true) const; /* Returns the description of a parameter */ - std::string GetParameterName(std::string paramKey); + std::string GetParameterName(std::string const& paramKey); /* Returns the description of a parameter */ - std::string GetParameterDescription(std::string paramKey); + std::string GetParameterDescription(std::string const& paramKey); /* Set the description of a parameter */ - void SetParameterDescription(std::string paramKey, std::string dec); + void SetParameterDescription(std::string const& paramKey, std::string dec); /* Enable the use of an optional parameter. Returns the previous state */ - void EnableParameter(std::string paramKey); + void EnableParameter(std::string const& paramKey); /* Disable the use of an optional parameter. Returns the previous state */ - void DisableParameter(std::string paramKey); + void DisableParameter(std::string const& paramKey); /* Return the enable state of an optional parameter */ - bool IsParameterEnabled(std::string paramKey, bool recurseParents = false) const; + bool IsParameterEnabled(std::string const& paramKey, bool recurseParents = false) const; /* Return true if the specified parameter is mandatory */ - bool IsMandatory(std::string paramKey) const; + bool IsMandatory(std::string const& paramKey) const; /* Return true if the specified parameter was set automatically in * the application */ - bool HasAutomaticValue(std::string paramKey) const; + bool HasAutomaticValue(std::string const& paramKey) const; /* Returns true if the parameter has an associated value provided externally * (not automatically computed by the application) */ - bool HasUserValue(std::string paramKey) const; + bool HasUserValue(std::string const& paramKey) const; /* If a user value was provided, clear it and update the other parameters */ - void ClearValue(std::string paramKey); + void ClearValue(std::string const& paramKey); /* Returns true if the parameter has an associated value. * This value can be an automatically computed value or default value, * or a value set externally by user */ - bool HasValue(std::string paramKey) const; + bool HasValue(std::string const& paramKey) const; /** Set HasUserValue flag of parameter with key paramKey * Note that when this function is called from DoInit, DoUpdateParameters * or DoExecute, it will always set this flag to false, because this is * the core behavior of the application. */ - void SetParameterUserValue(std::string paramKey, bool value); + void SetParameterUserValue(std::string const& paramKey, bool value); /* Return the user level of access to a parameter */ - UserLevel GetParameterUserLevel(std::string paramKey) const; + UserLevel GetParameterUserLevel(std::string const& paramKey) const; /** Get the role of the parameter */ - Role GetParameterRole(std::string paramKey) const; + Role GetParameterRole(std::string const& paramKey) const; /* Get the parameter type from its name */ - ParameterType GetParameterType(std::string paramKey) const; + ParameterType GetParameterType(std::string const& paramKey) const; /* Returns the description of a parameter */ - std::vector<std::string> GetChoiceKeys(std::string paramKey); + std::vector<std::string> GetChoiceKeys(std::string const& paramKey); /* Returns the description of a parameter */ - std::vector<std::string> GetChoiceNames(std::string paramKey); + std::vector<std::string> GetChoiceNames(std::string const& paramKey); /* Set an integer value * @@ -228,14 +228,14 @@ public: * \li ParameterType_Radius * \li ParameterType_Choice */ - void SetParameterInt(std::string parameter, int value, bool hasUserValueFlag = true); + void SetParameterInt(std::string const& parameter, int value, bool hasUserValueFlag = true); /* Set a floating value * * Can be called for types : * \li ParameterType_Float */ - void SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag = true); + void SetParameterFloat(std::string const& parameter, float value, bool hasUserValueFlag = true); /* Set a string value * @@ -246,7 +246,7 @@ public: * \li ParameterType_StringList * \li ParameterType_ListView */ - void SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag = true); + void SetParameterString(std::string const& parameter, std::string value, bool hasUserValueFlag = true); /* Set a string value * @@ -266,7 +266,7 @@ public: * \li ParameterType_OutputImageParameter * \li ParameterType_OutputVectorDataParameter */ - void SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag = true); + void SetParameterStringList(std::string const& parameter, std::vector<std::string> values, bool hasUserValueFlag = true); /** Checks if the application is ready to be executed. It checks that there * is no missing parameter @@ -294,7 +294,7 @@ public: * \li ParameterType_Radius * \li ParameterType_Choice */ - void SetDefaultParameterInt(std::string parameter, int value); + void SetDefaultParameterInt(std::string const& parameter, int value); /* Get the default integer value of a parameter * @@ -304,7 +304,7 @@ public: * \li ParameterType_Radius * \li ParameterType_Choice */ - int GetDefaultParameterInt(std::string parameter); + int GetDefaultParameterInt(std::string const& parameter); /* Set a default floating value, must be used in the * DoInit when setting a value by default @@ -313,28 +313,28 @@ public: * Can be called for types : * \li ParameterType_Float */ - void SetDefaultParameterFloat(std::string parameter, float value); + void SetDefaultParameterFloat(std::string const& parameter, float value); /* Get the default floating value of a parameter * * Can be called for types : * \li ParameterType_Float */ - float GetDefaultParameterFloat(std::string parameter); + float GetDefaultParameterFloat(std::string const& parameter); /** Set a default pixel type for an output image parameter * * \param[in] parameter Name of the output image parameter * \param[in] type Default pixel type */ - void SetDefaultOutputPixelType(std::string parameter, ImagePixelType type); + void SetDefaultOutputPixelType(std::string const& parameter, ImagePixelType type); /** Set a default complex pixel type for an output complex image parameter * * \param[in] parameter Name of the output complex image parameter * \param[in] type Default complex pixel type */ - void SetDefaultOutputComplexPixelType(std::string parameter, ComplexImagePixelType type); + void SetDefaultOutputComplexPixelType(std::string const& parameter, ComplexImagePixelType type); /* Set a minimum int value, must used in the * DoInit when setting a value by default @@ -343,7 +343,7 @@ public: * Can be called for types : * \li ParameterType_Int */ - void SetMinimumParameterIntValue(std::string parameter, int value); + void SetMinimumParameterIntValue(std::string const& parameter, int value); /* Set a maximum int value, must used in the * DoInit when setting a value by default @@ -352,7 +352,7 @@ public: * Can be called for types : * \li ParameterType_Int */ - void SetMaximumParameterIntValue(std::string parameter, int value); + void SetMaximumParameterIntValue(std::string const& parameter, int value); /* Set a minimum int value, must used in the * DoInit when setting a value by default @@ -361,7 +361,7 @@ public: * Can be called for types : * \li ParameterType_Float */ - void SetMinimumParameterFloatValue(std::string parameter, float value); + void SetMinimumParameterFloatValue(std::string const& parameter, float value); /* Set a maximum int value, must used in the * DoInit when setting a value by default @@ -370,7 +370,7 @@ public: * Can be called for types : * \li ParameterType_Float */ - void SetMaximumParameterFloatValue(std::string parameter, float value); + void SetMaximumParameterFloatValue(std::string const& parameter, float value); /** @@ -380,7 +380,7 @@ public: * Can be called for types: * \li ParameterType_ListView */ - void SetListViewSingleSelectionMode(std::string parameter, bool status); + void SetListViewSingleSelectionMode(std::string const& parameter, bool status); /** * True if the parameter is a list view and is in single selection mode @@ -395,21 +395,21 @@ public: * Can be called for types : * \li ParameterType_OutputImage */ - void SetParameterOutputImage(std::string parameter, FloatVectorImageType* value); + void SetParameterOutputImage(std::string const& parameter, FloatVectorImageType* value); /* Set the pixel type in which the image will be saved * * Can be called for types : * \li ParameterType_OutputImage */ - void SetParameterOutputImagePixelType(std::string parameter, ImagePixelType pixelType); + void SetParameterOutputImagePixelType(std::string const& parameter, ImagePixelType pixelType); /* Set an output vector data value * * Can be called for types : * \li ParameterType_OutputVectorData */ - void SetParameterOutputVectorData(std::string parameter, VectorDataType* value); + void SetParameterOutputVectorData(std::string const& parameter, VectorDataType* value); /* Get an integer parameter value * @@ -420,14 +420,14 @@ public: * \li ParameterType_Radius * \li ParameterType_Choice */ - int GetParameterInt(std::string parameter); + int GetParameterInt(std::string const& parameter) const; /* Get a floating parameter value * * Can be called for types : * \li ParameterType_Float */ - float GetParameterFloat(std::string parameter); + float GetParameterFloat(std::string const& parameter) const; /* Get a string parameter value * @@ -441,7 +441,7 @@ public: * \li ParameterType_OutputImage * \li ParameterType_OutputVectorData */ - std::string GetParameterString(std::string parameter); + std::string GetParameterString(std::string const& parameter) const; /* Get a string list parameter value * @@ -470,7 +470,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageParameter */ - void SetParameterInputImage(std::string parameter, ImageBaseType * inputImage); + void SetParameterInputImage(std::string const& parameter, ImageBaseType * inputImage); /** * Get the output image parameter as an ImageBase * instead @@ -481,7 +481,7 @@ public: * \throw itk::Exception if parameter is not found or not an * OutputImageParameter */ - ImageBaseType * GetParameterOutputImage(std::string parameter); + ImageBaseType * GetParameterOutputImage(std::string const& parameter); /** * Add an image to an InputImageList parameter as an ImageBase @@ -492,7 +492,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter */ - void AddImageToParameterInputImageList(std::string parameter, ImageBaseType * img); + void AddImageToParameterInputImageList(std::string const& parameter, ImageBaseType * img); /** * Set the nth image of an InputImageList parameter as an ImageBase pointer @@ -504,7 +504,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter or if id is out of bounds */ - void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, ImageBaseType * img); + void SetNthParameterInputImageList(std::string const& parameter, const unsigned int &id, ImageBaseType * img); /** * Add a value to a parameter list as a string @@ -517,7 +517,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter */ - void AddParameterStringList(std::string parameter, const std::string & str); + void AddParameterStringList(std::string const& parameter, const std::string & str); /** * Set the nth value of a parameter list as a string. @@ -531,7 +531,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter or if id is out of bounds */ - void SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string& str); + void SetNthParameterStringList(std::string const& parameter, const unsigned int &id, const std::string& str); /** @@ -541,7 +541,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter */ - void ClearParameterInputImageList(std::string parameter); + void ClearParameterInputImageList(std::string const& parameter); /** * Get the number of images in an InputImageList parameter. @@ -550,7 +550,7 @@ public: * \throw itk::Exception if parameter is not found or not an * InputImageList parameter */ - unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); + unsigned int GetNumberOfElementsInParameterInputImageList(std::string const& parameter); /* Get an image value @@ -558,35 +558,35 @@ public: * Can be called for types : * \li ParameterType_InputImage */ - FloatVectorImageType* GetParameterImage(std::string parameter); - - UInt8ImageType * GetParameterUInt8Image(std::string); - UInt16ImageType * GetParameterUInt16Image(std::string); - Int16ImageType * GetParameterInt16Image(std::string); - UInt32ImageType * GetParameterUInt32Image(std::string); - Int32ImageType * GetParameterInt32Image(std::string); - FloatImageType * GetParameterFloatImage(std::string); - DoubleImageType * GetParameterDoubleImage(std::string); - UInt8VectorImageType * GetParameterUInt8VectorImage(std::string); - UInt16VectorImageType * GetParameterUInt16VectorImage(std::string); - Int16VectorImageType * GetParameterInt16VectorImage(std::string); - UInt32VectorImageType * GetParameterUInt32VectorImage(std::string); - Int32VectorImageType * GetParameterInt32VectorImage(std::string); - FloatVectorImageType * GetParameterFloatVectorImage(std::string); - DoubleVectorImageType * GetParameterDoubleVectorImage(std::string); - UInt8RGBImageType * GetParameterUInt8RGBImage(std::string); - UInt8RGBAImageType * GetParameterUInt8RGBAImage(std::string); + FloatVectorImageType* GetParameterImage(std::string const& parameter); + + UInt8ImageType * GetParameterUInt8Image(std::string const&); + UInt16ImageType * GetParameterUInt16Image(std::string const&); + Int16ImageType * GetParameterInt16Image(std::string const&); + UInt32ImageType * GetParameterUInt32Image(std::string const&); + Int32ImageType * GetParameterInt32Image(std::string const&); + FloatImageType * GetParameterFloatImage(std::string const&); + DoubleImageType * GetParameterDoubleImage(std::string const&); + UInt8VectorImageType * GetParameterUInt8VectorImage(std::string const&); + UInt16VectorImageType * GetParameterUInt16VectorImage(std::string const&); + Int16VectorImageType * GetParameterInt16VectorImage(std::string const&); + UInt32VectorImageType * GetParameterUInt32VectorImage(std::string const&); + Int32VectorImageType * GetParameterInt32VectorImage(std::string const&); + FloatVectorImageType * GetParameterFloatVectorImage(std::string const&); + DoubleVectorImageType * GetParameterDoubleVectorImage(std::string const&); + UInt8RGBImageType * GetParameterUInt8RGBImage(std::string const&); + UInt8RGBAImageType * GetParameterUInt8RGBAImage(std::string const&); // Complex image - ComplexInt16ImageType * GetParameterComplexInt16Image(std::string); - ComplexInt32ImageType * GetParameterComplexInt32Image(std::string); - ComplexFloatImageType * GetParameterComplexFloatImage(std::string); - ComplexDoubleImageType * GetParameterComplexDoubleImage(std::string); + ComplexInt16ImageType * GetParameterComplexInt16Image(std::string const&); + ComplexInt32ImageType * GetParameterComplexInt32Image(std::string const&); + ComplexFloatImageType * GetParameterComplexFloatImage(std::string const&); + ComplexDoubleImageType * GetParameterComplexDoubleImage(std::string const&); - ComplexInt16VectorImageType * GetParameterComplexInt16VectorImage(std::string); - ComplexInt32VectorImageType * GetParameterComplexInt32VectorImage(std::string); - ComplexFloatVectorImageType * GetParameterComplexFloatVectorImage(std::string); - ComplexDoubleVectorImageType * GetParameterComplexDoubleVectorImage(std::string); + ComplexInt16VectorImageType * GetParameterComplexInt16VectorImage(std::string const&); + ComplexInt32VectorImageType * GetParameterComplexInt32VectorImage(std::string const&); + ComplexFloatVectorImageType * GetParameterComplexFloatVectorImage(std::string const&); + ComplexDoubleVectorImageType * GetParameterComplexDoubleVectorImage(std::string const&); /* Get an image list value @@ -594,7 +594,7 @@ public: * Can be called for types : * \li ParameterType_InputImageList */ - FloatVectorImageListType* GetParameterImageList(std::string parameter); + FloatVectorImageListType* GetParameterImageList(std::string const& parameter); /* GetParameterVectorData * @@ -602,7 +602,7 @@ public: * \li ParameterType_InputVectorData */ - VectorDataType* GetParameterVectorData(std::string parameter); + VectorDataType* GetParameterVectorData(std::string const& parameter); /* GetParameteVetorDataList * @@ -610,7 +610,7 @@ public: * \li ParameterType_InputVectorDatalist */ - VectorDataListType* GetParameterVectorDataList(std::string parameter); + VectorDataListType* GetParameterVectorDataList(std::string const& parameter); /* Get the parameter as a std::string * @@ -628,7 +628,7 @@ public: * \li ParameterType_OutputImage * \li ParameterType_OutputVectorData */ - std::string GetParameterAsString(std::string paramKey); + std::string GetParameterAsString(std::string const& paramKey); /* Get the list of all parameters */ @@ -639,7 +639,7 @@ public: * Can be called for types : * \li ParameterType_OutputImage */ - ImagePixelType GetParameterOutputImagePixelType(std::string parameter); + ImagePixelType GetParameterOutputImagePixelType(std::string const& parameter); void SetParameterList(ParameterGroup::Pointer paramGroup) { @@ -797,43 +797,43 @@ protected: void AddProcess(itk::ProcessObject* object, std::string description); /** Add a new choice value to an existing choice parameter */ - void AddChoice(std::string paramKey, std::string paramName); + void AddChoice(std::string const& paramKey, std::string const& paramName); /** Add a new parameter to the parameter group * the parent key of paramKey can be the path to a parameter group * or the path to a choice value */ - void AddParameter(ParameterType type, std::string paramKey, std::string paramName); + void AddParameter(ParameterType type, std::string const& paramKey, std::string const& paramName); /** Add a parameterRAM method with no parameter*/ - void AddRAMParameter(std::string paramKey="ram"); + void AddRAMParameter(std::string const& paramKey="ram"); /** Add a parameterRAM method with parameter*/ - void AddRAMParameter(std::string paramKey, std::string paramName, unsigned int defaultValue); + void AddRAMParameter(std::string const& paramKey, std::string const& paramName, unsigned int defaultValue); /** Add a parameterRAND method with no parameter*/ - void AddRANDParameter(std::string paramKey="rand"); + void AddRANDParameter(std::string const& paramKey="rand"); /** Add a parameterRAND method with parameter * by default seed initialization is based on time value*/ - void AddRANDParameter(std::string paramKey, std::string paramName, unsigned int defaultValue); + void AddRANDParameter(std::string const& paramKey, std::string const& paramName, unsigned int defaultValue); /** Remove the items added to the ListWidget */ - void ClearChoices(std::string key); + void ClearChoices(std::string const& key); /** Get Items selected in the ListView Parameter*/ - std::vector<int> GetSelectedItems(std::string paramKey); + std::vector<int> GetSelectedItems(std::string const& paramKey); /** Declare a parameter as mandatory */ - void MandatoryOn(std::string paramKey); + void MandatoryOn(std::string const& paramKey); /** Declare a parameter as NOT mandatory (default state) */ - void MandatoryOff(std::string paramKey); + void MandatoryOff(std::string const& paramKey); /* Set the user level of access to a parameter */ - void SetParameterUserLevel(std::string paramKey, UserLevel level); + void SetParameterUserLevel(std::string const& paramKey, UserLevel level); /* Set the parameter role (input/output) */ - void SetParameterRole(std::string paramKey, Role role); + void SetParameterRole(std::string const& paramKey, Role role); /* Get an image value * @@ -841,13 +841,13 @@ protected: * \li ParameterType_InputImage */ template <class TImageType> - TImageType* GetParameterImage(std::string parameter); + TImageType* GetParameterImage(std::string const& parameter); /** Declare a parameter as having an automatic value */ - void AutomaticValueOn(std::string paramKey); + void AutomaticValueOn(std::string const& paramKey); /** Declare a parameter as NOT having an automatic value */ - void AutomaticValueOff(std::string paramKey); + void AutomaticValueOff(std::string const& paramKey); /* Set an output image value * @@ -855,7 +855,7 @@ protected: * \li ParameterType_OutputImage */ template <class TImageType> - void SetParameterOutputImage(std::string parameter, TImageType* value); + void SetParameterOutputImage(std::string const& parameter, TImageType* value); private: /* Implement this method to add parameters */ @@ -937,77 +937,77 @@ namespace otb namespace Wrapper { -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8VectorImageType* Application::GetParameterImage<UInt8VectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE Int16VectorImageType* Application::GetParameterImage<Int16VectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt16VectorImageType* Application::GetParameterImage<UInt16VectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE Int32VectorImageType* Application::GetParameterImage<Int32VectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt32VectorImageType* Application::GetParameterImage<UInt32VectorImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8VectorImageType* Application::GetParameterImage<UInt8VectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE Int16VectorImageType* Application::GetParameterImage<Int16VectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt16VectorImageType* Application::GetParameterImage<UInt16VectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE Int32VectorImageType* Application::GetParameterImage<Int32VectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt32VectorImageType* Application::GetParameterImage<UInt32VectorImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE FloatVectorImageType* Application::GetParameterImage<FloatVectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE DoubleVectorImageType* Application::GetParameterImage<DoubleVectorImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE FloatVectorImageType* Application::GetParameterImage<FloatVectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE DoubleVectorImageType* Application::GetParameterImage<DoubleVectorImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt16VectorImageType* Application::GetParameterImage<ComplexInt16VectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt32VectorImageType* Application::GetParameterImage<ComplexInt32VectorImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt16VectorImageType* Application::GetParameterImage<ComplexInt16VectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt32VectorImageType* Application::GetParameterImage<ComplexInt32VectorImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexFloatVectorImageType* Application::GetParameterImage<ComplexFloatVectorImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexDoubleVectorImageType* Application::GetParameterImage<ComplexDoubleVectorImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexFloatVectorImageType* Application::GetParameterImage<ComplexFloatVectorImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexDoubleVectorImageType* Application::GetParameterImage<ComplexDoubleVectorImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8RGBImageType* Application::GetParameterImage<UInt8RGBImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8RGBAImageType* Application::GetParameterImage<UInt8RGBAImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8RGBImageType* Application::GetParameterImage<UInt8RGBImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8RGBAImageType* Application::GetParameterImage<UInt8RGBAImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8ImageType* Application::GetParameterImage<UInt8ImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE Int16ImageType* Application::GetParameterImage<Int16ImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt16ImageType* Application::GetParameterImage<UInt16ImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE Int32ImageType* Application::GetParameterImage<Int32ImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt32ImageType* Application::GetParameterImage<UInt32ImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt8ImageType* Application::GetParameterImage<UInt8ImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE Int16ImageType* Application::GetParameterImage<Int16ImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt16ImageType* Application::GetParameterImage<UInt16ImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE Int32ImageType* Application::GetParameterImage<Int32ImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE UInt32ImageType* Application::GetParameterImage<UInt32ImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE FloatImageType* Application::GetParameterImage<FloatImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE DoubleImageType* Application::GetParameterImage<DoubleImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE FloatImageType* Application::GetParameterImage<FloatImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE DoubleImageType* Application::GetParameterImage<DoubleImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt16ImageType* Application::GetParameterImage<ComplexInt16ImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt32ImageType* Application::GetParameterImage<ComplexInt32ImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt16ImageType* Application::GetParameterImage<ComplexInt16ImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexInt32ImageType* Application::GetParameterImage<ComplexInt32ImageType>(std::string const&); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexFloatImageType* Application::GetParameterImage<ComplexFloatImageType>(std::string); -extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexDoubleImageType* Application::GetParameterImage<ComplexDoubleImageType>(std::string); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexFloatImageType* Application::GetParameterImage<ComplexFloatImageType>(std::string const&); +extern template OTBApplicationEngine_EXPORT_TEMPLATE ComplexDoubleImageType* Application::GetParameterImage<ComplexDoubleImageType>(std::string const&); // -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8VectorImageType>(std::string, UInt8VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int16VectorImageType>(std::string, Int16VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt16VectorImageType>(std::string, UInt16VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int32VectorImageType>(std::string, Int32VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt32VectorImageType>(std::string, UInt32VectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8VectorImageType>(std::string const&, UInt8VectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int16VectorImageType>(std::string const&, Int16VectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt16VectorImageType>(std::string const&, UInt16VectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int32VectorImageType>(std::string const&, Int32VectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt32VectorImageType>(std::string const&, UInt32VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<FloatVectorImageType>(std::string, FloatVectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<DoubleVectorImageType>(std::string, DoubleVectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<FloatVectorImageType>(std::string const&, FloatVectorImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<DoubleVectorImageType>(std::string const&, DoubleVectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16VectorImageType>(std::string, +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16VectorImageType>(std::string const&, ComplexInt16VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32VectorImageType>(std::string, +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32VectorImageType>(std::string const&, ComplexInt32VectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatVectorImageType>(std::string, +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatVectorImageType>(std::string const&, ComplexFloatVectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleVectorImageType>(std::string, +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleVectorImageType>(std::string const&, ComplexDoubleVectorImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBImageType>(std::string, UInt8RGBImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBAImageType>(std::string, UInt8RGBAImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBImageType>(std::string const&, UInt8RGBImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBAImageType>(std::string const&, UInt8RGBAImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8ImageType>(std::string, UInt8ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int16ImageType>(std::string, Int16ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt16ImageType>(std::string, UInt16ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int32ImageType>(std::string, Int32ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt32ImageType>(std::string, UInt32ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt8ImageType>(std::string const&, UInt8ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int16ImageType>(std::string const&, Int16ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt16ImageType>(std::string const&, UInt16ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<Int32ImageType>(std::string const&, Int32ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<UInt32ImageType>(std::string const&, UInt32ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<FloatImageType>(std::string, FloatImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<DoubleImageType>(std::string, DoubleImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<FloatImageType>(std::string const&, FloatImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<DoubleImageType>(std::string const&, DoubleImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16ImageType>(std::string, ComplexInt16ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32ImageType>(std::string, ComplexInt32ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16ImageType>(std::string const&, ComplexInt16ImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32ImageType>(std::string const&, ComplexInt32ImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatImageType>(std::string, ComplexFloatImageType*); -extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleImageType>(std::string, ComplexDoubleImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatImageType>(std::string const&, ComplexFloatImageType*); +extern template OTBApplicationEngine_EXPORT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleImageType>(std::string const&, ComplexDoubleImageType*); } // namespace Wrapper } // namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.hxx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.hxx index 33330cd2418fa7c81e506806d6a43b3d9d583f23..104b4a99a5e682295aa3c17373ce2ac2f1d53404 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.hxx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.hxx @@ -36,7 +36,7 @@ namespace Wrapper template <class TImageType> TImageType* Application -::GetParameterImage(std::string parameter) +::GetParameterImage(std::string const& parameter) { typename TImageType::Pointer ret; @@ -57,7 +57,7 @@ Application template <class TImageType> void Application -::SetParameterOutputImage(std::string parameter, TImageType* value) +::SetParameterOutputImage(std::string const& parameter, TImageType* value) { Parameter* param = GetParameterByKey(parameter); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 9cdfa1e1d841dd1a4c2f8693b342bc3dd6c72c63..95f4f794430447c6697da6b9245973c7f515d1e8 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -75,77 +75,77 @@ namespace Wrapper { -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8VectorImageType* Application::GetParameterImage<UInt8VectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int16VectorImageType* Application::GetParameterImage<Int16VectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt16VectorImageType* Application::GetParameterImage<UInt16VectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int32VectorImageType* Application::GetParameterImage<Int32VectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt32VectorImageType* Application::GetParameterImage<UInt32VectorImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8VectorImageType* Application::GetParameterImage<UInt8VectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int16VectorImageType* Application::GetParameterImage<Int16VectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt16VectorImageType* Application::GetParameterImage<UInt16VectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int32VectorImageType* Application::GetParameterImage<Int32VectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt32VectorImageType* Application::GetParameterImage<UInt32VectorImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE FloatVectorImageType* Application::GetParameterImage<FloatVectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE DoubleVectorImageType* Application::GetParameterImage<DoubleVectorImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE FloatVectorImageType* Application::GetParameterImage<FloatVectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE DoubleVectorImageType* Application::GetParameterImage<DoubleVectorImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt16VectorImageType* Application::GetParameterImage<ComplexInt16VectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt32VectorImageType* Application::GetParameterImage<ComplexInt32VectorImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt16VectorImageType* Application::GetParameterImage<ComplexInt16VectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt32VectorImageType* Application::GetParameterImage<ComplexInt32VectorImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexFloatVectorImageType* Application::GetParameterImage<ComplexFloatVectorImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexDoubleVectorImageType* Application::GetParameterImage<ComplexDoubleVectorImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexFloatVectorImageType* Application::GetParameterImage<ComplexFloatVectorImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexDoubleVectorImageType* Application::GetParameterImage<ComplexDoubleVectorImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8RGBImageType* Application::GetParameterImage<UInt8RGBImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8RGBAImageType* Application::GetParameterImage<UInt8RGBAImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8RGBImageType* Application::GetParameterImage<UInt8RGBImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8RGBAImageType* Application::GetParameterImage<UInt8RGBAImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8ImageType* Application::GetParameterImage<UInt8ImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int16ImageType* Application::GetParameterImage<Int16ImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt16ImageType* Application::GetParameterImage<UInt16ImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int32ImageType* Application::GetParameterImage<Int32ImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt32ImageType* Application::GetParameterImage<UInt32ImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt8ImageType* Application::GetParameterImage<UInt8ImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int16ImageType* Application::GetParameterImage<Int16ImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt16ImageType* Application::GetParameterImage<UInt16ImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE Int32ImageType* Application::GetParameterImage<Int32ImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE UInt32ImageType* Application::GetParameterImage<UInt32ImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE FloatImageType* Application::GetParameterImage<FloatImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE DoubleImageType* Application::GetParameterImage<DoubleImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE FloatImageType* Application::GetParameterImage<FloatImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE DoubleImageType* Application::GetParameterImage<DoubleImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt16ImageType* Application::GetParameterImage<ComplexInt16ImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt32ImageType* Application::GetParameterImage<ComplexInt32ImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt16ImageType* Application::GetParameterImage<ComplexInt16ImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexInt32ImageType* Application::GetParameterImage<ComplexInt32ImageType>(std::string const&); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexFloatImageType* Application::GetParameterImage<ComplexFloatImageType>(std::string); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexDoubleImageType* Application::GetParameterImage<ComplexDoubleImageType>(std::string); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexFloatImageType* Application::GetParameterImage<ComplexFloatImageType>(std::string const&); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE ComplexDoubleImageType* Application::GetParameterImage<ComplexDoubleImageType>(std::string const&); // -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8VectorImageType>(std::string, UInt8VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int16VectorImageType>(std::string, Int16VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt16VectorImageType>(std::string, UInt16VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int32VectorImageType>(std::string, Int32VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt32VectorImageType>(std::string, UInt32VectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8VectorImageType>(std::string const&, UInt8VectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int16VectorImageType>(std::string const&, Int16VectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt16VectorImageType>(std::string const&, UInt16VectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int32VectorImageType>(std::string const&, Int32VectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt32VectorImageType>(std::string const&, UInt32VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<FloatVectorImageType>(std::string, FloatVectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<DoubleVectorImageType>(std::string, DoubleVectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<FloatVectorImageType>(std::string const&, FloatVectorImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<DoubleVectorImageType>(std::string const&, DoubleVectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16VectorImageType>(std::string, +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16VectorImageType>(std::string const&, ComplexInt16VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32VectorImageType>(std::string, +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32VectorImageType>(std::string const&, ComplexInt32VectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatVectorImageType>(std::string, +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatVectorImageType>(std::string const&, ComplexFloatVectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleVectorImageType>(std::string, +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleVectorImageType>(std::string const&, ComplexDoubleVectorImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBImageType>(std::string, UInt8RGBImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBAImageType>(std::string, UInt8RGBAImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBImageType>(std::string const&, UInt8RGBImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8RGBAImageType>(std::string const&, UInt8RGBAImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8ImageType>(std::string, UInt8ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int16ImageType>(std::string, Int16ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt16ImageType>(std::string, UInt16ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int32ImageType>(std::string, Int32ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt32ImageType>(std::string, UInt32ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt8ImageType>(std::string const&, UInt8ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int16ImageType>(std::string const&, Int16ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt16ImageType>(std::string const&, UInt16ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<Int32ImageType>(std::string const&, Int32ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<UInt32ImageType>(std::string const&, UInt32ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<FloatImageType>(std::string, FloatImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<DoubleImageType>(std::string, DoubleImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<FloatImageType>(std::string const&, FloatImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<DoubleImageType>(std::string const&, DoubleImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16ImageType>(std::string, ComplexInt16ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32ImageType>(std::string, ComplexInt32ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt16ImageType>(std::string const&, ComplexInt16ImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexInt32ImageType>(std::string const&, ComplexInt32ImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatImageType>(std::string, ComplexFloatImageType*); -template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleImageType>(std::string, ComplexDoubleImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexFloatImageType>(std::string const&, ComplexFloatImageType*); +template OTBApplicationEngine_EXPORT_EXPLICIT_TEMPLATE void Application::SetParameterOutputImage<ComplexDoubleImageType>(std::string const&, ComplexDoubleImageType*); void Application::SetName( const std::string & name ) @@ -383,36 +383,36 @@ ParameterGroup* Application::GetParameterList() return m_ParameterList; } -Parameter* Application::GetParameterByKey(std::string name, bool follow) +Parameter* Application::GetParameterByKey(std::string const& name, bool follow) { return GetParameterList()->GetParameterByKey(name, follow); } -void Application::SetParameterInt(std::string key, int value, bool hasUserValueFlag) +void Application::SetParameterInt(std::string const& key, int value, bool hasUserValueFlag) { GetParameterByKey(key)->FromInt(value); this->SetParameterUserValue(key, hasUserValueFlag); } -void Application::SetParameterFloat(std::string key, float value, bool hasUserValueFlag) +void Application::SetParameterFloat(std::string const& key, float value, bool hasUserValueFlag) { GetParameterByKey(key)->FromFloat(value); this->SetParameterUserValue(key, hasUserValueFlag); } -void Application::SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag) +void Application::SetParameterString(std::string const& parameter, std::string value, bool hasUserValueFlag) { GetParameterByKey(parameter)->FromString(value); this->SetParameterUserValue(parameter, hasUserValueFlag); } -void Application::SetParameterStringList(std::string key, std::vector<std::string> values, bool hasUserValueFlag) +void Application::SetParameterStringList(std::string const& key, std::vector<std::string> values, bool hasUserValueFlag) { GetParameterByKey(key)->FromStringList(values); this->SetParameterUserValue(key, hasUserValueFlag); } -void Application::SetParameterUserValue(std::string paramKey, bool value) +void Application::SetParameterUserValue(std::string const& paramKey, bool value) { /** UserValue is set/unset parameter must be active. Can't set the m_Active flg in Parameter::SetUserValue() instead of @@ -429,7 +429,7 @@ void Application::SetParameterUserValue(std::string paramKey, bool value) } } -const Parameter* Application::GetParameterByKey(std::string name, bool follow) const +const Parameter* Application::GetParameterByKey(std::string const& name, bool follow) const { // GetParameterList is non const... Application* _this = const_cast<Application*>(this); @@ -942,36 +942,36 @@ Application::Stop() } /* Enable the use of an optional parameter. Returns the previous state */ -void Application::EnableParameter(std::string paramKey) +void Application::EnableParameter(std::string const& paramKey) { Parameter* param = GetParameterByKey(paramKey); param->SetActive(true); } /* Disable the use of an optional parameter. Returns the previous state */ -void Application::DisableParameter(std::string paramKey) +void Application::DisableParameter(std::string const& paramKey) { GetParameterByKey(paramKey)->SetActive(false); } /* Return the enable state of an optional parameter */ -bool Application::IsParameterEnabled(std::string paramKey, bool recurseParents) const +bool Application::IsParameterEnabled(std::string const& paramKey, bool recurseParents) const { return GetParameterByKey(paramKey)->GetActive(recurseParents); } /* Return true if the specified parameter is mandatory */ -bool Application::IsMandatory(std::string paramKey) const +bool Application::IsMandatory(std::string const& paramKey) const { return GetParameterByKey(paramKey)->GetMandatory(); } -void Application::MandatoryOn(std::string paramKey) +void Application::MandatoryOn(std::string const& paramKey) { GetParameterByKey(paramKey)->SetMandatory(true); } -void Application::MandatoryOff(std::string paramKey) +void Application::MandatoryOff(std::string const& paramKey) { GetParameterByKey(paramKey)->SetMandatory(false); } @@ -979,30 +979,30 @@ void Application::MandatoryOff(std::string paramKey) /* Return true if the specified parameter was set automatically in the * application */ -bool Application::HasAutomaticValue(std::string paramKey) const +bool Application::HasAutomaticValue(std::string const& paramKey) const { return GetParameterByKey(paramKey)->GetAutomaticValue(); } -void Application::AutomaticValueOn(std::string paramKey) +void Application::AutomaticValueOn(std::string const& paramKey) { GetParameterByKey(paramKey)->SetAutomaticValue(true); } -void Application::AutomaticValueOff(std::string paramKey) +void Application::AutomaticValueOff(std::string const& paramKey) { GetParameterByKey(paramKey)->SetAutomaticValue(false); } /* Returns true if the parameter has an associated value provided externally * (not automatically computed by the application) */ -bool Application::HasUserValue(std::string paramKey) const +bool Application::HasUserValue(std::string const& paramKey) const { return GetParameterByKey(paramKey)->HasUserValue(); } /* If a user value was provided clear it and update the other parameters */ -void Application::ClearValue(std::string paramKey) +void Application::ClearValue(std::string const& paramKey) { GetParameterByKey(paramKey)->ClearValue(); } @@ -1010,37 +1010,37 @@ void Application::ClearValue(std::string paramKey) /* Returns true if the parameter has an associated value. * This value can be an automatically computed value or default value, * or a value set externally by user */ -bool Application::HasValue(std::string paramKey) const +bool Application::HasValue(std::string const& paramKey) const { return GetParameterByKey(paramKey)->HasValue(); } /* Return the user level of access to a parameter */ -UserLevel Application::GetParameterUserLevel(std::string paramKey) const +UserLevel Application::GetParameterUserLevel(std::string const& paramKey) const { return GetParameterByKey(paramKey)->GetUserLevel(); } /* Return the role (input/output) of a parameter */ -Role Application::GetParameterRole(std::string paramKey) const +Role Application::GetParameterRole(std::string const& paramKey) const { return GetParameterByKey(paramKey)->GetRole(); } /* Return the role (input/output) of a parameter */ -void Application::SetParameterRole(std::string paramKey, Role role) +void Application::SetParameterRole(std::string const& paramKey, Role role) { GetParameterByKey(paramKey)->SetRole(role); } /* Get the parameter type from its name */ -ParameterType Application::GetParameterType(std::string key) const +ParameterType Application::GetParameterType(std::string const& key) const { return GetParameterByKey(key)->GetType(); } -std::vector<std::string> Application::GetChoiceKeys(std::string name) +std::vector<std::string> Application::GetChoiceKeys(std::string const& name) { Parameter* param = GetParameterByKey(name); if (dynamic_cast<ChoiceParameter*>(param)) @@ -1056,7 +1056,7 @@ std::vector<std::string> Application::GetChoiceKeys(std::string name) itkExceptionMacro(<< name << " is not a choice parameter"); } -std::vector<std::string> Application::GetChoiceNames(std::string name) +std::vector<std::string> Application::GetChoiceNames(std::string const& name) { Parameter* param = GetParameterByKey(name); if (dynamic_cast<ChoiceParameter*>(param)) @@ -1073,7 +1073,7 @@ std::vector<std::string> Application::GetChoiceNames(std::string name) } -void Application::SetDefaultParameterInt(std::string parameter, int value) +void Application::SetDefaultParameterInt(std::string const& parameter, int value) { Parameter* param = GetParameterByKey(parameter); bool hasUserValue = param->HasUserValue(); @@ -1104,7 +1104,7 @@ void Application::SetDefaultParameterInt(std::string parameter, int value) } } -int Application::GetDefaultParameterInt(std::string parameter) +int Application::GetDefaultParameterInt(std::string const& parameter) { Parameter* param = GetParameterByKey(parameter); int ret = 0 ; @@ -1135,7 +1135,7 @@ int Application::GetDefaultParameterInt(std::string parameter) return ret; } -void Application::SetDefaultParameterFloat(std::string key, float value) +void Application::SetDefaultParameterFloat(std::string const& key, float value) { auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); param->SetDefaultValue(value); @@ -1146,44 +1146,44 @@ void Application::SetDefaultParameterFloat(std::string key, float value) } } -float Application::GetDefaultParameterFloat(std::string key) +float Application::GetDefaultParameterFloat(std::string const& key) { auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); return param->GetDefaultValue(); } -void Application::SetDefaultOutputPixelType(std::string key, ImagePixelType type) +void Application::SetDefaultOutputPixelType(std::string const& key, ImagePixelType type) { auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); param->SetDefaultPixelType(type); param->SetPixelType(type); } -void Application::SetMinimumParameterIntValue(std::string key, int value) +void Application::SetMinimumParameterIntValue(std::string const& key, int value) { auto param = downcast_check<IntParameter>(GetParameterByKey(key)); param->SetMinimumValue(value); } -void Application::SetMaximumParameterIntValue(std::string key, int value) +void Application::SetMaximumParameterIntValue(std::string const& key, int value) { auto param = downcast_check<IntParameter>(GetParameterByKey(key)); param->SetMaximumValue(value); } -void Application::SetMinimumParameterFloatValue(std::string key, float value) +void Application::SetMinimumParameterFloatValue(std::string const& key, float value) { auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); param->SetMinimumValue(value); } -void Application::SetMaximumParameterFloatValue(std::string key, float value) +void Application::SetMaximumParameterFloatValue(std::string const& key, float value) { auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); param->SetMaximumValue(value); } -void Application::SetListViewSingleSelectionMode(std::string key, bool status) +void Application::SetListViewSingleSelectionMode(std::string const& key, bool status) { auto param = downcast_check<ListViewParameter>(GetParameterByKey(key)); param->SetSingleSelection(status); @@ -1195,56 +1195,56 @@ bool Application::GetListViewSingleSelectionMode(const std::string& key) return param->GetSingleSelection(); } -void Application::SetParameterOutputImage(std::string key, FloatVectorImageType* value) +void Application::SetParameterOutputImage(std::string const& key, FloatVectorImageType* value) { auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); param->SetValue(value); } -void Application::SetParameterOutputImagePixelType(std::string key, ImagePixelType pixelType) +void Application::SetParameterOutputImagePixelType(std::string const& key, ImagePixelType pixelType) { auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); param->SetPixelType(pixelType); } -void Application::SetParameterOutputVectorData(std::string key, VectorDataType* value) +void Application::SetParameterOutputVectorData(std::string const& key, VectorDataType* value) { auto param = downcast_check<OutputVectorDataParameter>(GetParameterByKey(key)); param->SetValue(value); } -std::string Application::GetParameterName(std::string parameter) +std::string Application::GetParameterName(std::string const& parameter) { // get the actual parameter, even if it is a proxy Parameter* param = GetParameterByKey(parameter,false); return param->GetName(); } -std::string Application::GetParameterDescription(std::string parameter) +std::string Application::GetParameterDescription(std::string const& parameter) { // get the actual parameter, even if it is a proxy Parameter* param = GetParameterByKey(parameter,false); return param->GetDescription(); } -void Application::SetParameterDescription(std::string parameter, std::string desc) +void Application::SetParameterDescription(std::string const& parameter, std::string desc) { // get the actual parameter, even if it is a proxy Parameter* param = GetParameterByKey(parameter,false); param->SetDescription(desc); } -int Application::GetParameterInt(std::string key) +int Application::GetParameterInt(std::string const& key) const { return GetParameterByKey(key)->ToInt(); } -float Application::GetParameterFloat(std::string key) +float Application::GetParameterFloat(std::string const& key) const { return GetParameterByKey(key)->ToFloat(); } -std::string Application::GetParameterString(std::string key) +std::string Application::GetParameterString(std::string const& key) const { return GetParameterByKey(key)->ToString(); } @@ -1254,113 +1254,113 @@ std::vector<std::string> Application::GetParameterStringList(const std::string& return GetParameterByKey(key)->ToStringList(); } -void Application::SetParameterInputImage(std::string key, ImageBaseType* inputImage) +void Application::SetParameterInputImage(std::string const& key, ImageBaseType* inputImage) { auto param = downcast_check<InputImageParameter>(GetParameterByKey(key)); param->SetImage(inputImage); } -ImageBaseType* Application::GetParameterOutputImage(std::string key) +ImageBaseType* Application::GetParameterOutputImage(std::string const& key) { auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); return param->GetValue(); } -void Application::AddImageToParameterInputImageList(std::string key, ImageBaseType* img) +void Application::AddImageToParameterInputImageList(std::string const& key, ImageBaseType* img) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); param->AddImage(img); } -void Application::SetNthParameterInputImageList(std::string key, const unsigned int& id, ImageBaseType* img) +void Application::SetNthParameterInputImageList(std::string const& key, const unsigned int& id, ImageBaseType* img) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); param->SetNthImage(id, img); } -void Application::AddParameterStringList(std::string key, const std::string& str) +void Application::AddParameterStringList(std::string const& key, const std::string& str) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); param->AddFromFileName(str); } -void Application::SetNthParameterStringList(std::string key, const unsigned int& id, const std::string& str) +void Application::SetNthParameterStringList(std::string const& key, const unsigned int& id, const std::string& str) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); param->SetNthFileName(id, str); } -void Application::ClearParameterInputImageList(std::string key) +void Application::ClearParameterInputImageList(std::string const& key) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); param->ClearValue(); } -unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::string key) +unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::string const& key) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); return param->Size(); } -FloatVectorImageType* Application::GetParameterImage(std::string parameter) +FloatVectorImageType* Application::GetParameterImage(std::string const& parameter) { return this->GetParameterImage<FloatVectorImageType>(parameter); } -FloatVectorImageListType* Application::GetParameterImageList(std::string key) +FloatVectorImageListType* Application::GetParameterImageList(std::string const& key) { auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); return param->GetImageList(); } -VectorDataType* Application::GetParameterVectorData(std::string key) +VectorDataType* Application::GetParameterVectorData(std::string const& key) { auto param = downcast_check<InputVectorDataParameter>(GetParameterByKey(key)); return param->GetVectorData(); } -VectorDataListType* Application::GetParameterVectorDataList(std::string key) +VectorDataListType* Application::GetParameterVectorDataList(std::string const& key) { auto param = downcast_check<InputVectorDataListParameter>(GetParameterByKey(key)); return param->GetVectorDataList(); } -std::string Application::GetParameterAsString(std::string key) +std::string Application::GetParameterAsString(std::string const& key) { return GetParameterString(key); } -ImagePixelType Application::GetParameterOutputImagePixelType(std::string key) +ImagePixelType Application::GetParameterOutputImagePixelType(std::string const& key) { auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); return param->GetPixelType(); } void -Application::AddChoice(std::string paramKey, std::string paramName) +Application::AddChoice(std::string const& paramKey, std::string const& paramName) { GetParameterList()->AddChoice(paramKey, paramName); } void -Application::ClearChoices(std::string paramKey) +Application::ClearChoices(std::string const& paramKey) { GetParameterList()->ClearChoices(paramKey); } std::vector<int> -Application::GetSelectedItems(std::string param) +Application::GetSelectedItems(std::string const& param) { return GetParameterList()->GetSelectedItems(param); } void -Application::AddParameter(ParameterType type, std::string paramKey, std::string paramName) +Application::AddParameter(ParameterType type, std::string const& paramKey, std::string const& paramName) { GetParameterList()->AddParameter(type, paramKey, paramName); } -void Application::AddRAMParameter(std::string paramKey, std::string paramName, unsigned int defaultValue) +void Application::AddRAMParameter(std::string const& paramKey, std::string const& paramName, unsigned int defaultValue) { GetParameterList()->AddParameter(ParameterType_RAM, paramKey, paramName); SetDefaultParameterInt(paramKey, defaultValue); @@ -1368,7 +1368,7 @@ void Application::AddRAMParameter(std::string paramKey, std::string paramName, u } // paramKey default value = ram -void Application::AddRAMParameter(std::string paramKey) +void Application::AddRAMParameter(std::string const& paramKey) { // Get the RAM Parameter from the configuration manager AddRAMParameter(paramKey, "Available RAM (MB)", otb::ConfigurationManager::GetMaxRAMHint()); @@ -1376,7 +1376,7 @@ void Application::AddRAMParameter(std::string paramKey) SetParameterDescription(paramKey, "Available memory for processing (in MB)."); } -void Application::AddRANDParameter(std::string paramKey, std::string paramName, unsigned int defaultValue) +void Application::AddRANDParameter(std::string const& paramKey, std::string const& paramName, unsigned int defaultValue) { GetParameterList()->AddParameter(ParameterType_Int, paramKey, paramName); SetDefaultParameterInt(paramKey, defaultValue); @@ -1384,7 +1384,7 @@ void Application::AddRANDParameter(std::string paramKey, std::string paramName, } // paramKey default value = rand -void Application::AddRANDParameter(std::string paramKey) +void Application::AddRANDParameter(std::string const& paramKey) { // Get the RAND Parameter from the configuration file @@ -1711,7 +1711,7 @@ Application::GetImageBasePixelType(const std::string & key, unsigned int idx) } #define otbGetParameterImageMacro( Image ) \ - Image##Type * Application::GetParameter##Image(std::string parameter) \ + Image##Type * Application::GetParameter##Image(std::string const& parameter) \ { \ Parameter* param = GetParameterByKey(parameter); \ InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); \ diff --git a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx index 609a8e658750f459382830d6c818eee13315ab2f..0f46c783e090d1572dc18de4987ad6782e489eb7 100644 --- a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx +++ b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) std::string output_file = module + ".txt"; std::string algs_txt = "algs.txt"; - if (argc > 3) + if ( argc > 3 ) { output_file = std::string(argv[3]) + module + ".txt"; algs_txt = std::string(argv[3]) + "algs.txt"; @@ -102,12 +102,12 @@ int main(int argc, char* argv[]) std::string output_parameter_name; bool hasRasterOutput = false; { - for (unsigned int i = 0; i < nbOfParam; i++) + for ( unsigned int i = 0; i < nbOfParam; i++ ) { - Parameter::Pointer param = appli->GetParameterByKey(appKeyList[i]); - if (param->GetMandatory()) + Parameter::Pointer param = appli->GetParameterByKey( appKeyList[i] ); + if ( param->GetMandatory() ) { - if (appli->GetParameterType(appKeyList[i]) == ParameterType_OutputImage) + if ( appli->GetParameterType( appKeyList[i] ) == ParameterType_OutputImage ) { output_parameter_name = appKeyList[i]; hasRasterOutput = true; @@ -116,15 +116,24 @@ int main(int argc, char* argv[]) } } - if(output_parameter_name.empty()) + if( output_parameter_name.empty() ) dFile << module << std::endl; else dFile << module << "|" << output_parameter_name << std::endl; dFile << appli->GetDescription() << std::endl; dFile << group << std::endl; + + /* + From here onwards each line appended to dFile is passed to QgsProcessingParameter* class constructor. + dFile is nothing but a csv (with a .txt) with "|" as delimiter character. + First field is the name of Qgis parameter class and rest of it are extracted as list and passed to class constructor. + Parsing and calling of paramater classes are done by python. + source available : qgis/python/plugins/processing/core/parameters.py + source code of qgis parameter is available at: qgis/src/core/processing/qgsprocessingparameters.cpp + */ - for (unsigned int i = 0; i < nbOfParam; i++) + for ( unsigned int i = 0; i < nbOfParam; i++ ) { const std::string name = appKeyList[i]; const Parameter::Pointer param = appli->GetParameterByKey(name); @@ -166,15 +175,14 @@ int main(int argc, char* argv[]) } #endif - bool isDestination = false; bool isEpsgCode = false; // use QgsProcessingParameterCrs if required. // TODO: do a regex on name to match ==epsg || *\.epsg.\* if ( name == "epsg" - || name == "map.epsg.code" - || name == "mapproj.epsg.code" - || name == "mode.epsg.code") + || name == "map.epsg.code" + || name == "mapproj.epsg.code" + || name == "mode.epsg.code" ) { qgis_type = "QgsProcessingParameterCrs"; isEpsgCode = true; @@ -183,9 +191,9 @@ int main(int argc, char* argv[]) dFile << qgis_type << "|" << name << "|" << description; std::string default_value = "None"; - if (type == ParameterType_Int) + if ( type == ParameterType_Int ) { - if (isEpsgCode) + if ( isEpsgCode ) { if (param->HasValue() && appli->GetParameterInt(name) < 1) default_value = "EPSG: " + appli->GetParameterAsString(name); @@ -198,43 +206,41 @@ int main(int argc, char* argv[]) default_value = param->HasValue() ? appli->GetParameterAsString(name): "0"; } } - else if (type == ParameterType_Float) + else if ( type == ParameterType_Float ) { dFile << "|QgsProcessingParameterNumber.Double"; default_value = param->HasValue() ? appli->GetParameterAsString(name): "0"; } - else if (type == ParameterType_Radius) + else if ( type == ParameterType_Radius ) { dFile << "|QgsProcessingParameterNumber.Integer"; default_value = param->HasValue() ? appli->GetParameterAsString(name): "0"; } - else if(type == ParameterType_InputFilename) + else if ( type == ParameterType_InputFilename ) { // TODO: if parameter InputFilename can give supported extensions // we can use it gitlab #1559 dFile << "|QgsProcessingParameterFile.File|None"; } - else if(type == ParameterType_Directory) + else if( type == ParameterType_Directory ) { dFile << "|QgsProcessingParameterFile.Folder|False"; } - else if (type == ParameterType_InputImageList) + else if ( type == ParameterType_InputImageList ) { dFile << "|3"; //QgsProcessing.TypeRaster } - else if (type == ParameterType_InputVectorDataList) + else if ( type == ParameterType_InputVectorDataList + || type == ParameterType_InputVectorData + || type == ParameterType_OutputVectorData ) { dFile << "|-1"; //QgsProcessing.TypeVectorAnyGeometry } - else if (type == ParameterType_InputVectorData) - { - dFile << "|-1"; //QgsProcessing.TypeVectorAnyGeometry - } - else if(type == ParameterType_InputFilenameList) + else if ( type == ParameterType_InputFilenameList ) { dFile << "|4"; //QgsProcessing.TypeFile" } - else if(type == ParameterType_String) + else if ( type == ParameterType_String ) { // Below line is interpreted in qgis processing as // 1. default_value = None @@ -253,10 +259,16 @@ int main(int argc, char* argv[]) // setting default_value this way is an exception for ParameterType_StringList and ParameterType_String default_value = "None|True"; } - else if (type == ParameterType_InputImage) + else if (type == ParameterType_InputImage || type == ParameterType_OutputImage) { // default is None and nothing to add to dFile } + else if (type == ParameterType_OutputFilename) + { + // fileFilter and defaultValue is None + // OTB does not have any implementation for file extension. + default_value = "None|None"; + } else if(type == ParameterType_ListView) { // default is None and nothing to add to dFile @@ -277,38 +289,27 @@ int main(int argc, char* argv[]) ChoiceParameter *cparam = dynamic_cast<ChoiceParameter*>(param.GetPointer()); default_value = std::to_string(cparam->GetValue()); } - else if(type == ParameterType_OutputVectorData || - type == ParameterType_OutputImage || - type == ParameterType_OutputFilename) - { - // No need for default_value, optional and extra fields in dFile. - // If parameter is a destination type. qgis_type|name|description is enough. - // So we simply set isDestination to true and skip to end to append a new line. - isDestination = true; - } else { std::cout << "ERROR: default_value is empty for '" << name << "' type='" << qgis_type << "'" << std::endl; return EXIT_FAILURE; } - if (!isDestination) + std::string optional; + if ( param->GetMandatory() ) { - std::string optional; - if (param->GetMandatory()) - { - // TODO: avoid workaround for stringlist types (fix appengine) - // type == ParameterType_StringList check is needed because: - // If parameter is mandatory it can have no value - // It is accepted in OTB that, string list could be generated dynamically - // qgis has no such option to handle dynamic values yet.. - // So mandatory parameters whose type is StringList is considered optional - optional = param->HasValue() || type == ParameterType_StringList ? "True" : "False"; - } - else - { - optional = "True"; - } + // TODO: avoid workaround for stringlist types (fix appengine) + // type == ParameterType_StringList check is needed because: + // If parameter is mandatory it can have no value + // It is accepted in OTB that, string list could be generated dynamically + // qgis has no such option to handle dynamic values yet.. + // So mandatory parameters whose type is StringList is considered optional + optional = param->HasValue() || type == ParameterType_StringList ? "True" : "False"; + } + else + { + optional = "True"; + } #if 0 std::cerr << name; std::cerr << " mandatory=" << param->GetMandatory(); @@ -316,8 +317,7 @@ int main(int argc, char* argv[]) std::cerr << " qgis_type=" << qgis_type; std::cerr << " optional=" << optional << std::endl; #endif - dFile << "|" << default_value << "|" << optional; - } + dFile << "|" << default_value << "|" << optional; dFile << std::endl; } diff --git a/Modules/Wrappers/SWIG/src/CMakeLists.txt b/Modules/Wrappers/SWIG/src/CMakeLists.txt index ebae699688ad14b987db947246cb24dd719da0fa..ec5b62ad216cedb687ede6461d1ab08e33ff4cca 100644 --- a/Modules/Wrappers/SWIG/src/CMakeLists.txt +++ b/Modules/Wrappers/SWIG/src/CMakeLists.txt @@ -18,18 +18,10 @@ # limitations under the License. # -if ( OTB_WRAP_PYTHON ) - include ( UseSWIGLocal ) - list(APPEND SWIG_EXTRA_DEPS - otbWrapperSWIGIncludes.h - itkBase.includes - ${CMAKE_CURRENT_SOURCE_DIR}/itkBase.i - ${CMAKE_CURRENT_SOURCE_DIR}/itkMacro.i - ) - include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ) -endif() +include(UseSWIG) +include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) # Python SWIG configuration if ( OTB_WRAP_PYTHON ) add_subdirectory(python) -endif() \ No newline at end of file +endif() diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index 3cf79c5d8991ba6e59eeb21ea75b39f6775b60f5..2f4139254868b91935628529664031ff5fff91e1 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -271,8 +271,10 @@ public: logger = self.GetLogger() logger.AddLogOutput(_libraryLogOutput.GetPointer()) + self.progressReportManager = ProgressReporterManager_New() + self.progressReportManager.SetLogOutputCallback(_libraryLogCallback) self.AddObserver(AddProcessToWatchEvent(), - _libraryProgressReportManager.GetAddProcessCommand() + self.progressReportManager.GetAddProcessCommand() ) } } @@ -605,146 +607,149 @@ class ApplicationProxy(object): %pythoncode { - def GetParameterTypeAsString(self, parameter_type): - return { - ParameterType_String : 'ParameterType_String', - ParameterType_InputFilename : 'ParameterType_InputFilename', - ParameterType_OutputImage : 'ParameterType_OutputImage', - ParameterType_OutputVectorData : 'ParameterType_OutputVectorData', - ParameterType_OutputFilename : 'ParameterType_OutputFilename', - ParameterType_Directory : 'ParameterType_Directory', - ParameterType_InputImage : 'ParameterType_InputImage', - ParameterType_InputVectorData : 'ParameterType_InputVectorData', - ParameterType_InputImageList : 'ParameterType_InputImageList', - ParameterType_InputVectorDataList : 'ParameterType_InputImageList', - ParameterType_InputFilenameList : 'ParameterType_InputFilenameList', - ParameterType_StringList : 'ParameterType_StringList', - ParameterType_ListView : 'ParameterType_ListView', - ParameterType_Int : 'ParameterType_Int', - ParameterType_Radius : 'ParameterType_Radius', - ParameterType_RAM : 'ParameterType_RAM', - ParameterType_Float : 'ParameterType_Float', - ParameterType_Choice : 'ParameterType_Choice', - ParameterType_Group : 'ParameterType_Group', - ParameterType_Bool : 'ParameterType_Bool' - }.get(parameter_type, 'ParameterType_UNKNOWN') - - def __str__(self): - s = self.GetName() - s += '\n' - s += self.GetDocLongDescription() - return s - - def SetParameters(self, dict_params): - for param_key, param_value in dict_params.items(): - self.SetParameterValue(param_key, param_value) - - def SetParameterValue(self, paramKey, value): - paramType = self.GetParameterType(paramKey) - if paramType in [ParameterType_RAM, - ParameterType_String, ParameterType_InputFilename, - ParameterType_OutputImage, ParameterType_OutputVectorData, - ParameterType_OutputFilename, - ParameterType_Directory, ParameterType_InputImage, - ParameterType_InputVectorData]: - return self.SetParameterString(paramKey, value) - elif paramType in [ParameterType_InputImageList, ParameterType_InputVectorDataList, - ParameterType_InputFilenameList, ParameterType_StringList, - ParameterType_ListView]: - return self.SetParameterStringList(paramKey, value) - elif paramType in [ParameterType_Int, ParameterType_Radius]: - return self.SetParameterInt(paramKey, value) - elif paramType in [ParameterType_Float]: - return self.SetParameterFloat(paramKey, value) - elif paramType in [ParameterType_Bool]: - return self.SetParameterString(paramKey, str(value) ) - elif paramType in [ParameterType_Group]: - return ApplicationProxy(self, paramKey) - elif paramType in [ParameterType_Choice]: - return ApplicationProxy(self, paramKey, value) - else: - print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) - return - - def GetParameters(self): - ret = {} - for key in self.GetParametersKeys(): - if self.HasValue(key) and self.IsParameterEnabled(key) and self.GetParameterRole(key) == 0: - ret[key] = self.GetParameterValue(key) - return ret - - def GetParameterValue(self, paramKey): - paramType = self.GetParameterType(paramKey) - if paramType in [ - ParameterType_String, ParameterType_InputFilename, - ParameterType_OutputImage, ParameterType_OutputVectorData, - ParameterType_OutputFilename, - ParameterType_Directory, ParameterType_InputImage, - ParameterType_InputVectorData]: - return self.GetParameterString(paramKey) - elif paramType in [ParameterType_InputImageList, ParameterType_InputVectorDataList, - ParameterType_InputFilenameList, ParameterType_StringList, - ParameterType_ListView]: - return self.GetParameterStringList(paramKey) - elif paramType in [ParameterType_Int, ParameterType_Radius, ParameterType_RAM]: - return self.GetParameterInt(paramKey) - elif paramType in [ParameterType_Float]: - return self.GetParameterFloat(paramKey) - elif paramType in [ParameterType_Bool]: - return bool(self.GetParameterInt(paramKey)) - elif paramType in [ParameterType_Group, ParameterType_Choice]: - return ApplicationProxy(self, paramKey) - else: - print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) - return None - - def __getattr__(self,name): - """ - __get_attribute__ is called whenever an instance request an attribute. - eg: App.SetParameterString(), App.GetName() .. - __getattr__ is only called if the attribute is not found by __get_attribute__ call - So we keep hide the GetParameter** calls within this method so that it seems like - an obivous call for users. App.IN , App.OUT , where 'in' and 'out' are - parameters in the 'otb application' with instance App - Since SWIG also uses this function, we have to copy their code before - using custom OTB behaviour - """ - if (name == "thisown"): - return self.this.own() - method = Application.__swig_getmethods__.get(name, None) - if method: - return method(self) - key_list = [k.upper() for k in self.GetParametersKeys(True)] - if name in key_list: - return self.GetParameterValue(name.lower()) - raise AttributeError("'%s' object has no attribute '%s'" % (Application.__name__, name)) - - def __setattr__(self, name, value): - """ - __setattr__ is called if the attribute requested is not found in the attribute list. - So these attributes are supposed to be 'key' of parameters used. Here we - keep hide the SetParameter** calls within this method so that it seems like - an obivous call for users. App.IN='my-input-file-name' , App.OUT='my-output-file-name'w - here 'in' and 'out' are parameters in the 'otb application' with instance App - Ofcourse, we don't blindly accept any attributes as python, we check them against - list of existing parameters for application with 'self.GetParametersKeys(True)' - Since SWIG also uses this function, we have to copy their code before - using custom OTB behaviour - """ - if (name == "thisown"): - return self.this.own(value) - if (name == "this"): - if type(value).__name__ == 'SwigPyObject': - self.__dict__[name] = value - return - method = Application.__swig_setmethods__.get(name, None) - if method: - return method(self, value) - key_list = [k.upper() for k in self.GetParametersKeys(True)] - if name in key_list: - self.SetParameterValue(name.lower(), value) - else: - raise AttributeError("You cannot add attributes to %s" % self) + def GetParameterTypeAsString(self, parameter_type): + return { + ParameterType_String : 'ParameterType_String', + ParameterType_InputFilename : 'ParameterType_InputFilename', + ParameterType_OutputImage : 'ParameterType_OutputImage', + ParameterType_OutputVectorData : 'ParameterType_OutputVectorData', + ParameterType_OutputFilename : 'ParameterType_OutputFilename', + ParameterType_Directory : 'ParameterType_Directory', + ParameterType_InputImage : 'ParameterType_InputImage', + ParameterType_InputVectorData : 'ParameterType_InputVectorData', + ParameterType_InputImageList : 'ParameterType_InputImageList', + ParameterType_InputVectorDataList : 'ParameterType_InputImageList', + ParameterType_InputFilenameList : 'ParameterType_InputFilenameList', + ParameterType_StringList : 'ParameterType_StringList', + ParameterType_ListView : 'ParameterType_ListView', + ParameterType_Int : 'ParameterType_Int', + ParameterType_Radius : 'ParameterType_Radius', + ParameterType_RAM : 'ParameterType_RAM', + ParameterType_Float : 'ParameterType_Float', + ParameterType_Choice : 'ParameterType_Choice', + ParameterType_Group : 'ParameterType_Group', + ParameterType_Bool : 'ParameterType_Bool' + }.get(parameter_type, 'ParameterType_UNKNOWN') + + def __str__(self): + s = self.GetName() + s += '\n' + s += self.GetDocLongDescription() + return s + + def SetParameters(self, dict_params): + for param_key, param_value in dict_params.items(): + self.SetParameterValue(param_key, param_value) + + def SetParameterValue(self, paramKey, value): + paramType = self.GetParameterType(paramKey) + if paramType in [ParameterType_RAM, + ParameterType_String, ParameterType_InputFilename, + ParameterType_OutputImage, ParameterType_OutputVectorData, + ParameterType_OutputFilename, + ParameterType_Directory, ParameterType_InputImage, + ParameterType_InputVectorData]: + return self.SetParameterString(paramKey, value) + elif paramType in [ParameterType_InputImageList, ParameterType_InputVectorDataList, + ParameterType_InputFilenameList, ParameterType_StringList, + ParameterType_ListView]: + return self.SetParameterStringList(paramKey, value) + elif paramType in [ParameterType_Int, ParameterType_Radius]: + return self.SetParameterInt(paramKey, value) + elif paramType in [ParameterType_Float]: + return self.SetParameterFloat(paramKey, value) + elif paramType in [ParameterType_Bool]: + return self.SetParameterString(paramKey, str(value) ) + elif paramType in [ParameterType_Group]: + return ApplicationProxy(self, paramKey) + elif paramType in [ParameterType_Choice]: + return ApplicationProxy(self, paramKey, value) + else: + print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) + return + + def GetParameters(self): + ret = {} + for key in self.GetParametersKeys(): + if self.HasValue(key) and self.IsParameterEnabled(key) and self.GetParameterRole(key) == 0: + ret[key] = self.GetParameterValue(key) + return ret + + def GetParameterValue(self, paramKey): + paramType = self.GetParameterType(paramKey) + if paramType in [ + ParameterType_String, ParameterType_InputFilename, + ParameterType_OutputImage, ParameterType_OutputVectorData, + ParameterType_OutputFilename, + ParameterType_Directory, ParameterType_InputImage, + ParameterType_InputVectorData]: + return self.GetParameterString(paramKey) + elif paramType in [ParameterType_InputImageList, ParameterType_InputVectorDataList, + ParameterType_InputFilenameList, ParameterType_StringList, + ParameterType_ListView]: + return self.GetParameterStringList(paramKey) + elif paramType in [ParameterType_Int, ParameterType_Radius, ParameterType_RAM]: + return self.GetParameterInt(paramKey) + elif paramType in [ParameterType_Float]: + return self.GetParameterFloat(paramKey) + elif paramType in [ParameterType_Bool]: + return bool(self.GetParameterInt(paramKey)) + elif paramType in [ParameterType_Group, ParameterType_Choice]: + return ApplicationProxy(self, paramKey) + else: + print ("Unsupported parameter type '%s' with key '%s'" %(self.GetParameterTypeAsString(paramType) ,paramKey)) + return None + + def __getattr__(self,name): + """ + __get_attribute__ is called whenever an instance request an attribute. + eg: App.SetParameterString(), App.GetName() .. + __getattr__ is only called if the attribute is not found by __get_attribute__ call + So we keep hide the GetParameter** calls within this method so that it seems like + an obivous call for users. App.IN , App.OUT , where 'in' and 'out' are + parameters in the 'otb application' with instance App + Since SWIG also uses this function, we have to copy their code before + using custom OTB behaviour + """ + if (name == "thisown"): + return self.this.own() + method = Application.__swig_getmethods__.get(name, None) + if method: + return method(self) + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if name in key_list: + return self.GetParameterValue(name.lower()) + raise AttributeError("'%s' object has no attribute '%s'" % (Application.__name__, name)) + + def __setattr__(self, name, value): + """ + __setattr__ is called if the attribute requested is not found in the attribute list. + So these attributes are supposed to be 'key' of parameters used. Here we + keep hide the SetParameter** calls within this method so that it seems like + an obivous call for users. App.IN='my-input-file-name' , App.OUT='my-output-file-name'w + here 'in' and 'out' are parameters in the 'otb application' with instance App + Ofcourse, we don't blindly accept any attributes as python, we check them against + list of existing parameters for application with 'self.GetParametersKeys(True)' + Since SWIG also uses this function, we have to copy their code before + using custom OTB behaviour + """ + if (name == "thisown"): + return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + if (name == "progressReportManager"): + super().__setattr__(name, value) + return + method = Application.__swig_setmethods__.get(name, None) + if method: + return method(self, value) + key_list = [k.upper() for k in self.GetParametersKeys(True)] + if name in key_list: + self.SetParameterValue(name.lower(), value) + else: + raise AttributeError("You cannot add attributes to %s" % self) } } diff --git a/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i b/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i index 748c8bfef4820b6bd9a04c6d19d8c57f61ca7a84..044942d56dfef11fef66bcc2d40fb5595097948d 100644 --- a/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i +++ b/Modules/Wrappers/SWIG/src/otbPythonLogOutput.i @@ -91,9 +91,7 @@ class ProgressReporterManager: public itkObject { public: /** Default constructor */ - static ProgressReporterManager_Pointer New(); - virtual void Delete(); void DeleteWatcherList(); void SetLogOutputCallback(otb::SwigPrintCallback* callback); itkCommand* GetAddProcessCommand(); @@ -109,14 +107,10 @@ DECLARE_REF_COUNT_CLASS( ProgressReporterManager ) %pythoncode { _libraryLogOutput = PythonLogOutput_New() _libraryLogCallback = PythonPrintCallback() - _libraryProgressReportManager = ProgressReporterManager_New() - + Logger.Instance().ResetOutputs() _libraryLogOutput.SetCallback(_libraryLogCallback) Logger.Instance().AddLogOutput(_libraryLogOutput.GetPointer()) - - _libraryProgressReportManager.SetLogOutputCallback(_libraryLogCallback) - } #endif diff --git a/Modules/Wrappers/SWIG/src/python/CMakeLists.txt b/Modules/Wrappers/SWIG/src/python/CMakeLists.txt index 6a7b288b5cb9ea944662a3fccaf88c4b1181be0c..de676f70272dadc3fd7b5678f675560cd89d437c 100644 --- a/Modules/Wrappers/SWIG/src/python/CMakeLists.txt +++ b/Modules/Wrappers/SWIG/src/python/CMakeLists.txt @@ -21,6 +21,14 @@ include_directories ( ${PYTHON_INCLUDE_DIR} ) include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}) set_source_files_properties ( ../otbApplication.i PROPERTIES CPLUSPLUS ON ) +# Get target name +set(extension_target _otbApplication) +if(POLICY CMP0078) + cmake_policy(GET CMP0078 swig_target_name_policy) + if (swig_target_name_policy STREQUAL "NEW") + set(extension_target otbApplication) + endif() +endif() # Run swig set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS}) if(NUMPY_FOUND) @@ -36,34 +44,35 @@ set(SWIG_MODULE_otbApplication_EXTRA_DEPS otbPythonLogOutput.h otbProgressReporterManager.h OTBApplicationEngine) -SWIG_add_module( otbApplication python ../otbApplication.i - otbApplicationPYTHON_wrap.cxx - itkPyCommand.cxx - ../python/otbPythonLogOutput.cxx - ../python/otbProgressReporterManager.cxx) -SWIG_link_libraries( otbApplication ${PYTHON_LIBRARIES} OTBApplicationEngine ) -set_target_properties(_otbApplication PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR}) +swig_add_library( otbApplication + LANGUAGE python + SOURCES ../otbApplication.i + itkPyCommand.cxx + otbPythonLogOutput.cxx + otbProgressReporterManager.cxx) +swig_link_libraries( otbApplication ${PYTHON_LIBRARIES} OTBApplicationEngine ) +set_target_properties(${extension_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR}) if(MSVC) - set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" ) + set_source_files_properties( ${CMAKE_SWIG_OUTDIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "/wd4005" ) else() - set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" ) + set_source_files_properties( ${CMAKE_SWIG_OUTDIR}/otbApplicationPYTHON_wrap.cxx COMPILE_FLAGS "-w" ) endif() # byte-compile the resulting python file add_custom_command( - TARGET _otbApplication + TARGET ${extension_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Byte-compiling otbApplication.py" COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/CMake/PythonCompile.py ${CMAKE_SWIG_OUTDIR}/otbApplication.py - DEPENDS _otbApplication + DEPENDS ${extension_target} ) -otb_module_target_label( _otbApplication ) +otb_module_target_label( ${extension_target} ) -install( TARGETS _otbApplication +install( TARGETS ${extension_target} DESTINATION ${OTB_INSTALL_PYTHON_DIR} COMPONENT RuntimeLibraries ) @@ -78,3 +87,20 @@ if(PYTHON_VERSION_STRING VERSION_LESS "3.2.0") else() # TODO : pyc file is in a subfolder. endif() + +configure_file(StandaloneWrapper.in CMakeLists.txt @ONLY) + +install( FILES ${CMAKE_SWIG_OUTDIR}/otbApplicationPYTHON_wrap.cxx + ${CMAKE_SWIG_OUTDIR}/otbApplicationPYTHON_wrap.h + itkPyCommand.cxx + itkPyCommand.h + otbPythonLogOutput.cxx + otbPythonLogOutput.h + otbSwigPrintCallback.h + otbProgressReporterManager.cxx + otbProgressReporterManager.h + ../itkBase.includes + ../otbWrapperSWIGIncludes.h + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt + DESTINATION ${OTB_INSTALL_DATA_DIR}/swig + COMPONENT Resources ) diff --git a/Modules/Wrappers/SWIG/src/python/StandaloneWrapper.in b/Modules/Wrappers/SWIG/src/python/StandaloneWrapper.in new file mode 100644 index 0000000000000000000000000000000000000000..a0b9e362917c8aa87c0552b3e8076bad27006385 --- /dev/null +++ b/Modules/Wrappers/SWIG/src/python/StandaloneWrapper.in @@ -0,0 +1,81 @@ +# +# Copyright (C) 2005-2019 CS Systemes d'Information (CS SI) +# +# 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. +# + +cmake_minimum_required(VERSION 3.10.1) +project(OTBPythonWrappers) + +if(POLICY CMP0072) + cmake_policy(SET CMP0072 NEW) +endif() + +get_filename_component(PKG_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}" PATH) +get_filename_component(PKG_PREFIX "${PKG_PREFIX}" PATH) +get_filename_component(PKG_PREFIX "${PKG_PREFIX}" PATH) + +find_package(OTB REQUIRED HINTS ${PKG_PREFIX}/@OTB_INSTALL_PACKAGE_DIR@) +list(APPEND CMAKE_MODULE_PATH ${OTB_CMAKE_DIR}) +include(${OTB_USE_FILE}) + +set ( Python_ADDITIONAL_VERSIONS "3;2" ) +set ( PythonInterp_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) +set ( PythonLibs_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) +find_package( PythonInterp ) +if ( OTB_WRAP_PYTHON AND ( ${PYTHON_VERSION_MAJOR} EQUAL 2 ) ) + message (WARNING "Python3 not found. There is no longer support of \ + wrapping in python2 in OTB, but it can still be used.") +endif() +# Now that we have a python version the addditional versions should only +# contain the version we have to get the corresponding libs +set (Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +find_package ( PythonLibs ) +include_directories(${PYTHON_INCLUDE_DIR}) + +find_package(Numpy) +if ( NUMPY_FOUND ) + include_directories(${NUMPY_INCLUDE_DIRS}) +else() + message( WARNING + "OTB wrappers will be done without support for NumPy (not found).") +endif() + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}") + +file(GLOB OTBPythonWrappers_SOURCES "*.cxx") + +# declare the python wrapper library +add_library(PythonWrapperLib MODULE ${OTBPythonWrappers_SOURCES}) +target_link_libraries(PythonWrapperLib ${PYTHON_LIBRARIES} OTBApplicationEngine) + +set_target_properties(PythonWrapperLib PROPERTIES + OUTPUT_NAME "_otbApplication" + NO_SONAME ON + PREFIX "") + +if(WIN32 AND NOT CYGWIN) + set_target_properties(PythonWrapperLib PROPERTIES SUFFIX ".pyd") +endif() + +if(NUMPY_FOUND) + add_definitions(-DOTB_SWIGNUMPY=1) +endif() + +install(TARGETS PythonWrapperLib + DESTINATION lib/python + COMPONENT RuntimeLibraries ) diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx index e3a6ac541739b337fea15b1597a186b559031042..ff53453bbeac70dbf42b17a5d8c091bbe0d1e55c 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx @@ -38,11 +38,6 @@ ProgressReporterManager::~ProgressReporterManager() void ProgressReporterManager::DeleteWatcherList() { - //Delete all stored progress reporter - for (auto watcher: m_WatcherList) - { - delete watcher; - } m_WatcherList.clear(); } @@ -52,9 +47,9 @@ void ProgressReporterManager::LinkWatchers(itk::Object* itkNotUsed(caller), cons { const Wrapper::AddProcessToWatchEvent* eventToWatch = dynamic_cast<const Wrapper::AddProcessToWatchEvent*>(&event); - auto watch = new WatcherType(eventToWatch->GetProcess(), eventToWatch->GetProcessDescription()); + auto watch = std::make_unique< WatcherType>(eventToWatch->GetProcess(), eventToWatch->GetProcessDescription()); watch->SetCallback(m_Callback); - m_WatcherList.push_back(watch); + m_WatcherList.push_back(std::move(watch)); } } } diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h index ec15926fd20ad0b91ac238f0fbc1b7e61b0e4c1b..59d0cafd26b5ad962290553f9f2d9d013dd5cbad 100644 --- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h +++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h @@ -27,6 +27,8 @@ #include "otbSwigPrintCallback.h" #include "otbStandardOneLineFilterWatcher.h" +#include <memory> + namespace otb { @@ -54,7 +56,7 @@ public: typedef StandardOneLineFilterWatcher<CallbackType> WatcherType; /** Filter watcher list type */ - typedef std::vector<WatcherType *> WatcherListType; + typedef std::vector<std::unique_ptr <WatcherType> > WatcherListType; /** Command Member */ typedef itk::MemberCommand<Self> AddProcessCommandType; diff --git a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt index 7b0bd59465dd896e922622afa59427da408eca88..968ec181ea4270726f16075ba05e2bcdedbb3d6b 100644 --- a/Modules/Wrappers/SWIG/test/python/CMakeLists.txt +++ b/Modules/Wrappers/SWIG/test/python/CMakeLists.txt @@ -19,7 +19,7 @@ # set(TEST_DRIVER otbTestDriver - --add-before-env PYTHONPATH $<TARGET_FILE_DIR:_otbApplication> + --add-before-env PYTHONPATH ${CMAKE_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR} --add-before-env OTB_APPLICATION_PATH $<TARGET_FILE_DIR:otbapp_Smoothing> ) if(WIN32) diff --git a/PSC.md b/PSC.md index c0692bf8d7c113c30ad624683153b2d4de44a74f..8e8d4d516bc722ebc91f9033742d26ddf9cff3bf 100644 --- a/PSC.md +++ b/PSC.md @@ -212,6 +212,7 @@ establishing a fully functioning PSC. PSC has now 4 members. **Name** | **Affiliation** | **Email** | **Role** | ----------------------------|------------------|----------------------------------|--------------------------------------------| +Agustin Lobo | ICTJA-CSIC | Agustin DOT Lobo AT ictja.csic.es| User perspective, documentation | Julien Radoux | UCLouvain | jradoux AT hotmail DOT com | User perpsective, documentation | Rémi Cresson | IRSTEA | cresson.r AT gmail DOT com | Release Manager for release 5.2 | Guillaume Pasero | CS-SI | guillaume.pasero AT c-s DOT fr | release planner | diff --git a/Packaging/Files/build_wrapping.cmake b/Packaging/Files/build_wrapping.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3cbce611896581e1ea533b6f342c14767a324650 --- /dev/null +++ b/Packaging/Files/build_wrapping.cmake @@ -0,0 +1,49 @@ +# +# Copyright (C) 2005-2019 CS Systemes d'Information (CS SI) +# +# 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. +# + +get_filename_component(PKG_PREFIX "${CTEST_SCRIPT_DIRECTORY}" PATH) +get_filename_component(PKG_PREFIX "${PKG_PREFIX}" PATH) +get_filename_component(PKG_PREFIX "${PKG_PREFIX}" PATH) + +set(CTEST_PROJECT_NAME OTBPythonWrappers) +set(CTEST_SOURCE_DIRECTORY ${CTEST_SCRIPT_DIRECTORY}) +set(CTEST_BINARY_DIRECTORY ${CTEST_SCRIPT_DIRECTORY}/build) +if(WIN32) + set(CTEST_CMAKE_GENERATOR "NMake Makefiles") +else() + set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +endif() +set(CTEST_BUILD_CONFIGURATION "Release") + +if(IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}") +endif() + +set(CONFIGURE_OPTIONS + "-DCMAKE_INSTALL_PREFIX=${PKG_PREFIX}" + "-DCMAKE_INSTALL_RPATH=${PKG_PREFIX}/lib" + "-DCMAKE_BUILD_TYPE=Release") +if(PYTHON_EXECUTABLE) + list(APPEND CONFIGURE_OPTIONS "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") +endif() + +ctest_start(Experimental) +ctest_configure(OPTIONS "${CONFIGURE_OPTIONS}") +ctest_build(TARGET install) diff --git a/Packaging/Files/build_wrapping.md b/Packaging/Files/build_wrapping.md new file mode 100644 index 0000000000000000000000000000000000000000..3fe735393fb39ccda30a6ccbd110135fe799244e --- /dev/null +++ b/Packaging/Files/build_wrapping.md @@ -0,0 +1,47 @@ +# How to recompile OTB Python bindings with your Python version? + +The OTB Python bindings are made of: + +* a Python module `otbApplication.py` +* a Python C++ extension `_otbApplication.so` (or `_otbApplication.pyd` on Windows) + +The Python module should be independent from the Python version you are using, +but the compiled C++ extension is linked to a specific Python library. If this +library is not present on your system, you can recompile the extension to use +your Python version. + +The procedure is simple, once you have the following prerequisite: + +* A C++ compiler: + * On Linux: GCC >= 5.0 + * On macos: XCode + * On Windows: either Visual Studio >= 2015 with the desktop C++ workload, + or just the MSVC Build Tools. +* CMake >= 3.10 +* Python library and headers for your Python version + * On macos and Windows: they are usually supplied with installers from + official website + * On Linux packages: you should look for a `python-dev` package matching + your Python interpreter version. +* Numpy module for your Python version + +The compilation and installation of the C++ extension can be launched from the +command line (on Windows you can use `cmd.exe`): + +``` +ctest -S build_wrapping.cmake +``` + +If you want to use a specific Python interpreter: + +``` +ctest -DPYTHON_EXECUTABLE=/my/own/python -S build_wrapping.cmake +``` + +Note: on Windows, you have to setup MSVC compiler before calling `ctest`. Use +the `vcvarsall.bat` script with the right architecture (x32 or x64). For +instance: + +``` +call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 +``` diff --git a/Packaging/Files/otbenv.bash b/Packaging/Files/otbenv.bash index 4102c5b50d73bc7cbfeae495d91f291320224226..a2a7906ca45cbfdcea25fedb6fddd59e993f9d3a 100644 --- a/Packaging/Files/otbenv.bash +++ b/Packaging/Files/otbenv.bash @@ -18,6 +18,22 @@ # limitations under the License. # +cat_path() +{ + if [ $# -eq 0 ]; then exit 0; fi + if [ $# -eq 1 ]; then echo "$1"; exit 0; fi + cur="$1" + shift 1 + next=$(cat_path "$@") + if [ -z "$cur" ]; then + echo "$next" + elif [ -z "$next" ]; then + echo "$cur" + else + echo "$cur:$next" + fi +} + # The below environment variables only affect current shell # So if you run again from a terminal. you need to run the script again # see how this is sourced in monteverdi.sh and mapla.sh @@ -26,11 +42,11 @@ CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P unset LD_LIBRARY_PATH -PATH=$CURRENT_DIR/bin:$PATH +PATH=$(cat_path "$CURRENT_DIR/bin" "$PATH") GDAL_DATA=$CURRENT_DIR/share/data GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv -PYTHONPATH=$CURRENT_DIR/lib/python:$PYTHONPATH -OTB_APPLICATION_PATH=$CURRENT_DIR/lib/otb/applications +PYTHONPATH=$(cat_path "$CURRENT_DIR/lib/python" "$PYTHONPATH") +OTB_APPLICATION_PATH=$(cat_path "$CURRENT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH") GDAL_DRIVER_PATH="disable" LC_NUMERIC=C diff --git a/Packaging/Files/otbenv.bat b/Packaging/Files/otbenv.bat index 615271ecd6104cf6e4bc70651ce2bd0aaeada606..6b4efefb227c0767592e1210f801f62212a7aded 100644 --- a/Packaging/Files/otbenv.bat +++ b/Packaging/Files/otbenv.bat @@ -16,15 +16,31 @@ :: 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. - +@echo off :: Setup environment for OTB package set CURRENT_SCRIPT_DIR=%~dp0 -set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH% +call :prefix_path PATH "%CURRENT_SCRIPT_DIR%bin" +call :prefix_path PYTHONPATH "%CURRENT_SCRIPT_DIR%lib\python" +call :prefix_path OTB_APPLICATION_PATH "%CURRENT_SCRIPT_DIR%lib\otb\applications" + set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\data set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv -set PYTHONPATH=%CURRENT_SCRIPT_DIR%lib\python;%PYTHONPATH% -set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications set GDAL_DRIVER_PATH=disable :: Set numeric locale to C set LC_NUMERIC=C +goto :eof + +:prefix_path +setlocal enabledelayedexpansion +set output=%~2 +set var=%1 +set content= +if not defined %var% ( goto :prefix_path_testcontent ) +set content=!%var%! +:prefix_path_testcontent +if "%content%" == "" ( goto :prefix_path_end ) +set output=%output%;%content% +:prefix_path_end +endlocal & set %1=%output% +goto :eof diff --git a/Packaging/Files/otbenv.profile b/Packaging/Files/otbenv.profile index 1e147d1c0528dbe4a16d99e76ac040989773aaf8..f46ab79bf77b65b795ca37d26e8b4c1d66c4bde3 100644 --- a/Packaging/Files/otbenv.profile +++ b/Packaging/Files/otbenv.profile @@ -19,6 +19,22 @@ # limitations under the License. # +cat_path() +{ + if [ $# -eq 0 ]; then exit 0; fi + if [ $# -eq 1 ]; then echo "$1"; exit 0; fi + cur="$1" + shift 1 + next=$(cat_path "$@") + if [ -z "$cur" ]; then + echo "$next" + elif [ -z "$next" ]; then + echo "$cur" + else + echo "$cur:$next" + fi +} + # The below environment variables only affect current shell # So if you run again from a terminal. you need to run the script again # see how this is sourced in monteverdi.sh and mapla.sh @@ -27,17 +43,13 @@ CMAKE_PREFIX_PATH=OUT_DIR export CMAKE_PREFIX_PATH # check and set OTB_APPLICATION_PATH -if [ -z "$OTB_APPLICATION_PATH" ] || [ "$OTB_APPLICATION_PATH" = "" ]; then - OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications -else - OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications:$OTB_APPLICATION_PATH -fi +OTB_APPLICATION_PATH=$(cat_path "OUT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH") # Add bin direcotory to system PATH -PATH=OUT_DIR/bin:$PATH +PATH=$(cat_path "OUT_DIR/bin" "$PATH") # export PYTHONPATH to import otbApplication.py -PYTHONPATH=OUT_DIR/lib/python:$PYTHONPATH +PYTHONPATH=$(cat_path "OUT_DIR/lib/python" "$PYTHONPATH") # set numeric locale to C LC_NUMERIC=C diff --git a/Packaging/install_python_bindings.cmake b/Packaging/install_python_bindings.cmake index 754986de0a96b845f761ca02143a73ac839ee843..5de31587c0655ed1a686c5629b2e9e334084ca3e 100644 --- a/Packaging/install_python_bindings.cmake +++ b/Packaging/install_python_bindings.cmake @@ -24,6 +24,14 @@ function(install_python_bindings) PATTERN "*.pyc" EXCLUDE PATTERN "__pycache__" EXCLUDE ) + install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/share/otb/swig + DESTINATION ${PKG_STAGE_DIR}/share/otb + ) + install(FILES Files/build_wrapping.cmake + DESTINATION ${PKG_STAGE_DIR}/share/otb/swig) + install(FILES Files/build_wrapping.md + DESTINATION ${PKG_STAGE_DIR}/share/otb/swig + RENAME README.md) endif() # Handle GDAL python bindings file(GLOB gdal_python_scripts "${SUPERBUILD_INSTALL_DIR}/bin/gdal*.py") diff --git a/README.md b/README.md index 671908491cce537f0cfb025bc12e868315f2eb5d..fd8c20861be494727843612ea78fce7f42676d2c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ #  Orfeo Toolbox + +[](https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/commits/develop) +[](https://sonar.orfeo-toolbox.org/dashboard?id=orfeotoolbox-otb) + ## Open Source processing of remote sensing images Orfeo ToolBox (OTB) is an open-source project for state-of-the-art remote diff --git a/SuperBuild/CMake/External_boost.cmake b/SuperBuild/CMake/External_boost.cmake index a2d44ea89b121c10be27bb1b1d74b34dcd0e8c2d..edd73c86b09dd7b68cfa622f67947722e81e7f5f 100644 --- a/SuperBuild/CMake/External_boost.cmake +++ b/SuperBuild/CMake/External_boost.cmake @@ -22,41 +22,12 @@ INCLUDE_ONCE_MACRO(BOOST) SETUP_SUPERBUILD(BOOST) -set(_SB_BOOST_LIBRARYDIR ${SB_INSTALL_PREFIX}/lib) - -set(BOOST_SB_CONFIG) -if(OTB_TARGET_SYSTEM_ARCH_IS_X64) - set(BOOST_SB_CONFIG address-model=64) -endif() - -set(BOOST_SB_CONFIG - ${BOOST_SB_CONFIG} - variant=release - link=shared - threading=multi - runtime-link=shared - --prefix=${SB_INSTALL_PREFIX} - --includedir=${SB_INSTALL_PREFIX}/include - --libdir=${_SB_BOOST_LIBRARYDIR} - --with-system - --with-serialization - --with-filesystem - --with-test - --with-date_time - --with-program_options - --with-thread - ) - -set(BOOST_BOOTSTRAP_OPTIONS "") - if(UNIX) set(BOOST_BOOTSTRAP_FILE "./bootstrap.sh") set(BOOST_B2_EXE "./b2") if(NOT APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(BOOST_SB_CONFIG - ${BOOST_SB_CONFIG} - toolset=clang) - set(BOOST_BOOTSTRAP_OPTIONS "--with-toolset=clang") + set(BOOST_BOOTSTRAP_OPTIONS "${BOOST_BOOTSTRAP_OPTIONS} --with-toolset=clang") + set(BOOST_SB_CONFIG toolset=clang) endif() else() set(BOOST_BOOTSTRAP_FILE "bootstrap.bat") @@ -66,8 +37,47 @@ endif() set(BOOST_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E chdir ${BOOST_SB_SRC} ${BOOST_BOOTSTRAP_FILE} ${BOOST_BOOTSTRAP_OPTIONS} + ) + +# We cannot configure and bootstrap boost properly. Every configuration stuff +# must be passed to b2. Why? Windows... That is why... +# Libraries we need from boost +set( boost_libraries_to_build "system;serialization;filesystem;test;date_time;program_options;thread") +# add libraries to b2 option +set(BOOST_SB_CONFIG) +foreach(lib ${boost_libraries_to_build}) + set(BOOST_SB_CONFIG + ${BOOST_SB_CONFIG} + --with-${lib}) +endforeach(lib) + +# This is needed because otherwise boost is building both x32 and x64 lib +# (on wndows) and during packages on win32 we are installing all libs. +# See Packaging/install_importlibs.cmake + +if ( WIN32 ) + if(OTB_TARGET_SYSTEM_ARCH_IS_X64) + set(BOOST_SB_CONFIG + ${BOOST_SB_CONFIG} + address-model=64) + else() + set(BOOST_SB_CONFIG + ${BOOST_SB_CONFIG} + address-model=32) + endif() +endif() + +set(BOOST_SB_CONFIG + ${BOOST_SB_CONFIG} + variant=release + link=shared + threading=multi + runtime-link=shared --prefix=${SB_INSTALL_PREFIX} ) + # set(_SB_BOOST_LIBRARYDIR ${SB_INSTALL_PREFIX}/lib) + # --includedir=${SB_INSTALL_PREFIX}/include #This is the default in boost + # --libdir=${_SB_BOOST_LIBRARYDIR} # same here set(BOOST_BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${BOOST_SB_SRC} @@ -79,8 +89,8 @@ set(BOOST_BUILD_COMMAND ${CMAKE_COMMAND} #NOTE: update _SB_Boost_INCLUDE_DIR below when you change version number ExternalProject_Add(BOOST PREFIX BOOST - URL "http://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2" - URL_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe + URL "http://downloads.sourceforge.net/project/boost/boost/1.69.0/boost_1_69_0.tar.bz2" + URL_MD5 a1332494397bf48332cb152abfefcec2 BINARY_DIR ${BOOST_SB_BUILD_DIR} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} @@ -96,7 +106,7 @@ ExternalProject_Add(BOOST #HINT: avoid all uses of _SB_* in External_<project>.cmake # and depend on much saner CMAKE_PREFIX_PATH for cmake projects. if(MSVC) - set(_SB_Boost_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include/boost-1_60) + set(_SB_Boost_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include/boost-1_69) else() set(_SB_Boost_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) endif() diff --git a/SuperBuild/CMake/External_font.cmake b/SuperBuild/CMake/External_font.cmake index 14f5b415483d8018187a403b9d53e5d9cc8d9dd0..58109160892a4bf39b741b49748a7e05e1c5dacf 100644 --- a/SuperBuild/CMake/External_font.cmake +++ b/SuperBuild/CMake/External_font.cmake @@ -30,11 +30,10 @@ if ( EXISTS "${DOWNLOAD_LOCATION}/dejavu-fonts-ttf-2.37.tar.bz2" ) file( MD5 "${DOWNLOAD_LOCATION}/dejavu-fonts-ttf-2.37.tar.bz2" MD5_FONT ) endif() -SET(CMAKE_TLS_VERIFY "OFF") if ( NOT ( "${MD5_FONT}" STREQUAL "d0efec10b9f110a32e9b8f796e21782c" ) ) MESSAGE("DOWNLOADING FONTS") file(DOWNLOAD - "https://netix.dl.sourceforge.net/project/dejavu/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2" + "https://sourceforge.net/projects/dejavu/files/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2" ${DOWNLOAD_LOCATION}/dejavu-fonts-ttf-2.37.tar.bz2 EXPECTED_MD5 d0efec10b9f110a32e9b8f796e21782c) endif() diff --git a/SuperBuild/CMake/External_gdal.cmake b/SuperBuild/CMake/External_gdal.cmake index 418c9e6de361772b61d38b3172c31c49e1f9fcac..30d0010ec89582d2dd8c47c159d7acf1e860f1f2 100644 --- a/SuperBuild/CMake/External_gdal.cmake +++ b/SuperBuild/CMake/External_gdal.cmake @@ -105,6 +105,7 @@ if(UNIX) --with-webp=no --with-threads=yes --with-freexl=no + --with-proj=yes --with-libjson-c=internal ${GDAL_SB_CONFIG} ${GDAL_SB_EXTRA_OPTIONS} diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index fbcf788525b1f568d87a3b913eaaf2e0c77f72fd..f4a9ffd6c0077e5be3a0c9e6faf017cf4b6ca995 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -385,7 +385,7 @@ set ( Python_ADDITIONAL_VERSIONS "3;2" ) set ( PythonInterp_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) set ( PythonLibs_FIND_REQUIRED ${OTB_WRAP_PYTHON} ) find_package( PythonInterp ) -if ( OTB_WRAP_PYTHON AND ( ${PYTHON_VERSION_MAJOR} EQUAL 2 ) ) +if ( OTB_WRAP_PYTHON AND ( "x${PYTHON_VERSION_MAJOR}" STREQUAL "x2" ) ) message (WARNING "Python3 not found. There is no longer support of \ wrapping in python2 in OTB, but it can still be used.") endif() diff --git a/SuperBuild/patches/BOOST/boost-2-fix_quadmath-linux.diff b/SuperBuild/patches/BOOST/boost-2-fix_quadmath-linux.diff deleted file mode 100755 index 164cbacc66a4edaeb60a3396689cebdc127f1bd0..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/BOOST/boost-2-fix_quadmath-linux.diff +++ /dev/null @@ -1,77 +0,0 @@ -This patch is taken from boostorg github. -https://github.com/boostorg/math/commit/74ff2db959c5fa75bec770c41ed2951a740fe936.diff - -diff --git a/include/boost/math/special_functions/fpclassify.hpp b/include/boost/math/special_functions/fpclassify.hpp -index 0a4e1ac..58fad13 100644 ---- a/boost/math/special_functions/fpclassify.hpp -+++ b/boost/math/special_functions/fpclassify.hpp -@@ -81,7 +81,12 @@ is used. - #include <float.h> - #endif - #ifdef BOOST_MATH_USE_FLOAT128 -+#ifdef __has_include -+#if __has_include("quadmath.h") - #include "quadmath.h" -+#define BOOST_MATH_HAS_QUADMATH_H -+#endif -+#endif - #endif - - #ifdef BOOST_NO_STDC_NAMESPACE -@@ -124,9 +129,14 @@ inline bool is_nan_helper(T, const boost::false_type&) - { - return false; - } --#ifdef BOOST_MATH_USE_FLOAT128 -+#if defined(BOOST_MATH_USE_FLOAT128) -+#if defined(BOOST_MATH_HAS_QUADMATH_H) - inline bool is_nan_helper(__float128 f, const boost::true_type&) { return ::isnanq(f); } - inline bool is_nan_helper(__float128 f, const boost::false_type&) { return ::isnanq(f); } -+#else -+inline bool is_nan_helper(__float128 f, const boost::true_type&) { return ::isnan(static_cast<double>(f)); } -+inline bool is_nan_helper(__float128 f, const boost::false_type&) { return ::isnan(static_cast<double>(f)); } -+#endif - #endif - } - -@@ -519,7 +529,7 @@ inline bool (isinf)(long double x) - return detail::isinf_impl(static_cast<value_type>(x), method()); - } - #endif --#ifdef BOOST_MATH_USE_FLOAT128 -+#if defined(BOOST_MATH_USE_FLOAT128) && defined(BOOST_MATH_HAS_QUADMATH_H) - template<> - inline bool (isinf)(__float128 x) - { -@@ -611,7 +621,7 @@ inline bool (isnan)(long double x) - return detail::isnan_impl(x, method()); - } - #endif --#ifdef BOOST_MATH_USE_FLOAT128 -+#if defined(BOOST_MATH_USE_FLOAT128) && defined(BOOST_MATH_HAS_QUADMATH_H) - template<> - inline bool (isnan)(__float128 x) - { -diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp -index ffd0ab4..75d29b6 100644 ---- a/boost/math/tools/config.hpp -+++ b/boost/math/tools/config.hpp -@@ -265,18 +265,6 @@ - # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF - #endif - // --// Test whether to support __float128, if we don't have quadmath.h then this can't currently work: --// --#ifndef BOOST_MATH_USE_FLOAT128 --#ifdef __has_include --#if ! __has_include("quadmath.h") --#define BOOST_MATH_DISABLE_FLOAT128 --#endif --#elif !defined(BOOST_ARCH_X86) --#define BOOST_MATH_DISABLE_FLOAT128 --#endif --#endif --// - // And then the actual configuration: - // - #if defined(_GLIBCXX_USE_FLOAT128) && defined(BOOST_GCC) && !defined(__STRICT_ANSI__) \ diff --git a/SuperBuild/patches/BOOST/boost-2-timerheader-all.diff b/SuperBuild/patches/BOOST/boost-2-timerheader-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..58d46451364a25989a5be9a2f39994736ed15553 --- /dev/null +++ b/SuperBuild/patches/BOOST/boost-2-timerheader-all.diff @@ -0,0 +1,29 @@ +--- boost_1_69_0.orig/libs/test/build/Jamfile.v2 ++++ boost_1_69_0/libs/test/build/Jamfile.v2 +@@ -7,7 +7,7 @@ + import os ; + + import ../../predef/check/predef +- : check ++ : check + : predef-check ; + + project boost/test +@@ -25,17 +25,10 @@ project boost/test + <warnings>all + # <warnings-as-errors>on + +- # adding a dependency on boost/timer as the header are needed, and the junction needs +- # to be there in order to build the library. +- <library>/boost/timer//boost_timer + : usage-requirements + <define>BOOST_TEST_NO_AUTO_LINK=1 + # Disable Warning about boost::noncopyable not being exported + <link>shared,<toolset>msvc:<cxxflags>-wd4275 +- +- # Adding a dependency on boost/timer as the headers need to be there in case of the +- # header-only usage variant +- <use>/boost/timer//boost_timer + ; + + PRG_EXEC_MON_SOURCES = diff --git a/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in b/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in index 8a03873073d1505ea3680959f40185526e0689a8..c57c8966769a9f770b9c653746b4922b9dd1acda 100644 --- a/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in +++ b/SuperBuild/patches/GDAL/nmake_gdal_extra.opt.in @@ -44,6 +44,7 @@ SQLITE_LIB=@SB_INSTALL_PREFIX_NATIVE@\lib\sqlite3.lib SQLITE_HAS_COLUMN_METADATA=yes # PROJ.4 stuff +PROJ_FLAGS = -DPROJ_STATIC -DPROJ_VERSION=4 PROJ_INCLUDE = -I@SB_INSTALL_PREFIX_NATIVE@\include PROJ_LIBRARY = @SB_INSTALL_PREFIX_NATIVE@\lib\proj.lib