diff --git a/CHANGELOG.md b/CHANGELOG.md index 424a6312cca..51b1efd2565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# UNRELEASED + - Changes from 5.17.0: + - Infrastructure: + - ADDED: Updated libosmium and added protozero and vtzero libraries [#5037](https://github.com/Project-OSRM/osrm-backend/pull/5037) + # 5.17.1 - Changes from 5.17.0: - Bugfixes: diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e6e40828d3..4dbc5a2ebc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ add_executable(osrm-customize src/tools/customize.cpp) add_executable(osrm-contract src/tools/contract.cpp) add_executable(osrm-routed src/tools/routed.cpp $ $) add_executable(osrm-datastore src/tools/store.cpp $ $) -add_library(osrm src/osrm/osrm.cpp $ $ $ $ ) +add_library(osrm src/osrm/osrm.cpp $ $ $ $) add_library(osrm_contract src/osrm/contractor.cpp $ $) add_library(osrm_extract src/osrm/extractor.cpp $ $ $) add_library(osrm_guidance $ $) @@ -416,11 +416,24 @@ if(UNIX AND NOT APPLE) set(MAYBE_RT_LIBRARY -lrt) endif() -# Disallow deprecated protozero APIs -add_definitions(-DPROTOZERO_STRICT_API) - find_package(Threads REQUIRED) +# Third-party libraries +set(RAPIDJSON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidjson/include") +include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR}) + +set(MICROTAR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src") +include_directories(SYSTEM ${MICROTAR_INCLUDE_DIR}) +add_library(MICROTAR OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src/microtar.c") +set_property(TARGET MICROTAR PROPERTY POSITION_INDEPENDENT_CODE ON) + +set(PROTOZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/protozero/include") +include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR}) + +set(VTZERO_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/vtzero/include") +include_directories(SYSTEM ${VTZERO_INCLUDE_DIR}) + + # if mason is enabled no find_package calls are made # to ensure that we are only compiling and linking against # fully portable mason packages @@ -554,14 +567,6 @@ else() include_directories(SYSTEM ${OSMIUM_INCLUDE_DIR}) endif() -set(RAPIDJSON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidjson/include") -include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR}) - -set(MICROTAR_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src") -include_directories(SYSTEM ${MICROTAR_INCLUDE_DIR}) -add_library(MICROTAR OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/third_party/microtar/src/microtar.c") -set_property(TARGET MICROTAR PROPERTY POSITION_INDEPENDENT_CODE ON) - # prefix compilation with ccache by default if available and on clang or gcc if(ENABLE_CCACHE AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")) find_program(CCACHE_FOUND ccache) diff --git a/scripts/update_dependencies.sh b/scripts/update_dependencies.sh index 0b7f33ec69a..57dd62659d5 100755 --- a/scripts/update_dependencies.sh +++ b/scripts/update_dependencies.sh @@ -9,79 +9,50 @@ set -o nounset # structure will be lost. # http://git.661346.n2.nabble.com/subtree-merges-lose-prefix-after-rebase-td7332850.html -OSMIUM_REPO="https://github.com/osmcode/libosmium.git" -OSMIUM_TAG=v2.13.1 +OSMIUM_PATH="osmcode/libosmium" +OSMIUM_TAG=v2.14.0 -VARIANT_REPO="https://github.com/mapbox/variant.git" +VARIANT_PATH="mapbox/variant" VARIANT_TAG=v1.1.3 -SOL_REPO="https://github.com/ThePhD/sol2.git" +SOL_PATH="ThePhD/sol2" SOL_TAG=v2.17.5 -RAPIDJSON_REPO="https://github.com/miloyip/rapidjson.git" +RAPIDJSON_PATH="Tencent/rapidjson" RAPIDJSON_TAG=v1.1.0 -MICROTAR_REPO="https://github.com/rxi/microtar" +MICROTAR_PATH="rxi/microtar" MICROTAR_TAG=v0.1.0 -VARIANT_LATEST=$(curl "https://api.github.com/repos/mapbox/variant/releases/latest" | jq ".tag_name") -OSMIUM_LATEST=$(curl "https://api.github.com/repos/osmcode/libosmium/releases/latest" | jq ".tag_name") -SOL_LATEST=$(curl "https://api.github.com/repos/ThePhD/sol2/releases/latest" | jq ".tag_name") -RAPIDJSON_LATEST=$(curl "https://api.github.com/repos/miloyip/rapidjson/releases/latest" | jq ".tag_name") -MICROTAR_LATEST=$(curl "https://api.github.com/repos/rxi/microtar/releases/latest" | jq ".tag_name") - -echo "Latest osmium release is $OSMIUM_LATEST, pulling in \"$OSMIUM_TAG\"" -echo "Latest variant release is $VARIANT_LATEST, pulling in \"$VARIANT_TAG\"" -echo "Latest sol2 release is $SOL_LATEST, pulling in \"$SOL_TAG\"" -echo "Latest rapidjson release is $RAPIDJSON_LATEST, pulling in \"$RAPIDJSON_TAG\"" -echo "Latest microtar release is $MICROTAR_LATEST, pulling in \"$MICROTAR_TAG\"" - -read -p "Update osmium (y/n) " ok -if [[ $ok =~ [yY] ]] -then - if [ -d "third_party/libosmium" ]; then - git subtree pull -P third_party/libosmium/ $OSMIUM_REPO $OSMIUM_TAG --squash - else - git subtree add -P third_party/libosmium/ $OSMIUM_REPO $OSMIUM_TAG --squash - fi -fi - -read -p "Update variant (y/n) " ok -if [[ $ok =~ [yY] ]] -then - if [ -d "third_party/variant" ]; then - git subtree pull -P third_party/variant/ $VARIANT_REPO $VARIANT_TAG --squash - else - git subtree add -P third_party/variant/ $VARIANT_REPO $VARIANT_TAG --squash - fi -fi - -read -p "Update sol2 (y/n) " ok -if [[ $ok =~ [yY] ]] -then - if [ -d "third_party/sol2" ]; then - git subtree pull -P third_party/sol2/sol2/ $SOL_REPO $SOL_TAG --squash - else - git subtree add -P third_party/sol2/sol2/ $SOL_REPO $SOL_TAG --squash - fi -fi - -read -p "Update rapidjson (y/n) " ok -if [[ $ok =~ [yY] ]] -then - if [ -d "third_party/rapidjson" ]; then - git subtree pull -P third_party/rapidjson/ $RAPIDJSON_REPO $RAPIDJSON_TAG --squash - else - git subtree add -P third_party/rapidjson/ $RAPIDJSON_REPO $RAPIDJSON_TAG --squash - fi -fi - -read -p "Update microtar (y/n) " ok -if [[ $ok =~ [yY] ]] -then - if [ -d "third_party/microtar" ]; then - git subtree pull -P third_party/microtar/ $MICROTAR_REPO $MICROTAR_TAG --squash - else - git subtree add -P third_party/microtar/ $MICROTAR_REPO $MICROTAR_TAG --squash - fi -fi +PROTOZERO_PATH="mapbox/protozero" +PROTOZERO_TAG=v1.6.2 + +VTZERO_PATH="mapbox/vtzero" +VTZERO_TAG=v1.0.1 + +function update_subtree () { + name=${1^^} + path=$(tmpvar=${name}_PATH && echo ${!tmpvar}) + tag=$(tmpvar=${name}_TAG && echo ${!tmpvar}) + dir=$(basename $path) + repo="https://github.com/${path}.git" + latest=$(curl -s "https://api.github.com/repos/${path}/releases/latest" | jq ".tag_name") + + echo "Latest $1 release is ${latest}, pulling in \"${tag}\"" + + read -p "Update ${1} (y/n) " ok + + if [[ $ok =~ [yY] ]] + then + if [ -d "third_party/$dir" ]; then + git subtree pull -P third_party/$dir ${repo} ${tag} --squash + else + git subtree add -P third_party/$dir ${repo} ${tag} --squash + fi + fi +} + +## Update dependencies +for dep in osmium variant sol rapidjson microtar protozero vtzero ; do + update_subtree $dep +done diff --git a/third_party/libosmium/.clang-tidy b/third_party/libosmium/.clang-tidy new file mode 100644 index 00000000000..9f3240b8700 --- /dev/null +++ b/third_party/libosmium/.clang-tidy @@ -0,0 +1,90 @@ +--- +Checks: '*,-android-cloexec-*,-cert-dcl21-cpp,-cert-err58-cpp,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-runtime-references,-hicpp-invalid-access-moved,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-vararg,-misc-macro-parentheses,-misc-unused-parameters,-modernize-make-unique,-modernize-raw-string-literal,-readability-avoid-const-params-in-decls,-readability-implicit-bool-cast,-readability-implicit-bool-conversion' +# +# For a list of check options, see: +# http://clang.llvm.org/extra/clang-tidy/checks/list.html +# +# Disabled checks: +# +# android-cloexec-* +# O_CLOEXEC isn't available on Windows making this non-portable. +# +# cert-dcl21-cpp +# It is unclear whether this is still a good recommendation in modern C++. +# +# cert-err58-cpp +# Used in several singelton factory functions. I don't know of a better +# way to do this and it is rather unlikely that this will be a problem. +# +# cppcoreguidelines-owning-memory +# Don't want to add dependency on gsl library. +# +# cppcoreguidelines-pro-bounds-array-to-pointer-decay +# Limited use and many false positives including for all asserts. +# +# cppcoreguidelines-pro-bounds-constant-array-index +# Is needed for low-level code. +# +# cppcoreguidelines-pro-bounds-pointer-arithmetic +# This is a low-level library, it needs to do pointer arithmetic. +# +# cppcoreguidelines-pro-type-const-cast +# When you need it, you need it. +# +# cppcoreguidelines-pro-type-reinterpret-cast +# This is a low-level library, it needs to do reinterpret-casts. +# +# cppcoreguidelines-pro-type-static-cast-downcast +# This is needed and totally okay if we are sure about the types. +# +# cppcoreguidelines-pro-type-vararg +# We need some of these functions at least and for some functions it isn't +# even clear that those are vararg functions. +# +# fuchsia-* +# Much too strict. +# +# google-runtime-references +# This is just a matter of preference, and we can't change the interfaces +# now anyways. +# +# hicpp-invalid-access-moved +# Creates false positives. +# +# hicpp-no-array-decay +# Alias for cppcoreguidelines-pro-bounds-array-to-pointer-decay. +# +# hicpp-no-assembler +# Reports are from macros we don't have any control over. +# +# hicpp-vararg +# Too strict, sometimes calling vararg functions is necessary. +# +# misc-macro-parentheses +# False positive in the only place where it reports something and +# disabling locally doesn't work. +# +# misc-unused-parameters +# Can't be fixed, because then Doxygen will complain. (In file +# include/osmium/area/problem_reporter.hpp). +# +# modernize-make-unique +# This is a C++11 library and C++ doesn't have std::make_unique. +# +# modernize-raw-string-literal +# Readability isn't that much better, arguably worse because of the new +# syntax. +# +# readability-avoid-const-params-in-decls +# This is header only library, so the declaration and implementation are +# often the same and we want to have the const in implementations. +# +# readability-implicit-bool-cast +# Old name for readability-implicit-bool-conversion. +# +# readability-implicit-bool-conversion +# I don't think this makes the code more readable. +# +#WarningsAsErrors: '*' +HeaderFilterRegex: '\/include\/osmium\/.*' +... diff --git a/third_party/libosmium/.gitmodules b/third_party/libosmium/.gitmodules new file mode 100644 index 00000000000..b42b21d77cd --- /dev/null +++ b/third_party/libosmium/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/data-tests/osm-testdata"] + path = test/data-tests/osm-testdata + url = https://github.com/osmcode/osm-testdata diff --git a/third_party/libosmium/.travis.yml b/third_party/libosmium/.travis.yml index 33239630886..bc5615d9b8b 100644 --- a/third_party/libosmium/.travis.yml +++ b/third_party/libosmium/.travis.yml @@ -8,6 +8,10 @@ language: generic sudo: false +dist: trusty + +#----------------------------------------------------------------------------- + cache: directories: - $HOME/.ccache @@ -18,176 +22,195 @@ env: - CCACHE_COMPRESS=1 - CASHER_TIME_OUT=1000 +#----------------------------------------------------------------------------- + +# Save common build configurations as shortcuts, so we can reference them later. +addons_shortcuts: + addons_clang35: &clang35 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'clang-3.5'] + addons_clang38: &clang38 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'clang-3.8'] + addons_clang39: &clang39 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'clang-3.9'] + addons_clang40: &clang40 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'llvm-toolchain-trusty-4.0' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'clang-4.0'] + addons_clang50: &clang50 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'llvm-toolchain-trusty-5.0' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'clang-5.0', 'g++-6', 'gcc-6'] + addons_gcc48: &gcc48 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'g++-4.8', 'gcc-4.8' ] + addons_gcc49: &gcc49 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'g++-4.9', 'gcc-4.9' ] + addons_gcc5: &gcc5 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'g++-5', 'gcc-5' ] + addons_gcc6: &gcc6 + apt: + sources: [ 'ubuntu-toolchain-r-test', 'boost-latest' ] + packages: [ 'libboost1.55-all-dev', 'libgdal-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin', 'g++-6', 'gcc-6' ] + +#----------------------------------------------------------------------------- + matrix: include: # 1/ Linux Clang Builds - os: linux compiler: linux-clang35-release - addons: - apt: - sources: ['llvm-toolchain-precise-3.5', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.5', 'cmake', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.5' BUILD_TYPE='Release' + env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Release' + addons: *clang35 - os: linux compiler: linux-clang35-dev - addons: - apt: - sources: ['llvm-toolchain-precise-3.5', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.5', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.5' BUILD_TYPE='Dev' + env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Dev' + addons: *clang35 + + - os: linux + compiler: linux-clang38-release + env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Release' + addons: *clang38 + - os: linux + compiler: linux-clang38-dev + env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Dev' + addons: *clang38 - os: linux - compiler: linux-clang37-release - addons: - apt: - sources: ['llvm-toolchain-precise-3.7', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.7', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.7' BUILD_TYPE='Release' + compiler: linux-clang39-release + env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Release' + addons: *clang39 - os: linux - compiler: linux-clang37-dev - addons: - apt: - sources: ['llvm-toolchain-precise-3.7', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.7', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.7' BUILD_TYPE='Dev' + compiler: linux-clang39-dev + env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Dev' + addons: *clang39 + - os: linux + compiler: linux-clang40-release + env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Release' + addons: *clang40 - os: linux - compiler: linux-clang38-release - addons: - apt: - sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.8', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.8' BUILD_TYPE='Release' + compiler: linux-clang40-dev + env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Dev' + addons: *clang40 - os: linux - compiler: linux-clang38-dev - addons: - apt: - sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['clang-3.8', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='clang++-3.8' BUILD_TYPE='Dev' + compiler: linux-clang50-release + env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Release' + addons: *clang50 + - os: linux + compiler: linux-clang50-dev + env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Dev' + addons: *clang50 + +# Disabled because it creates false-positives on the old travis systems +# - os: linux +# compiler: linux-clang50-debug +# env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Debug' +# CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer" +# LDFLAGS="-fsanitize=address,undefined,integer" +# # LSAN doesn't work on container-based system +# sudo: required +# addons: *clang50 # 2/ Linux GCC Builds - os: linux compiler: linux-gcc48-release - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-4.8', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-4.8' COMPILER_FLAGS='-Wno-return-type' BUILD_TYPE='Release' + env: CC='gcc-4.8' CXX='g++-4.8' BUILD_TYPE='Release' + CXXFLAGS='-Wno-return-type' + addons: *gcc48 - os: linux compiler: linux-gcc48-dev - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-4.8', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-4.8' COMPILER_FLAGS='-Wno-return-type' BUILD_TYPE='Dev' - + env: CC='gcc-4.8' CXX='g++-4.8' BUILD_TYPE='Dev' + CXXFLAGS='-Wno-return-type' + addons: *gcc48 - os: linux compiler: linux-gcc49-release - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-4.9', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-4.9' BUILD_TYPE='Release' + env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Release' + addons: *gcc49 - os: linux compiler: linux-gcc49-dev - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-4.9', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-4.9' BUILD_TYPE='Dev' - + env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Dev' + addons: *gcc49 - os: linux compiler: linux-gcc5-release - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-5', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-5' BUILD_TYPE='Release' + env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Release' + addons: *gcc5 - os: linux compiler: linux-gcc5-dev - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-5', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-5' BUILD_TYPE='Dev' - + env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Dev' + addons: *gcc5 - os: linux compiler: linux-gcc6-release - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-6', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-6' BUILD_TYPE='Release' + env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Release' + addons: *gcc6 - os: linux compiler: linux-gcc6-dev - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-6', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-6' BUILD_TYPE='Dev' + env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Dev' + addons: *gcc6 - os: linux compiler: linux-gcc6-coverage - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'boost-latest'] - packages: ['g++-6', 'libboost1.55-all-dev', 'libgdal-dev', 'libgeos++-dev', 'libproj-dev', 'libsparsehash-dev', 'spatialite-bin'] - env: COMPILER='g++-6' BUILD_TYPE='Coverage' - + env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Coverage' + addons: *gcc6 # 3/ OSX Clang Builds - os: osx osx_image: xcode6.4 compiler: xcode64-clang-release - env: COMPILER='clang++' BUILD_TYPE='Release' + env: CC='clang' CXX='clang++' BUILD_TYPE='Release' - os: osx osx_image: xcode6.4 compiler: xcode64-clang-dev - env: COMPILER='clang++' BUILD_TYPE='Dev' - + env: CC='clang' CXX='clang++' BUILD_TYPE='Dev' - os: osx osx_image: xcode7 compiler: xcode7-clang-release - env: COMPILER='clang++' BUILD_TYPE='Release' + env: CC='clang' CXX='clang++' BUILD_TYPE='Release' - os: osx osx_image: xcode7 compiler: xcode7-clang-dev - env: COMPILER='clang++' BUILD_TYPE='Dev' - + env: CC='clang' CXX='clang++' BUILD_TYPE='Dev' - os: osx osx_image: xcode8.3 compiler: xcode8-clang-release - env: COMPILER='clang++' BUILD_TYPE='Release' + env: CC='clang' CXX='clang++' BUILD_TYPE='Release' - os: osx osx_image: xcode8.3 compiler: xcode8-clang-dev - env: COMPILER='clang++' BUILD_TYPE='Dev' + env: CC='clang' CXX='clang++' BUILD_TYPE='Dev' install: - - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} - - git clone --quiet --depth 1 https://github.com/osmcode/osm-testdata.git + - git clone --quiet --depth 1 https://github.com/mapbox/protozero.git ../protozero - | if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then brew remove gdal @@ -197,8 +220,9 @@ install: before_script: - cd ${TRAVIS_BUILD_DIR} + - git submodule update --init - mkdir build && cd build - - CXX=${COMPILER} CXXFLAGS=${COMPILER_FLAGS} cmake -LA .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_WITH_CCACHE=1 -DOSM_TESTDATA="${TRAVIS_BUILD_DIR}/deps/osm-testdata" + - cmake -LA .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_DATA_TESTS=ON -DBUILD_WITH_CCACHE=1 script: - make VERBOSE=1 && ctest --output-on-failure @@ -208,11 +232,12 @@ after_success: if [ "${BUILD_TYPE}" = "Coverage" ]; then curl -S -f https://codecov.io/bash -o codecov chmod +x codecov - gcov-${COMPILER#g++-} -p $(find test/CMakeFiles -name '*.o') - ./codecov -Z -c -F unit_tests - gcov-${COMPILER#g++-} -p $(find test/data-tests -name '*.o') - ./codecov -Z -c -F data_tests - gcov-${COMPILER#g++-} -p $(find examples -name '*.o') - ./codecov -Z -c -F examples + gcov-${CXX#g++-} -p $(find test/CMakeFiles -name '*.o') + ./codecov -Z -c -X gcov -F unit_tests + gcov-${CXX#g++-} -p $(find test/data-tests -name '*.o') + ./codecov -Z -c -X gcov -F data_tests + gcov-${CXX#g++-} -p $(find examples -name '*.o') + ./codecov -Z -c -X gcov -F examples fi +#----------------------------------------------------------------------------- diff --git a/third_party/libosmium/CHANGELOG.md b/third_party/libosmium/CHANGELOG.md index 2493e0af8ae..fa838f50b5f 100644 --- a/third_party/libosmium/CHANGELOG.md +++ b/third_party/libosmium/CHANGELOG.md @@ -2,7 +2,7 @@ # Change Log All notable changes to this project will be documented in this file. -This project adheres to [Semantic Versioning](http://semver.org/). +This project adheres to [Semantic Versioning](https://semver.org/). ## [unreleased] - @@ -13,6 +13,90 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +## [2.14.0] - 2018-03-31 + +### Added + +* Add `ReaderWithProgressBar` class. This wraps an `osmium::io::Reader` and an + `osmium::ProgressBar` into a nice little package allowing easier use in the + common case. +* Add polygon implementation for WKT and GeoJSON geometry factories. (Thanks + to Horace Williams.) +* Various tests. + +### Changed + +* Add git submodule with `osm-testdata` repository. Before this the repository + had to be installed externally. Now a submodule update can be used to get the + correct version of the osm-testdata repository. +* The XML file reader was rewritten to be more strict. Cases where it could + be tricked into failing badly were removed. There are now more tests for the + XML parser. +* Replaced `strftime` by our own implementation. Uses a specialized + implementation for our use case instead the more general `strftime`. + Benchmarked this to be faster. +* Changed the way IDs are parsed from strings. No asserts are used any more but + checks are done and an exception is thrown when IDs are out of range. This + also changes the way negative values are handled. The value `-1` is now + always accepted for all IDs and returned as `0`. This deprecates the + `string_to_user_id()` function, use `string_to_uid()` instead which returns a + different type. +* It was always a bit confusing that some of the util classes and functions are + directly in the `osmium` namespace and some are in `osmium::util`. The + `osmium::util` namespace is now declared `inline`. which allows all util + classes and functions to be addressed directly in the `osmium` namespace + while keeping backwards compatibility. +* An error is now thrown when the deprecated `pbf_add_metadata` file format + option is used. Use `add_metadata` instead. +* Extended the `add_metadata` file format option. In addition to allowing the + values `true`, `yes`, `false`, and `no`, the new values `all` and `none` + are now recognized. The option can also be set to a list of attributes + separated by the `+` sign. Attributes are `version`, `timestamp`, + `changeset`, `uid`, and `user`. All output formats have been updated to + only output the specified attributes. This is based on the new + `osmium::metadata_options` class which stores information about what metadata + an `OSMObject` has or should have. (Thanks to Michael Reichert.) +* The `<` (less than) operator on `OSMObject`s now ignores the case when + one or both of the timestamps on the objects are not set at all. This + allows better handling of OSM data files with reduced metadata. +* Allow `version = -1` and `changeset = -1` in PBF input. This value is + sometimes used by other programs to denote "no value". Osmium uses the `0` + for this. +* The example programs using the `getopt_long` function have been rewritten to + work without it. This makes using libosmium on Windows easier, where this + function is not available. +* Removed the embedded protozero from repository. Like other dependencies you + have to install protozero first. If you check out the protozero repository + in the same directory where you checked out libosmium, libosmium's CMake + will find it. +* Various code cleanups, fixing of include order, etc. +* Remove need for `winsock2` library in Windows by using code from Protozero. + (Thanks alex85k.) +* Add MSYS2 build to Appveyor and fixed some Windows compile issues. (Thanks + to alex85k.) +* Use array instead of map to store input/output format creators. +* Update included `catch.hpp` to version 1.12.1. + +### Fixed + +* Remove check for lost ways in multipolygon assembler. This rules out too many + valid multipolygons, more specifically more complex ones with touching inner + rings. +* Use different macro magic for registering index maps. This allows the maps + to be used for several types at the same time. +* Lots of code was rewritten to fix warnings reported by `clang-tidy` making + libosmium more robust. +* Make ADL work for `begin()`/`end()` of `InputIterator`. +* Various fixes to make the code more robust, including an undefined behaviour + in the debug output format and a buffer overflow in the o5m parser. +* Range checks in o5m parser throw exceptions now instead of triggering + assertions. +* Better checking that PBF data is in range. +* Check `read` and `write` system calls for `EINTR`. +* Use tag and type from protozero to make PBF parser more robust. +* Test `testdata-multipolygon` on Windows was using the wrong executable name. + + ## [2.13.1] - 2017-08-25 ### Added @@ -739,7 +823,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). Doxygen (up to version 1.8.8). This version contains a workaround to fix this. -[unreleased]: https://github.com/osmcode/libosmium/compare/v2.13.1...HEAD +[unreleased]: https://github.com/osmcode/libosmium/compare/v2.14.0...HEAD +[2.14.0]: https://github.com/osmcode/libosmium/compare/v2.13.1...v2.14.0 [2.13.1]: https://github.com/osmcode/libosmium/compare/v2.13.0...v2.13.1 [2.13.0]: https://github.com/osmcode/libosmium/compare/v2.12.2...v2.13.0 [2.12.2]: https://github.com/osmcode/libosmium/compare/v2.12.1...v2.12.2 diff --git a/third_party/libosmium/CMakeLists.txt b/third_party/libosmium/CMakeLists.txt index e27887590ae..a8409133f68 100644 --- a/third_party/libosmium/CMakeLists.txt +++ b/third_party/libosmium/CMakeLists.txt @@ -24,8 +24,8 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel;Dev;Cover project(libosmium) set(LIBOSMIUM_VERSION_MAJOR 2) -set(LIBOSMIUM_VERSION_MINOR 13) -set(LIBOSMIUM_VERSION_PATCH 1) +set(LIBOSMIUM_VERSION_MINOR 14) +set(LIBOSMIUM_VERSION_PATCH 0) set(LIBOSMIUM_VERSION "${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}") @@ -62,7 +62,6 @@ option(BUILD_BENCHMARKS "compile benchmark programs" ${dev_build}) option(BUILD_DATA_TESTS "compile data tests, please run them with ctest" ${data_test_build}) option(INSTALL_GDALCPP "also install gdalcpp headers" OFF) -option(INSTALL_PROTOZERO "also install protozero headers" OFF) option(INSTALL_UTFCPP "also install utfcpp headers" OFF) option(WITH_PROFILING "add flags needed for profiling" OFF) @@ -173,17 +172,6 @@ set(_own_index) include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS}) -if(MSVC) - find_path(GETOPT_INCLUDE_DIR getopt.h) - find_library(GETOPT_LIBRARY NAMES wingetopt) - if(GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY) - include_directories(SYSTEM ${GETOPT_INCLUDE_DIR}) - list(APPEND OSMIUM_LIBRARIES ${GETOPT_LIBRARY}) - else() - set(GETOPT_MISSING 1) - endif() -endif() - #----------------------------------------------------------------------------- # @@ -402,21 +390,22 @@ if(BUILD_HEADERS) file(MAKE_DIRECTORY header_check) foreach(hpp ${ALL_HPPS}) - string(REPLACE ".hpp" "" tmp ${hpp}) - string(REPLACE "/" "__" libname ${tmp}) + if(GDAL_FOUND OR NOT ((hpp STREQUAL "osmium/area/problem_reporter_ogr.hpp") OR (hpp STREQUAL "osmium/geom/ogr.hpp"))) + string(REPLACE ".hpp" "" tmp ${hpp}) + string(REPLACE "/" "__" libname ${tmp}) - # Create a dummy .cpp file that includes the header file we want to - # check. - set(DUMMYCPP ${CMAKE_BINARY_DIR}/header_check/${libname}.cpp) - file(WRITE ${DUMMYCPP} "#include <${hpp}>\n") + # Create a dummy .cpp file that includes the header file we want to + # check. + set(DUMMYCPP ${CMAKE_BINARY_DIR}/header_check/${libname}.cpp) + file(WRITE ${DUMMYCPP} "#include <${hpp}> // IWYU pragma: keep\n") - # There is no way in CMake to just compile but not link a C++ file, - # so we pretend to build a library here. - add_library(${libname} STATIC ${DUMMYCPP} include/${hpp}) - - #### this is better but only supported from cmake 3.0: - ###add_library(${libname} OBJECT ${DUMMYCPP} include/${hpp}) + # There is no way in CMake to just compile but not link a C++ file, + # so we pretend to build a library here. + add_library(${libname} STATIC ${DUMMYCPP} include/${hpp}) + #### this is better but only supported from cmake 3.0: + ###add_library(${libname} OBJECT ${DUMMYCPP} include/${hpp}) + endif() endforeach() endif() @@ -427,10 +416,10 @@ endif() # #----------------------------------------------------------------------------- message(STATUS "Looking for clang-tidy") -find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-3.9 clang-tidy-3.8 clang-tidy-3.7 clang-tidy-3.6 clang-tidy-3.5) +find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-6.0 clang-tidy-5.0) if(CLANG_TIDY) - message(STATUS "Looking for clang-tidy - found") + message(STATUS "Looking for clang-tidy - found ${CLANG_TIDY}") if(BUILD_EXAMPLES) file(GLOB CT_ALL_EXAMPLES examples/*.cpp) @@ -467,41 +456,9 @@ if(CLANG_TIDY) ${CT_ALL_BENCHMARKS} ${CT_ALL_DATA_TESTS}) - # For a list of check options, see: - # http://clang.llvm.org/extra/clang-tidy/checks/list.html - - list(APPEND CT_CHECKS "cert-*" - "-cert-err60-cpp") # even the std lib doesn't do this - - # disabled, because it is slow -# list(APPEND CT_CHECKS "clang-analyzer-*") - - list(APPEND CT_CHECKS "google-*" - "-google-explicit-constructor" - "-google-readability-casting" - "-google-readability-function") - - list(APPEND CT_CHECKS "llvm-*" - "-llvm-include-order") - - list(APPEND CT_CHECKS "misc-*" - "-misc-argument-comment") - - list(APPEND CT_CHECKS "modernize-*" - "-modernize-make-unique") # not available in C++11 - - list(APPEND CT_CHECKS "readability-*" - "-readability-identifier-naming" - "-readability-implicit-bool-cast" - "-readability-named-parameter") - - string(REPLACE ";" "," ALL_CHECKS "${CT_CHECKS}") - add_custom_target(clang-tidy ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} - -header-filter='include/osmium/.*' - -checks="${ALL_CHECKS}" ${CT_CHECK_FILES} ) else() @@ -523,10 +480,6 @@ if(INSTALL_GDALCPP) install(FILES include/gdalcpp.hpp DESTINATION include) endif() -if(INSTALL_PROTOZERO) - install(DIRECTORY include/protozero DESTINATION include) -endif() - if(INSTALL_UTFCPP) install(FILES include/utf8.h DESTINATION include) install(DIRECTORY include/utf8 DESTINATION include) @@ -560,8 +513,7 @@ include(CPack) if(BUILD_DATA_TESTS AND OSM_TESTDATA STREQUAL "OSM_TESTDATA-NOTFOUND") message("\n========================== WARNING ==========================") message("osm-testdata directory not found, data tests were disabled!\n") - message("You can get it from https://github.com/osmcode/osm-testdata") - message("Clone it into the same directory libosmium is in") + message("Call 'git submodule update --init' to install test data") message("or set the OSM_TESTDATA cmake variable to its path.") message("=============================================================\n") endif() diff --git a/third_party/libosmium/CONTRIBUTING.md b/third_party/libosmium/CONTRIBUTING.md index 7e51d4cd47e..a60f507db0c 100644 --- a/third_party/libosmium/CONTRIBUTING.md +++ b/third_party/libosmium/CONTRIBUTING.md @@ -10,3 +10,10 @@ Some rules for contributing to this project: you have added. Please read the [notes for developers](NOTES_FOR_DEVELOPERS.md) beforehand which contains some coding guidelines. +If you are reporting a problem: + +* Describe exactly what you were trying to achieve, what you did, what you + expected to happen and what did happen instead. Include relevant information + about the platform, OS version etc. you are using. Include shell commands you + typed in, log files, errors messages etc. + diff --git a/third_party/libosmium/EXTERNAL_LICENSES.txt b/third_party/libosmium/EXTERNAL_LICENSES.txt index 7b06fcf4110..9484c08913f 100644 --- a/third_party/libosmium/EXTERNAL_LICENSES.txt +++ b/third_party/libosmium/EXTERNAL_LICENSES.txt @@ -1,210 +1,4 @@ -==== For protozero from https://github.com/mapbox/protozero - -protozero copyright (c) Mapbox. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -==== For protozero from https://github.com/mapbox/protozero - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - ==== For utf8.h Copyright 2006 Nemanja Trifunovic diff --git a/third_party/libosmium/LICENSE.txt b/third_party/libosmium/LICENSE similarity index 100% rename from third_party/libosmium/LICENSE.txt rename to third_party/libosmium/LICENSE diff --git a/third_party/libosmium/NOTES_FOR_DEVELOPERS.md b/third_party/libosmium/NOTES_FOR_DEVELOPERS.md index 4bd9d68cf7a..7ffca5ec580 100644 --- a/third_party/libosmium/NOTES_FOR_DEVELOPERS.md +++ b/third_party/libosmium/NOTES_FOR_DEVELOPERS.md @@ -126,7 +126,7 @@ Call `cmake/iwyu.sh` to check for proper includes and forward declarations. This uses the clang-based `include-what-you-use` program. Note that it does produce some false reports and crashes often. The `osmium.imp` file can be used to define mappings for iwyu. See the IWYU tool at -. +. ## Testing diff --git a/third_party/libosmium/README.md b/third_party/libosmium/README.md index b4fc4dcdb32..91d8f507c35 100644 --- a/third_party/libosmium/README.md +++ b/third_party/libosmium/README.md @@ -9,6 +9,7 @@ Libosmium works on Linux, Mac OSX and Windows. [![Travis Build Status](https://secure.travis-ci.org/osmcode/libosmium.svg)](https://travis-ci.org/osmcode/libosmium) [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/osmcode/libosmium?svg=true)](https://ci.appveyor.com/project/Mapbox/libosmium) [![Coverage Status](https://codecov.io/gh/osmcode/libosmium/branch/master/graph/badge.svg)](https://codecov.io/gh/osmcode/libosmium) +[![Packaging status](https://repology.org/badge/tiny-repos/libosmium.svg)](https://repology.org/metapackage/libosmium) Please see the [Libosmium manual](http://osmcode.org/libosmium/manual.html) for more details than this README can provide. @@ -31,9 +32,11 @@ manual. The following external (header-only) libraries are included in the libosmium repository: * [gdalcpp](https://github.com/joto/gdalcpp) -* [protozero](https://github.com/mapbox/protozero) * [utfcpp](http://utfcpp.sourceforge.net/) +Note that [protozero](https://github.com/mapbox/protozero) was included in +earlier versions of libosmium, but isn't any more. + ## Directories @@ -73,6 +76,14 @@ chapter in the manual. ## Testing +To download the `osm-testdata` submodule call: + +``` +git submodule update --init +``` + +This will enable additional tests. + See the [Libosmium Manual](http://osmcode.org/libosmium/manual.html#running-tests) for instructions. diff --git a/third_party/libosmium/appveyor.yml b/third_party/libosmium/appveyor.yml index ca77ae64750..2ac3e254665 100644 --- a/third_party/libosmium/appveyor.yml +++ b/third_party/libosmium/appveyor.yml @@ -6,34 +6,54 @@ environment: matrix: - - config: Dev + - config: MSYS2 autocrlf: true - - config: Dev - autocrlf: false - - config: RelWithDebInfo + - config: Debug + autocrlf: true + - config: Release autocrlf: true - - config: RelWithDebInfo + - config: Debug + autocrlf: false + - config: Release autocrlf: false -shallow_clone: true +clone_depth: 1 # Operating system (build VM template) os: Visual Studio 2015 +platform: x64 + # scripts that are called at very beginning, before repo cloning init: - git config --global core.autocrlf %autocrlf% - git config --get core.autocrlf -# clone directory clone_folder: c:\projects\libosmium -platform: x64 +# The option --ask=20 is a workaround for a problem with the MSYS2 update +# process. Without it the following error is printed and the appveyor script +# halts: "msys2-runtime and catgets are in conflict. Remove catgets?" +# See also: https://github.com/Alexpux/MSYS2-packages/issues/1141 +install: + - git submodule update --init + - cd c:\projects + - git clone --depth 1 https://github.com/mapbox/protozero + - if [%config%]==[MSYS2] ( + C:\msys64\usr\bin\pacman --noconfirm --sync --refresh --refresh --sysupgrade --sysupgrade --ask=20 + && C:\msys64\usr\bin\pacman -Rc --noconfirm mingw-w64-x86_64-gcc-libs + ) build_script: - - build-appveyor.bat + - cd c:\projects\libosmium + - if [%config%]==[MSYS2] ( + build-msys2.bat + ) else ( + build-appveyor.bat + ) # remove garbage VS messages -# http://help.appveyor.com/discussions/problems/4569-the-target-_convertpdbfiles-listed-in-a-beforetargets-attribute-at-c-does-not-exist-in-the-project-and-will-be-ignored +# https://help.appveyor.com/discussions/problems/4569-the-target-_convertpdbfiles-listed-in-a-beforetargets-attribute-at-c-does-not-exist-in-the-project-and-will-be-ignored before_build: - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets" + diff --git a/third_party/libosmium/benchmarks/download_data.sh b/third_party/libosmium/benchmarks/download_data.sh index be6adb9541d..b17fcad5895 100755 --- a/third_party/libosmium/benchmarks/download_data.sh +++ b/third_party/libosmium/benchmarks/download_data.sh @@ -4,9 +4,9 @@ # cd $DATA_DIR -curl --location --output 1_liechtenstein.osm.pbf http://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf # about 2 MB -curl --location --output 2_bremen.osm.pbf http://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf # about 16 MB -curl --location --output 3_sachsen.osm.pbf http://download.geofabrik.de/europe/germany/sachsen-latest.osm.pbf # about 160 MB -curl --location --output 4_germany.osm.pbf http://download.geofabrik.de/europe/germany-latest.osm.pbf # about 3 GB -curl --location --output 5_planet.osm.pbf http://planet.osm.org/pbf/planet-latest.osm.pbf # about 35 GB +curl --location --output 1_liechtenstein.osm.pbf https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf # about 2 MB +curl --location --output 2_bremen.osm.pbf https://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf # about 16 MB +curl --location --output 3_sachsen.osm.pbf https://download.geofabrik.de/europe/germany/sachsen-latest.osm.pbf # about 160 MB +curl --location --output 4_germany.osm.pbf https://download.geofabrik.de/europe/germany-latest.osm.pbf # about 3 GB +curl --location --output 5_planet.osm.pbf https://planet.osm.org/pbf/planet-latest.osm.pbf # about 35 GB diff --git a/third_party/libosmium/benchmarks/osmium_benchmark_count.cpp b/third_party/libosmium/benchmarks/osmium_benchmark_count.cpp index 41f9aa07890..65051b0f94f 100644 --- a/third_party/libosmium/benchmarks/osmium_benchmark_count.cpp +++ b/third_party/libosmium/benchmarks/osmium_benchmark_count.cpp @@ -4,36 +4,35 @@ */ +#include +#include +#include + #include #include #include #include -#include -#include -#include - struct CountHandler : public osmium::handler::Handler { uint64_t nodes = 0; uint64_t ways = 0; uint64_t relations = 0; - void node(const osmium::Node&) { + void node(const osmium::Node& /*node*/) { ++nodes; } - void way(const osmium::Way&) { + void way(const osmium::Way& /*way*/) { ++ways; } - void relation(const osmium::Relation&) { + void relation(const osmium::Relation& /*relation*/) { ++relations; } }; - int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; @@ -48,8 +47,8 @@ int main(int argc, char* argv[]) { osmium::apply(reader, handler); reader.close(); - std::cout << "Nodes: " << handler.nodes << "\n"; - std::cout << "Ways: " << handler.ways << "\n"; - std::cout << "Relations: " << handler.relations << "\n"; + std::cout << "Nodes: " << handler.nodes << '\n'; + std::cout << "Ways: " << handler.ways << '\n'; + std::cout << "Relations: " << handler.relations << '\n'; } diff --git a/third_party/libosmium/benchmarks/osmium_benchmark_count_tag.cpp b/third_party/libosmium/benchmarks/osmium_benchmark_count_tag.cpp index 5b82a7c3abd..12d5c8201ce 100644 --- a/third_party/libosmium/benchmarks/osmium_benchmark_count_tag.cpp +++ b/third_party/libosmium/benchmarks/osmium_benchmark_count_tag.cpp @@ -4,15 +4,15 @@ */ +#include +#include +#include + #include #include #include #include -#include -#include -#include - struct CountHandler : public osmium::handler::Handler { uint64_t counter = 0; @@ -26,17 +26,16 @@ struct CountHandler : public osmium::handler::Handler { } } - void way(const osmium::Way&) { + void way(const osmium::Way& /*way*/) { ++all; } - void relation(const osmium::Relation&) { + void relation(const osmium::Relation& /*relation*/) { ++all; } }; - int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; @@ -51,6 +50,6 @@ int main(int argc, char* argv[]) { osmium::apply(reader, handler); reader.close(); - std::cout << "r_all=" << handler.all << " r_counter=" << handler.counter << "\n"; + std::cout << "r_all=" << handler.all << " r_counter=" << handler.counter << '\n'; } diff --git a/third_party/libosmium/benchmarks/osmium_benchmark_index_map.cpp b/third_party/libosmium/benchmarks/osmium_benchmark_index_map.cpp index 2cf550ca9c5..e8989824685 100644 --- a/third_party/libosmium/benchmarks/osmium_benchmark_index_map.cpp +++ b/third_party/libosmium/benchmarks/osmium_benchmark_index_map.cpp @@ -4,16 +4,15 @@ */ -#include -#include -#include - -#include +#include #include +#include +#include #include -#include -#include +#include +#include +#include using index_type = osmium::index::map::Map; diff --git a/third_party/libosmium/benchmarks/osmium_benchmark_mercator.cpp b/third_party/libosmium/benchmarks/osmium_benchmark_mercator.cpp index 091e5c025ef..f9672c305ce 100644 --- a/third_party/libosmium/benchmarks/osmium_benchmark_mercator.cpp +++ b/third_party/libosmium/benchmarks/osmium_benchmark_mercator.cpp @@ -4,17 +4,17 @@ */ +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include -#include - struct GeomHandler : public osmium::handler::Handler { osmium::geom::WKBFactory factory; @@ -25,7 +25,6 @@ struct GeomHandler : public osmium::handler::Handler { }; - int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " OSMFILE\n"; diff --git a/third_party/libosmium/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp b/third_party/libosmium/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp index e9f950c3168..1a689b18785 100644 --- a/third_party/libosmium/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp +++ b/third_party/libosmium/benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp @@ -16,6 +16,12 @@ */ +#include +#include +#include +#include +#include + #include #include #include @@ -24,13 +30,6 @@ #include #include -#include -#include -#include - -#include -#include - using static_index_type = osmium::index::map::SparseMemArray; const std::string location_store{"sparse_mem_array"}; @@ -51,7 +50,7 @@ int main(int argc, char* argv[]) { const auto& map_factory = osmium::index::MapFactory::instance(); - const auto buffer_size = buffer.committed() / (1024*1024); // buffer size in MBytes + const auto buffer_size = buffer.committed() / (1024 * 1024); // buffer size in MBytes const int runs = std::max(10, static_cast(5000ull / buffer_size)); std::cout << "input: filename=" << input_filename << " buffer_size=" << buffer_size << "MBytes\n"; @@ -82,10 +81,14 @@ int main(int argc, char* argv[]) { osmium::apply(tmp_buffer, static_location_handler); const auto end = std::chrono::steady_clock::now(); - const double duration = std::chrono::duration(end-start).count(); + const double duration = std::chrono::duration(end - start).count(); - if (duration < static_min) static_min = duration; - if (duration > static_max) static_max = duration; + if (duration < static_min) { + static_min = duration; + } + if (duration > static_max) { + static_max = duration; + } static_sum += duration; } @@ -105,16 +108,20 @@ int main(int argc, char* argv[]) { osmium::apply(tmp_buffer, dynamic_location_handler); const auto end = std::chrono::steady_clock::now(); - const double duration = std::chrono::duration(end-start).count(); + const double duration = std::chrono::duration(end - start).count(); - if (duration < dynamic_min) dynamic_min = duration; - if (duration > dynamic_max) dynamic_max = duration; + if (duration < dynamic_min) { + dynamic_min = duration; + } + if (duration > dynamic_max) { + dynamic_max = duration; + } dynamic_sum += duration; } } - const double static_avg = static_sum/runs; - const double dynamic_avg = dynamic_sum/runs; + const double static_avg = static_sum / runs; + const double dynamic_avg = dynamic_sum / runs; std::cout << "static min=" << static_min << "ms avg=" << static_avg << "ms max=" << static_max << "ms\n"; std::cout << "dynamic min=" << dynamic_min << "ms avg=" << dynamic_avg << "ms max=" << dynamic_max << "ms\n"; diff --git a/third_party/libosmium/build-appveyor.bat b/third_party/libosmium/build-appveyor.bat index ef9da5ffd1e..74ea0c91a94 100644 --- a/third_party/libosmium/build-appveyor.bat +++ b/third_party/libosmium/build-appveyor.bat @@ -4,73 +4,33 @@ SET EL=0 ECHO ~~~~~~ %~f0 ~~~~~~ -SET CUSTOM_CMAKE=cmake-3.6.2-win64-x64 -::show all available env vars SET -ECHO cmake on AppVeyor -cmake -version ECHO activating VS cmd prompt && CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 IF %ERRORLEVEL% NEQ 0 GOTO ERROR -SET lodir=%CD% -SET PATH=%lodir%\%CUSTOM_CMAKE%\bin;%PATH% -SET LODEPSDIR=%lodir%\libosmium-deps -SET PROJ_LIB=%LODEPSDIR%\proj\share -SET GDAL_DATA=%LODEPSDIR%\gdal\data -::gdal.dll -SET PATH=%LODEPSDIR%\gdal\lib;%PATH% -::geos.dll -SET PATH=%LODEPSDIR%\geos\lib;%PATH% -::libtiff.dll -SET PATH=%LODEPSDIR%\libtiff\lib;%PATH% -::jpeg.dll -SET PATH=%LODEPSDIR%\jpeg\lib;%PATH% -::libexpat.dll -SET PATH=%LODEPSDIR%\expat\lib;%PATH% -::zlibwapi.dll -SET PATH=%LODEPSDIR%\zlib\lib;%PATH% -::convert backslashes in bzip2 path to forward slashes -::cmake cannot find it otherwise -SET LIBBZIP2=%LODEPSDIR%\bzip2\lib\libbz2.lib -SET LIBBZIP2=%LIBBZIP2:\=/% - -IF NOT EXIST cm.7z ECHO downloading cmake %CUSTOM_CMAKE% ... && powershell Invoke-WebRequest https://mapbox.s3.amazonaws.com/windows-builds/windows-build-deps/%CUSTOM_CMAKE%.7z -OutFile cm.7z -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +CD .. -IF NOT EXIST lodeps.7z ECHO downloading binary dependencies... && powershell Invoke-WebRequest https://mapbox.s3.amazonaws.com/windows-builds/windows-build-deps/libosmium-deps-win-14.0-x64.7z -OutFile lodeps.7z +nuget install expat.v140 -Version 2.2.5 IF %ERRORLEVEL% NEQ 0 GOTO ERROR -IF NOT EXIST %CUSTOM_CMAKE% ECHO extracting cmake... && 7z x cm.7z | %windir%\system32\find "ing archive" -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +SET PATH=C:/projects/expat.v140.2.2.5/build/native/bin/x64/%config%;%PATH% -IF NOT EXIST %LODEPSDIR% ECHO extracting binary dependencies... && 7z x lodeps.7z | %windir%\system32\find "ing archive" +nuget install zlib-vc140-static-64 -Version 1.2.11 IF %ERRORLEVEL% NEQ 0 GOTO ERROR -ECHO %LODEPSDIR% -DIR %LODEPSDIR% -::TREE %LODEPSDIR% - -::powershell (Get-ChildItem $env:LODEPSDIR\boost\lib -Filter *boost*.dll)[0].BaseName.split('_')[-1] -FOR /F "tokens=1 usebackq" %%i in (`powershell ^(Get-ChildItem %LODEPSDIR%\boost\lib -Filter *boost*.dll^)[0].BaseName.split^('_'^)[-1]`) DO SET BOOST_VERSION=%%i +nuget install bzip2.v140 -Version 1.0.6.9 IF %ERRORLEVEL% NEQ 0 GOTO ERROR -ECHO BOOST_VERSION^: %BOOST_VERSION% +SET PATH=C:/projects/bzip2.v140.1.0.6.9/build/native/bin/x64/%config%;%PATH% -ECHO our own cmake -cmake -version +CD libosmium -CD %lodir%\.. +ECHO config^: %config% -IF NOT EXIST osm-testdata ECHO cloning osm-testdata && git clone --depth 1 https://github.com/osmcode/osm-testdata.git -IF %ERRORLEVEL% NEQ 0 GOTO ERROR -CD osm-testdata -git fetch -IF %ERRORLEVEL% NEQ 0 GOTO ERROR -git pull -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +SET libpostfix="" +IF "%config%"=="Debug" SET libpostfix="d" -CD %lodir% IF EXIST build ECHO deleting build dir... && RD /Q /S build IF %ERRORLEVEL% NEQ 0 GOTO ERROR @@ -78,20 +38,21 @@ MKDIR build IF %ERRORLEVEL% NEQ 0 GOTO ERROR CD build -ECHO config^: %config% ::This will produce lots of LNK4099 warnings which can be ignored. ::Unfortunately they can't be disabled, see -::http://stackoverflow.com/questions/661606/visual-c-how-to-disable-specific-linker-warnings -SET CMAKE_CMD=cmake .. ^ --LA -G "Visual Studio 14 Win64" ^ +::https://stackoverflow.com/questions/661606/visual-c-how-to-disable-specific-linker-warnings +SET CMAKE_CMD=cmake .. -LA -G "Visual Studio 14 Win64" ^ -DOsmium_DEBUG=TRUE ^ -DCMAKE_BUILD_TYPE=%config% ^ -DBUILD_HEADERS=OFF ^ --DBOOST_ROOT=%LODEPSDIR%\boost ^ --DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib ^ --DBZIP2_LIBRARY_RELEASE=%LIBBZIP2% ^ --DCMAKE_PREFIX_PATH=%LODEPSDIR%\zlib;%LODEPSDIR%\expat;%LODEPSDIR%\bzip2;%LODEPSDIR%\geos;%LODEPSDIR%\gdal;%LODEPSDIR%\proj;%LODEPSDIR%\sparsehash;%LODEPSDIR%\wingetopt +-DBOOST_ROOT=C:/Libraries/boost_1_63_0 ^ +-DZLIB_INCLUDE_DIR=C:/projects/zlib-vc140-static-64.1.2.11/lib/native/include ^ +-DZLIB_LIBRARY=C:/projects/zlib-vc140-static-64.1.2.11/lib/native/libs/x64/static/%config%/zlibstatic.lib ^ +-DEXPAT_INCLUDE_DIR=C:/projects/expat.v140.2.2.5/build/native/include ^ +-DEXPAT_LIBRARY=C:/projects/expat.v140.2.2.5/build/native/lib/x64/%config%/libexpat%libpostfix%.lib ^ +-DBZIP2_INCLUDE_DIR=C:/projects/bzip2.v140.1.0.6.9/build/native/include ^ +-DBZIP2_LIBRARIES=C:/projects/bzip2.v140.1.0.6.9/build/native/lib/x64/%config%/libbz2%libpostfix%.lib ECHO calling^: %CMAKE_CMD% %CMAKE_CMD% @@ -107,12 +68,9 @@ msbuild libosmium.sln ^ /p:PlatformToolset=v140 %avlogger% IF %ERRORLEVEL% NEQ 0 GOTO ERROR -ctest --output-on-failure ^ --C %config% ^ --E testdata-overview +ctest --output-on-failure -C %config% -E testdata-overview IF %ERRORLEVEL% NEQ 0 GOTO ERROR - GOTO DONE :ERROR diff --git a/third_party/libosmium/build-local.bat b/third_party/libosmium/build-local.bat index 202d0b2fa68..c2d6e8d9ab3 100644 --- a/third_party/libosmium/build-local.bat +++ b/third_party/libosmium/build-local.bat @@ -6,11 +6,11 @@ ECHO ~~~~~~ %~f0 ~~~~~~ ECHO. ECHO build-local ["config=Dev"] -ECHO default config^: RelWithDebInfo +ECHO default config^: Release ECHO. SET platform=x64 -SET config=RelWithDebInfo +SET config=Release :: OVERRIDE PARAMETERS >>>>>>>> :NEXT-ARG @@ -24,9 +24,6 @@ GOTO NEXT-ARG :ARGS-DONE ::<<<<< OVERRIDE PARAMETERS -WHERE 7z -IF %ERRORLEVEL% NEQ 0 ECHO 7zip not on PATH && GOTO ERROR - CALL build-appveyor.bat IF %ERRORLEVEL% NEQ 0 GOTO ERROR diff --git a/third_party/libosmium/build-msys2.bat b/third_party/libosmium/build-msys2.bat new file mode 100644 index 00000000000..a4f0f7a1c6e --- /dev/null +++ b/third_party/libosmium/build-msys2.bat @@ -0,0 +1,41 @@ +@ECHO OFF +SETLOCAL +SET EL=0 + +ECHO ~~~~~~ %~f0 ~~~~~~ + +echo "Adding MSYS2 to path..." +SET "PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%" +echo %PATH% + +echo "Installing MSYS2 packages..." +bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-gcc mingw-w64-x86_64-geos mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-cppcheck mingw-w64-x86_64-doxygen mingw-w64-x86_64-gdb mingw-w64-x86_64-sparsehash mingw-w64-x86_64-gdal mingw-w64-x86_64-ruby mingw-w64-x86_64-libspatialite mingw-w64-x86_64-spatialite-tools mingw-w64-x86_64-clang-tools-extra" +bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-postgresql mingw-w64-x86_64-netcdf mingw-w64-x86_64-crypto++" +call C:\msys64\mingw64\bin\gem.cmd install json + +echo "Setting PROJ_LIB variable for correct PROJ.4 working" +set PROJ_LIB=c:\msys64\mingw64\share\proj + +echo "Generating makefiles" +mkdir build +cd build +cmake .. -G "MSYS Makefiles" -DBUILD_DATA_TESTS=ON -DBUILD_HEADERS=OFF +IF %ERRORLEVEL% NEQ 0 GOTO ERROR + +echo "Building" +make +IF %ERRORLEVEL% NEQ 0 GOTO ERROR + +echo "Testing" +ctest --output-on-failure +IF %ERRORLEVEL% NEQ 0 GOTO ERROR + +:ERROR +ECHO ~~~~~~ ERROR %~f0 ~~~~~~ +SET EL=%ERRORLEVEL% + +:DONE +IF %EL% NEQ 0 ECHO. && ECHO !!! ERRORLEVEL^: %EL% !!! && ECHO. +ECHO ~~~~~~ DONE %~f0 ~~~~~~ + +EXIT /b %EL% diff --git a/third_party/libosmium/cmake/FindGem.cmake b/third_party/libosmium/cmake/FindGem.cmake index f5389d1e832..5d78a9026f0 100644 --- a/third_party/libosmium/cmake/FindGem.cmake +++ b/third_party/libosmium/cmake/FindGem.cmake @@ -1,5 +1,7 @@ # Author thomas.roehr@dfki.de # +# Version 0.31 2017-09-15 +# - find gem executable gem.cmd on Windows # Version 0.3 2013-07-02 # - rely on `gem content` to find library and header # - introduce GEM_OS_PKG to allow search via pkgconfig @@ -28,7 +30,7 @@ # Check for how 'gem' should be called include(FindPackageHandleStandardArgs) find_program(GEM_EXECUTABLE - NAMES "gem${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}" + NAMES "gem.cmd" "gem${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}" "gem${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}" "gem-${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}" "gem-${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}" diff --git a/third_party/libosmium/cmake/FindOsmium.cmake b/third_party/libosmium/cmake/FindOsmium.cmake index adc457f9a2d..9eaf7349e8f 100644 --- a/third_party/libosmium/cmake/FindOsmium.cmake +++ b/third_party/libosmium/cmake/FindOsmium.cmake @@ -54,8 +54,7 @@ # #---------------------------------------------------------------------- -# This is the list of directories where we look for osmium and protozero -# includes. +# This is the list of directories where we look for osmium includes. set(_osmium_include_path ../libosmium ~/Library/Frameworks @@ -112,29 +111,14 @@ endif() if(Osmium_USE_PBF) find_package(ZLIB) find_package(Threads) - - message(STATUS "Looking for protozero") - find_path(PROTOZERO_INCLUDE_DIR protozero/version.hpp - PATH_SUFFIXES include - PATHS ${_osmium_include_path} - ${OSMIUM_INCLUDE_DIR} - ) - if(PROTOZERO_INCLUDE_DIR) - message(STATUS "Looking for protozero - found") - else() - message(STATUS "Looking for protozero - not found") - endif() + find_package(Protozero 1.5.1) list(APPEND OSMIUM_EXTRA_FIND_VARS ZLIB_FOUND Threads_FOUND PROTOZERO_INCLUDE_DIR) - if(ZLIB_FOUND AND Threads_FOUND AND PROTOZERO_INCLUDE_DIR) + if(ZLIB_FOUND AND Threads_FOUND AND PROTOZERO_FOUND) list(APPEND OSMIUM_PBF_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) - if(WIN32) - # This is needed for the ntohl() function - list(APPEND OSMIUM_PBF_LIBRARIES ws2_32) - endif() list(APPEND OSMIUM_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} ${PROTOZERO_INCLUDE_DIR} @@ -361,10 +345,10 @@ endif() set(OSMIUM_DRACONIC_CLANG_OPTIONS "-Wdocumentation -Wunused-exception-parameter -Wmissing-declarations -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-exit-time-destructors -Wno-global-constructors -Wno-padded -Wno-switch-enum -Wno-missing-prototypes -Wno-weak-vtables -Wno-cast-align -Wno-float-equal") if(Osmium_DEBUG) - message(STATUS "OSMIUM_XML_LIBRARIES=" ${OSMIUM_XML_LIBRARIES}) - message(STATUS "OSMIUM_PBF_LIBRARIES=" ${OSMIUM_PBF_LIBRARIES}) - message(STATUS "OSMIUM_IO_LIBRARIES=" ${OSMIUM_IO_LIBRARIES}) - message(STATUS "OSMIUM_LIBRARIES=" ${OSMIUM_LIBRARIES}) - message(STATUS "OSMIUM_INCLUDE_DIRS=" ${OSMIUM_INCLUDE_DIRS}) + message(STATUS "OSMIUM_XML_LIBRARIES=${OSMIUM_XML_LIBRARIES}") + message(STATUS "OSMIUM_PBF_LIBRARIES=${OSMIUM_PBF_LIBRARIES}") + message(STATUS "OSMIUM_IO_LIBRARIES=${OSMIUM_IO_LIBRARIES}") + message(STATUS "OSMIUM_LIBRARIES=${OSMIUM_LIBRARIES}") + message(STATUS "OSMIUM_INCLUDE_DIRS=${OSMIUM_INCLUDE_DIRS}") endif() diff --git a/third_party/libosmium/cmake/FindProtozero.cmake b/third_party/libosmium/cmake/FindProtozero.cmake new file mode 100644 index 00000000000..ad16cabeb00 --- /dev/null +++ b/third_party/libosmium/cmake/FindProtozero.cmake @@ -0,0 +1,63 @@ +#---------------------------------------------------------------------- +# +# FindProtozero.cmake +# +# Find the protozero headers. +# +#---------------------------------------------------------------------- +# +# Usage: +# +# Copy this file somewhere into your project directory, where cmake can +# find it. Usually this will be a directory called "cmake" which you can +# add to the CMake module search path with the following line in your +# CMakeLists.txt: +# +# list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +# +# Then add the following in your CMakeLists.txt: +# +# find_package(Protozero [version] [REQUIRED]) +# include_directories(SYSTEM ${PROTOZERO_INCLUDE_DIR}) +# +# The version number is optional. If it is not set, any version of +# protozero will do. +# +# if(NOT PROTOZERO_FOUND) +# message(WARNING "Protozero not found!\n") +# endif() +# +#---------------------------------------------------------------------- +# +# Variables: +# +# PROTOZERO_FOUND - True if Protozero was found. +# PROTOZERO_INCLUDE_DIR - Where to find include files. +# +#---------------------------------------------------------------------- + +# find include path +find_path(PROTOZERO_INCLUDE_DIR protozero/version.hpp + PATH_SUFFIXES include + PATHS ${CMAKE_SOURCE_DIR}/../protozero +) + +# Check version number +if(Protozero_FIND_VERSION) + file(STRINGS "${PROTOZERO_INCLUDE_DIR}/protozero/version.hpp" _version_define REGEX "#define PROTOZERO_VERSION_STRING") + if("${_version_define}" MATCHES "#define PROTOZERO_VERSION_STRING \"([0-9.]+)\"") + set(_version "${CMAKE_MATCH_1}") + else() + set(_version "unknown") + endif() +endif() + +#set(PROTOZERO_INCLUDE_DIRS "${PROTOZERO_INCLUDE_DIR}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Protozero + REQUIRED_VARS PROTOZERO_INCLUDE_DIR + VERSION_VAR _version) + + +#---------------------------------------------------------------------- diff --git a/third_party/libosmium/examples/CMakeLists.txt b/third_party/libosmium/examples/CMakeLists.txt index c4f875f43d2..c1498cc3522 100644 --- a/third_party/libosmium/examples/CMakeLists.txt +++ b/third_party/libosmium/examples/CMakeLists.txt @@ -30,25 +30,6 @@ set(EXAMPLES ) -#----------------------------------------------------------------------------- -# -# Examples depending on wingetopt -# -#----------------------------------------------------------------------------- -set(GETOPT_EXAMPLES area_test convert index_lookup) -if(NOT GETOPT_MISSING) - foreach(example ${GETOPT_EXAMPLES}) - list(APPEND EXAMPLE_LIBS_${example} ${GETOPT_LIBRARY}) - endforeach() -else() - message(STATUS "Configuring examples - Skipping examples because on Visual Studio the wingetopt library is needed and was not found:") - foreach(example ${GETOPT_EXAMPLES}) - message(STATUS " - osmium_${example}") - list(REMOVE_ITEM EXAMPLES ${example}) - endforeach() -endif() - - #----------------------------------------------------------------------------- # # Configure examples diff --git a/third_party/libosmium/examples/osmium_area_test.cpp b/third_party/libosmium/examples/osmium_area_test.cpp index 948c032ed19..5a29472e5a4 100644 --- a/third_party/libosmium/examples/osmium_area_test.cpp +++ b/third_party/libosmium/examples/osmium_area_test.cpp @@ -26,7 +26,7 @@ */ #include // for std::exit -#include // for getopt_long +#include // for std::strcmp #include // for std::cout, std::cerr // For assembling multipolygons @@ -91,13 +91,21 @@ void print_help() { << " -o, --dump-objects Dump area objects\n"; } +void print_usage(const char* prgname) { + std::cerr << "Usage: " << prgname << " [OPTIONS] OSMFILE\n"; + std::exit(1); +} + int main(int argc, char* argv[]) { - static struct option long_options[] = { - {"help", no_argument, nullptr, 'h'}, - {"dump-wkt", no_argument, nullptr, 'w'}, - {"dump-objects", no_argument, nullptr, 'o'}, - {nullptr, 0, nullptr, 0} - }; + if (argc > 1 && (!std::strcmp(argv[1], "-h") || + !std::strcmp(argv[1], "--help"))) { + print_help(); + std::exit(0); + } + + if (argc != 3) { + print_usage(argv[0]); + } // Initialize an empty DynamicHandler. Later it will be associated // with one of the handlers. You can think of the DynamicHandler as @@ -105,35 +113,15 @@ int main(int argc, char* argv[]) { // real handler. osmium::handler::DynamicHandler handler; - // Read options from command line. - while (true) { - const int c = getopt_long(argc, argv, "hwo", long_options, nullptr); - if (c == -1) { - break; - } - - switch (c) { - case 'h': - print_help(); - std::exit(0); - case 'w': - handler.set(); - break; - case 'o': - handler.set(std::cout); - break; - default: - std::exit(1); - } - } - - const int remaining_args = argc - optind; - if (remaining_args != 1) { - std::cerr << "Usage: " << argv[0] << " [OPTIONS] OSMFILE\n"; - std::exit(1); + if (!std::strcmp(argv[1], "-w") || !std::strcmp(argv[1], "--dump-wkt")) { + handler.set(); + } else if (!std::strcmp(argv[1], "-o") || !std::strcmp(argv[1], "--dump-objects")) { + handler.set(std::cout); + } else { + print_usage(argv[0]); } - osmium::io::File input_file{argv[optind]}; + osmium::io::File input_file{argv[2]}; // Configuration for the multipolygon assembler. Here the default settings // are used, but you could change multiple settings. diff --git a/third_party/libosmium/examples/osmium_change_tags.cpp b/third_party/libosmium/examples/osmium_change_tags.cpp index ae2e99e9880..e00ee0339fe 100644 --- a/third_party/libosmium/examples/osmium_change_tags.cpp +++ b/third_party/libosmium/examples/osmium_change_tags.cpp @@ -76,14 +76,14 @@ class RewriteHandler : public osmium::handler::Handler { // Iterate over all tags and build new tags using the new builder // based on the old ones. for (const auto& tag : tags) { - if (std::strcmp(tag.key(), "created_by")) { - if (!std::strcmp(tag.key(), "landuse") && !std::strcmp(tag.value(), "forest")) { - // add_tag() can be called with key and value C strings - builder.add_tag("natural", "wood"); - } else { - // add_tag() can also be called with an osmium::Tag - builder.add_tag(tag); - } + if (!std::strcmp(tag.key(), "created_by")) { + // ignore + } else if (!std::strcmp(tag.key(), "landuse") && !std::strcmp(tag.value(), "forest")) { + // add_tag() can be called with key and value C strings + builder.add_tag("natural", "wood"); + } else { + // add_tag() can also be called with an osmium::Tag + builder.add_tag(tag); } } } diff --git a/third_party/libosmium/examples/osmium_convert.cpp b/third_party/libosmium/examples/osmium_convert.cpp index dfa0abd4a6e..d28663b893d 100644 --- a/third_party/libosmium/examples/osmium_convert.cpp +++ b/third_party/libosmium/examples/osmium_convert.cpp @@ -18,8 +18,8 @@ */ #include // for std::exit +#include // for std::strcmp #include // for std::exception -#include // for getopt_long #include // for std::cout, std::cerr #include // for std::string @@ -51,13 +51,21 @@ void print_help() { << " -t, --to-format=FORMAT Output format\n"; } +void print_usage(const char* prgname) { + std::cerr << "Usage: " << prgname << " [OPTIONS] [INFILE [OUTFILE]]\n"; + std::exit(0); +} + int main(int argc, char* argv[]) { - static struct option long_options[] = { - {"help", no_argument, nullptr, 'h'}, - {"from-format", required_argument, nullptr, 'f'}, - {"to-format", required_argument, nullptr, 't'}, - {nullptr, 0, nullptr, 0} - }; + if (argc == 1) { + print_usage(argv[0]); + } + + if (argc > 1 && (!std::strcmp(argv[1], "-h") || + !std::strcmp(argv[1], "--help"))) { + print_help(); + std::exit(0); + } // Input and output format are empty by default. Later this will mean that // the format should be taken from the input and output file suffix, @@ -65,44 +73,35 @@ int main(int argc, char* argv[]) { std::string input_format; std::string output_format; - // Read options from command line. - while (true) { - const int c = getopt_long(argc, argv, "dhf:t:", long_options, nullptr); - if (c == -1) { - break; - } - - switch (c) { - case 'h': - print_help(); - std::exit(0); - case 'f': - input_format = optarg; - break; - case 't': - output_format = optarg; - break; - default: - std::exit(1); - } - } - - const int remaining_args = argc - optind; - if (remaining_args == 0 || remaining_args > 2) { - std::cerr << "Usage: " << argv[0] << " [OPTIONS] [INFILE [OUTFILE]]\n"; - std::exit(1); - } - - // Get input file name from command line. std::string input_file_name; - if (remaining_args >= 1) { - input_file_name = argv[optind]; - } - - // Get output file name from command line. std::string output_file_name; - if (remaining_args == 2) { - output_file_name = argv[optind+1]; + + for (int i = 1; i < argc; ++i) { + if (!std::strcmp(argv[i], "-f") || !std::strcmp(argv[i], "--from-format")) { + ++i; + if (i < argc) { + input_format = argv[i]; + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--from-format=", 14)) { + input_format = argv[i] + 14; + } else if (!std::strcmp(argv[i], "-t") || !std::strcmp(argv[i], "--to-format")) { + ++i; + if (i < argc) { + output_format = argv[i]; + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--to-format=", 12)) { + output_format = argv[i] + 12; + } else if (input_file_name.empty()) { + input_file_name = argv[i]; + } else if (output_file_name.empty()) { + output_file_name = argv[i]; + } else { + print_usage(argv[0]); + } } // This declares the input and output files using either the suffix of diff --git a/third_party/libosmium/examples/osmium_count.cpp b/third_party/libosmium/examples/osmium_count.cpp index 7de1b6b7c6e..130b98a0ccc 100644 --- a/third_party/libosmium/examples/osmium_count.cpp +++ b/third_party/libosmium/examples/osmium_count.cpp @@ -43,17 +43,17 @@ struct CountHandler : public osmium::handler::Handler { std::uint64_t relations = 0; // This callback is called by osmium::apply for each node in the data. - void node(const osmium::Node&) noexcept { + void node(const osmium::Node& /*node*/) noexcept { ++nodes; } // This callback is called by osmium::apply for each way in the data. - void way(const osmium::Way&) noexcept { + void way(const osmium::Way& /*way*/) noexcept { ++ways; } // This callback is called by osmium::apply for each relation in the data. - void relation(const osmium::Relation&) noexcept { + void relation(const osmium::Relation& /*relation*/) noexcept { ++relations; } diff --git a/third_party/libosmium/examples/osmium_create_pois.cpp b/third_party/libosmium/examples/osmium_create_pois.cpp index df27bfeff7b..dedbdb88aa2 100644 --- a/third_party/libosmium/examples/osmium_create_pois.cpp +++ b/third_party/libosmium/examples/osmium_create_pois.cpp @@ -31,11 +31,8 @@ #include // We want to use the builder interface -#include #include - -// Declare this to use the functions starting with the underscore (_) below. -using namespace osmium::builder::attr; +#include int main(int argc, char* argv[]) { if (argc != 2) { @@ -56,6 +53,9 @@ int main(int argc, char* argv[]) { const size_t initial_buffer_size = 10000; osmium::memory::Buffer buffer{initial_buffer_size, osmium::memory::Buffer::auto_grow::yes}; + // Declare this to use the functions starting with the underscore (_) below. + using namespace osmium::builder::attr; // NOLINT(google-build-using-namespace) + // Add nodes to the buffer. This is, of course, only an example. // You can set any of the attributes and more tags, etc. Ways and // relations can be added in a similar way. diff --git a/third_party/libosmium/examples/osmium_dump_internal.cpp b/third_party/libosmium/examples/osmium_dump_internal.cpp index 78229dadcd5..39523fa5472 100644 --- a/third_party/libosmium/examples/osmium_dump_internal.cpp +++ b/third_party/libosmium/examples/osmium_dump_internal.cpp @@ -29,8 +29,8 @@ */ #include // for errno -#include // for std::strerror #include // for std::exit +#include // for std::strerror #include // for std::cout, std::cerr #include // for std::string #include // for open @@ -71,7 +71,7 @@ class IndexFile { public: explicit IndexFile(const std::string& filename) : - m_fd(::open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666)) { + m_fd(::open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666)) { // NOLINT(hicpp-signed-bitwise) if (m_fd < 0) { std::cerr << "Can't open index file '" << filename << "': " << std::strerror(errno) << "\n"; std::exit(2); @@ -81,6 +81,12 @@ class IndexFile { #endif } + IndexFile(const IndexFile&) = delete; + IndexFile& operator=(const IndexFile&) = delete; + + IndexFile(IndexFile&&) = delete; + IndexFile& operator=(IndexFile&&) = delete; + ~IndexFile() { if (m_fd >= 0) { close(m_fd); @@ -115,7 +121,7 @@ int main(int argc, char* argv[]) { // Create the output file which will contain our serialized OSM data const std::string data_file{output_dir + "/data.osm.ser"}; - const int data_fd = ::open(data_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666); + const int data_fd = ::open(data_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666); // NOLINT(hicpp-signed-bitwise) if (data_fd < 0) { std::cerr << "Can't open data file '" << data_file << "': " << std::strerror(errno) << "\n"; std::exit(2); diff --git a/third_party/libosmium/examples/osmium_filter_discussions.cpp b/third_party/libosmium/examples/osmium_filter_discussions.cpp index c2a94e5a272..c4d092a0a38 100644 --- a/third_party/libosmium/examples/osmium_filter_discussions.cpp +++ b/third_party/libosmium/examples/osmium_filter_discussions.cpp @@ -3,7 +3,7 @@ EXAMPLE osmium_filter_discussions Read OSM changesets with discussions from a changeset dump like the one - you get from http://planet.osm.org/planet/discussions-latest.osm.bz2 + you get from https://planet.osm.org/planet/discussions-latest.osm.bz2 and write out only those changesets which have discussions (ie comments). DEMONSTRATES USE OF: diff --git a/third_party/libosmium/examples/osmium_index_lookup.cpp b/third_party/libosmium/examples/osmium_index_lookup.cpp index 2af2378339d..2f428bf7cd5 100644 --- a/third_party/libosmium/examples/osmium_index_lookup.cpp +++ b/third_party/libosmium/examples/osmium_index_lookup.cpp @@ -24,8 +24,8 @@ #include // for std::all_of, std::equal_range #include // for std::exit +#include // for std::strcmp #include // for open -#include // for getopt_long #include // for std::cout, std::cerr #include // for std::unique_ptr #include // for std::string @@ -64,6 +64,12 @@ class IndexAccess { return m_fd; } + IndexAccess(const IndexAccess&) = delete; + IndexAccess& operator=(const IndexAccess&) = delete; + + IndexAccess(IndexAccess&&) = delete; + IndexAccess& operator=(IndexAccess&&) = delete; + virtual ~IndexAccess() = default; virtual void dump() const = 0; @@ -83,7 +89,7 @@ class IndexAccess { template class IndexAccessDense : public IndexAccess { - using index_type = typename osmium::index::map::DenseFileArray; + using index_type = typename osmium::index::map::DenseFileArray; public: @@ -187,58 +193,70 @@ class Options { ; } + void print_usage(const char* prgname) { + std::cout << "Usage: " << prgname << " [OPTIONS]\n\n"; + std::exit(0); + } + public: Options(int argc, char* argv[]) { if (argc == 1) { - print_help(); - std::exit(1); + print_usage(argv[0]); } - static struct option long_options[] = { - {"array", required_argument, nullptr, 'a'}, - {"dump", no_argument, nullptr, 'd'}, - {"help", no_argument, nullptr, 'h'}, - {"list", required_argument, nullptr, 'l'}, - {"search", required_argument, nullptr, 's'}, - {"type", required_argument, nullptr, 't'}, - {nullptr, 0, nullptr, 0} - }; - - while (true) { - const int c = getopt_long(argc, argv, "a:dhl:s:t:", long_options, nullptr); - if (c == -1) { - break; - } + if (argc > 1 && (!std::strcmp(argv[1], "-h") || + !std::strcmp(argv[1], "--help"))) { + print_help(); + std::exit(0); + } - switch (c) { - case 'a': + for (int i = 1; i < argc; ++i) { + if (!std::strcmp(argv[i], "-a") || !std::strcmp(argv[i], "--array")) { + ++i; + if (i < argc) { m_array_format = true; - m_filename = optarg; - break; - case 'd': - m_dump = true; - break; - case 'h': - print_help(); - std::exit(0); - case 'l': + m_filename = argv[i]; + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--array=", 8)) { + m_array_format = true; + m_filename = argv[i] + 8; + } else if (!std::strcmp(argv[i], "-l") || !std::strcmp(argv[i], "--list")) { + ++i; + if (i < argc) { m_list_format = true; - m_filename = optarg; - break; - case 's': - m_ids.push_back(std::atoll(optarg)); - break; - case 't': - m_type = optarg; - if (m_type != "location" && m_type != "id" && m_type != "offset") { - std::cerr << "Unknown type '" << m_type - << "'. Must be 'location', 'id', or 'offset'.\n"; - std::exit(2); - } - break; - default: - std::exit(2); + m_filename = argv[i]; + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--list=", 7)) { + m_list_format = true; + m_filename = argv[i] + 7; + } else if (!std::strcmp(argv[i], "-d") || !std::strcmp(argv[i], "--dump")) { + m_dump = true; + } else if (!std::strcmp(argv[i], "-s") || !std::strcmp(argv[i], "--search")) { + ++i; + if (i < argc) { + m_ids.push_back(std::atoll(argv[i])); // NOLINT(cert-err34-c) + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--search=", 9)) { + m_ids.push_back(std::atoll(argv[i] + 9)); // NOLINT(cert-err34-c) + } else if (!std::strcmp(argv[i], "-t") || !std::strcmp(argv[i], "--type")) { + ++i; + if (i < argc) { + m_type = argv[i]; + } else { + print_usage(argv[0]); + } + } else if (!std::strncmp(argv[i], "--type=", 7)) { + m_type = argv[i] + 7; + } else { + std::cerr << "Unknown command line options or arguments\n"; + print_usage(argv[0]); } } @@ -257,6 +275,11 @@ class Options { std::exit(2); } + if (m_type != "location" && m_type != "id" && m_type != "offset") { + std::cerr << "Unknown type '" << m_type + << "'. Must be 'location', 'id', or 'offset'.\n"; + std::exit(2); + } } const char* filename() const noexcept { @@ -302,9 +325,8 @@ int run(const IndexAccess& index, const Options& options) { if (options.do_dump()) { index.dump(); return 0; - } else { - return index.search(options.search_keys()) ? 0 : 1; } + return index.search(options.search_keys()) ? 0 : 1; } int main(int argc, char* argv[]) { @@ -329,16 +351,18 @@ int main(int argc, char* argv[]) { // index id -> location const auto index = create(options.dense_format(), fd); return run(*index, options); - } else if (options.type_is("id")) { + } + + if (options.type_is("id")) { // index id -> id const auto index = create(options.dense_format(), fd); return run(*index, options); - } else { - // index id -> offset - const auto index = create(options.dense_format(), fd); - return run(*index, options); } - } catch(const std::exception& e) { + + // index id -> offset + const auto index = create(options.dense_format(), fd); + return run(*index, options); + } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << '\n'; std::exit(1); } diff --git a/third_party/libosmium/examples/osmium_location_cache_create.cpp b/third_party/libosmium/examples/osmium_location_cache_create.cpp index a7119df6048..d1b381082e3 100644 --- a/third_party/libosmium/examples/osmium_location_cache_create.cpp +++ b/third_party/libosmium/examples/osmium_location_cache_create.cpp @@ -42,8 +42,8 @@ // For the location index. There are different types of index implementation // available. These implementations put the index on disk. See below. -#include #include +#include // For the NodeLocationForWays handler #include @@ -72,7 +72,7 @@ int main(int argc, char* argv[]) { osmium::io::Reader reader{input_filename, osmium::osm_entity_bits::node}; // Initialize location index on disk creating a new file. - const int fd = ::open(cache_filename.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666); + const int fd = ::open(cache_filename.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666); // NOLINT(hicpp-signed-bitwise) if (fd == -1) { std::cerr << "Can not open location cache file '" << cache_filename << "': " << std::strerror(errno) << "\n"; std::exit(1); diff --git a/third_party/libosmium/examples/osmium_read_with_progress.cpp b/third_party/libosmium/examples/osmium_read_with_progress.cpp index 81437a665df..415e78de886 100644 --- a/third_party/libosmium/examples/osmium_read_with_progress.cpp +++ b/third_party/libosmium/examples/osmium_read_with_progress.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { osmium::io::Reader reader{input_file}; // Initialize progress bar, enable it only if STDERR is a TTY. - osmium::ProgressBar progress{reader.file_size(), osmium::util::isatty(2)}; + osmium::ProgressBar progress{reader.file_size(), osmium::isatty(2)}; // OSM data comes in buffers, read until there are no more. while (osmium::memory::Buffer buffer = reader.read()) { diff --git a/third_party/libosmium/examples/osmium_tiles.cpp b/third_party/libosmium/examples/osmium_tiles.cpp index 7dbeb3e29ae..52a1a1f5d91 100644 --- a/third_party/libosmium/examples/osmium_tiles.cpp +++ b/third_party/libosmium/examples/osmium_tiles.cpp @@ -36,21 +36,21 @@ int main(int argc, char* argv[]) { std::exit(1); } - const int zoom = std::atoi(argv[1]); + const int zoom = std::atoi(argv[1]); // NOLINT(cert-err34-c) if (zoom < 0 || zoom > 30) { std::cerr << "ERROR: Zoom must be between 0 and 30\n"; std::exit(1); } - const double lon = std::atof(argv[2]); - const double lat = std::atof(argv[3]); - - // Create location from WGS84 coordinates. In Osmium the order of - // coordinate values is always x/longitude first, then y/latitude. - const osmium::Location location{lon, lat}; - - std::cout << "WGS84: lon=" << lon << " lat=" << lat << "\n"; + osmium::Location location{}; + try { + location.set_lon(argv[2]); + location.set_lat(argv[3]); + } catch (const osmium::invalid_location&) { + std::cerr << "ERROR: Location is invalid\n"; + std::exit(1); + } // A location can store some invalid locations, ie locations outside the // -180 to 180 and -90 to 90 degree range. This function checks for that. @@ -59,6 +59,8 @@ int main(int argc, char* argv[]) { std::exit(1); } + std::cout << "WGS84: lon=" << location.lon() << " lat=" << location.lat() << "\n"; + // Project the coordinates using a helper function. You can also use the // osmium::geom::MercatorProjection class. const osmium::geom::Coordinates c = osmium::geom::lonlat_to_mercator(location); diff --git a/third_party/libosmium/include/osmium/area/assembler.hpp b/third_party/libosmium/include/osmium/area/assembler.hpp index 461a1837613..29fd6a5968b 100644 --- a/third_party/libosmium/include/osmium/area/assembler.hpp +++ b/third_party/libosmium/include/osmium/area/assembler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include - #include #include #include @@ -50,6 +46,10 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include + namespace osmium { namespace area { @@ -111,8 +111,6 @@ namespace osmium { detail::BasicAssemblerWithTags(config) { } - ~Assembler() noexcept = default; - /** * Assemble an area from the given way. * The resulting area is put into the out_buffer. diff --git a/third_party/libosmium/include/osmium/area/assembler_config.hpp b/third_party/libosmium/include/osmium/area/assembler_config.hpp index 24bd60a99d2..fce53badb0a 100644 --- a/third_party/libosmium/include/osmium/area/assembler_config.hpp +++ b/third_party/libosmium/include/osmium/area/assembler_config.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/third_party/libosmium/include/osmium/area/assembler_legacy.hpp b/third_party/libosmium/include/osmium/area/assembler_legacy.hpp index e616c947cb1..2531ad863d7 100644 --- a/third_party/libosmium/include/osmium/area/assembler_legacy.hpp +++ b/third_party/libosmium/include/osmium/area/assembler_legacy.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include @@ -62,6 +50,18 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + namespace osmium { namespace area { @@ -207,8 +207,6 @@ namespace osmium { detail::BasicAssemblerWithTags(config) { } - ~AssemblerLegacy() noexcept = default; - /** * Assemble an area from the given way. * The resulting area is put into the out_buffer. @@ -335,7 +333,7 @@ namespace osmium { if (stats().wrong_role == 0) { detail::for_each_member(relation, members, [this, &ways_that_should_be_areas, &area_tags](const osmium::RelationMember& member, const osmium::Way& way) { if (!std::strcmp(member.role(), "inner")) { - if (!way.nodes().empty() && way.is_closed() && way.tags().size() > 0) { + if (!way.nodes().empty() && way.is_closed() && !way.tags().empty()) { const auto d = std::count_if(way.tags().cbegin(), way.tags().cend(), std::cref(filter())); if (d > 0) { osmium::tags::KeyFilter::iterator way_fi_begin(std::cref(filter()), way.tags().cbegin(), way.tags().cend()); diff --git a/third_party/libosmium/include/osmium/area/detail/basic_assembler.hpp b/third_party/libosmium/include/osmium/area/detail/basic_assembler.hpp index 94168a12d5f..485d2223923 100644 --- a/third_party/libosmium/include/osmium/area/detail/basic_assembler.hpp +++ b/third_party/libosmium/include/osmium/area/detail/basic_assembler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,20 @@ DEALINGS IN THE SOFTWARE. */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -45,21 +59,6 @@ DEALINGS IN THE SOFTWARE. #include #include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - namespace osmium { namespace area { @@ -70,19 +69,17 @@ namespace osmium { struct location_to_ring_map { osmium::Location location; - open_ring_its_type::iterator ring_it; - bool start; + open_ring_its_type::iterator ring_it{}; + bool start{false}; - location_to_ring_map(const osmium::Location& l, const open_ring_its_type::iterator& r, bool s) noexcept : + location_to_ring_map(osmium::Location l, open_ring_its_type::iterator r, const bool s) noexcept : location(l), ring_it(r), start(s) { } - explicit location_to_ring_map(const osmium::Location& l) noexcept : - location(l), - ring_it(), - start(false) { + explicit location_to_ring_map(osmium::Location l) noexcept : + location(l) { } const ProtoRing& ring() const noexcept { @@ -108,7 +105,7 @@ namespace osmium { struct slocation { - static constexpr const uint32_t invalid_item = 1 << 30; + static constexpr const uint32_t invalid_item = 1u << 30u; uint32_t item : 31; uint32_t reverse : 1; @@ -320,7 +317,7 @@ namespace osmium { const int64_t ly = end_location.y(); const auto z = (bx - ax)*(ly - ay) - (by - ay)*(lx - ax); if (debug()) { - std::cerr << " Segment XXXX z=" << z << "\n"; + std::cerr << " Segment z=" << z << '\n'; } if (z > 0) { nesting += segment->is_reverse() ? -1 : 1; @@ -623,8 +620,8 @@ namespace osmium { } void merge_two_rings(open_ring_its_type& open_ring_its, const location_to_ring_map& m1, const location_to_ring_map& m2) { - std::list::iterator r1 = *m1.ring_it; - std::list::iterator r2 = *m2.ring_it; + const auto r1 = *m1.ring_it; + const auto r2 = *m2.ring_it; if (r1->get_node_ref_stop().location() == r2->get_node_ref_start().location()) { r1->join_forward(*r2); @@ -689,13 +686,12 @@ namespace osmium { struct candidate { int64_t sum; - std::vector> rings; + std::vector> rings{}; osmium::Location start_location; osmium::Location stop_location; explicit candidate(location_to_ring_map& ring, bool reverse) : sum(ring.ring().sum()), - rings(), start_location(ring.ring().get_node_ref_start().location()), stop_location(ring.ring().get_node_ref_stop().location()) { rings.emplace_back(ring, reverse); @@ -813,8 +809,8 @@ namespace osmium { ++m_stats.open_rings; if (m_config.problem_reporter) { for (auto& it : open_ring_its) { - m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_start()); - m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_stop()); + m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_start(), nullptr); + m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_stop(), nullptr); } } } @@ -939,20 +935,6 @@ namespace osmium { return true; } - /** - * Checks if any ways were completely removed in the - * erase_duplicate_segments step. - */ - bool ways_were_lost() { - std::unordered_set ways_in_segments; - - for (const auto& segment : m_segment_list) { - ways_in_segments.insert(segment.way()); - } - - return ways_in_segments.size() < m_num_members; - } - #ifdef OSMIUM_WITH_TIMER static bool print_header() { std::cout << "nodes outer_rings inner_rings sort dupl intersection locations split simple_case complex_case roles_check\n"; @@ -1022,15 +1004,6 @@ namespace osmium { return false; } - // If one or more complete ways was removed because of - // duplicate segments, this isn't a valid area. - if (ways_were_lost()) { - if (debug()) { - std::cerr << " Complete ways removed because of duplicate segments\n"; - } - return false; - } - if (m_config.debug_level >= 3) { std::cerr << "Sorted de-duplicated segment list:\n"; for (const auto& s : m_segment_list) { @@ -1170,8 +1143,6 @@ namespace osmium { #endif } - ~BasicAssembler() noexcept = default; - const AssemblerConfig& config() const noexcept { return m_config; } diff --git a/third_party/libosmium/include/osmium/area/detail/basic_assembler_with_tags.hpp b/third_party/libosmium/include/osmium/area/detail/basic_assembler_with_tags.hpp index 1e946805cfe..821e914de08 100644 --- a/third_party/libosmium/include/osmium/area/detail/basic_assembler_with_tags.hpp +++ b/third_party/libosmium/include/osmium/area/detail/basic_assembler_with_tags.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE. */ -#include - #include #include #include #include #include +#include + namespace osmium { namespace area { @@ -68,7 +68,7 @@ namespace osmium { static void copy_tags_without_type(osmium::builder::AreaBuilder& builder, const osmium::TagList& tags) { osmium::builder::TagListBuilder tl_builder{builder}; for (const osmium::Tag& tag : tags) { - if (std::strcmp(tag.key(), "type")) { + if (std::strcmp(tag.key(), "type") != 0) { tl_builder.add_tag(tag.key(), tag.value()); } } diff --git a/third_party/libosmium/include/osmium/area/detail/node_ref_segment.hpp b/third_party/libosmium/include/osmium/area/detail/node_ref_segment.hpp index 8039579b2e6..dc3782dbee1 100644 --- a/third_party/libosmium/include/osmium/area/detail/node_ref_segment.hpp +++ b/third_party/libosmium/include/osmium/area/detail/node_ref_segment.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE. */ +#include +#include +#include + #include #include #include #include #include -#include -#include -#include - namespace osmium { class Way; @@ -74,20 +74,20 @@ namespace osmium { class NodeRefSegment { // First node in order described above. - osmium::NodeRef m_first; + osmium::NodeRef m_first{}; // Second node in order described above. - osmium::NodeRef m_second; + osmium::NodeRef m_second{}; // Way this segment was from. - const osmium::Way* m_way; + const osmium::Way* m_way = nullptr; // The ring this segment is part of. Initially nullptr, this // will be filled in once we know which ring the segment is in. - ProtoRing* m_ring; + ProtoRing* m_ring = nullptr; // The role of this segment from the member role. - role_type m_role; + role_type m_role = role_type::unknown; // Nodes have to be reversed to get the intended order. bool m_reverse = false; @@ -98,19 +98,12 @@ namespace osmium { public: - NodeRefSegment() noexcept : - m_first(), - m_second(), - m_way(nullptr), - m_ring(nullptr), - m_role(role_type::unknown) { - } + NodeRefSegment() noexcept = default; NodeRefSegment(const osmium::NodeRef& nr1, const osmium::NodeRef& nr2, role_type role, const osmium::Way* way) noexcept : m_first(nr1), m_second(nr2), m_way(way), - m_ring(nullptr), m_role(role) { if (nr2.location() < nr1.location()) { using std::swap; @@ -303,7 +296,7 @@ namespace osmium { * or a defined Location if the segments intersect. */ inline osmium::Location calculate_intersection(const NodeRefSegment& s1, const NodeRefSegment& s2) noexcept { - // See http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect + // See https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect // for some hints about how the algorithm works. const vec p0{s1.first()}; const vec p1{s1.second()}; diff --git a/third_party/libosmium/include/osmium/area/detail/proto_ring.hpp b/third_party/libosmium/include/osmium/area/detail/proto_ring.hpp index 7ab353b882c..6be29f94d72 100644 --- a/third_party/libosmium/include/osmium/area/detail/proto_ring.hpp +++ b/third_party/libosmium/include/osmium/area/detail/proto_ring.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,10 @@ DEALINGS IN THE SOFTWARE. */ +#include +#include +#include + #include #include #include @@ -40,10 +44,6 @@ DEALINGS IN THE SOFTWARE. #include #include -#include -#include -#include - namespace osmium { class Way; @@ -64,18 +64,18 @@ namespace osmium { private: // Segments in this ring. - segments_type m_segments; + segments_type m_segments{}; // If this is an outer ring, these point to it's inner rings // (if any). - std::vector m_inner; + std::vector m_inner{}; // The smallest segment. Will be kept current whenever a new // segment is added to the ring. NodeRefSegment* m_min_segment; // If this is an inner ring, points to the outer ring. - ProtoRing* m_outer_ring; + ProtoRing* m_outer_ring = nullptr; #ifdef OSMIUM_DEBUG_RING_NO static int64_t next_num() noexcept { @@ -91,10 +91,7 @@ namespace osmium { public: explicit ProtoRing(NodeRefSegment* segment) noexcept : - m_segments(), - m_inner(), m_min_segment(segment), - m_outer_ring(nullptr), #ifdef OSMIUM_DEBUG_RING_NO m_num(next_num()), #endif diff --git a/third_party/libosmium/include/osmium/area/detail/segment_list.hpp b/third_party/libosmium/include/osmium/area/detail/segment_list.hpp index 39e16abaeaf..776507b46a9 100644 --- a/third_party/libosmium/include/osmium/area/detail/segment_list.hpp +++ b/third_party/libosmium/include/osmium/area/detail/segment_list.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -43,15 +52,6 @@ DEALINGS IN THE SOFTWARE. #include #include -#include -#include -#include -#include -#include -#include -#include -#include - namespace osmium { namespace area { @@ -84,7 +84,7 @@ namespace osmium { using slist_type = std::vector; - slist_type m_segments; + slist_type m_segments{}; bool m_debug; @@ -144,7 +144,6 @@ namespace osmium { public: explicit SegmentList(bool debug) noexcept : - m_segments(), m_debug(debug) { } diff --git a/third_party/libosmium/include/osmium/area/detail/vector.hpp b/third_party/libosmium/include/osmium/area/detail/vector.hpp index e8ff0a501ff..dae6c634739 100644 --- a/third_party/libosmium/include/osmium/area/detail/vector.hpp +++ b/third_party/libosmium/include/osmium/area/detail/vector.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include #include +#include +#include + namespace osmium { namespace area { diff --git a/third_party/libosmium/include/osmium/area/geom_assembler.hpp b/third_party/libosmium/include/osmium/area/geom_assembler.hpp index 8fb3b3ac5dc..4c9fc276ea1 100644 --- a/third_party/libosmium/include/osmium/area/geom_assembler.hpp +++ b/third_party/libosmium/include/osmium/area/geom_assembler.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/third_party/libosmium/include/osmium/area/multipolygon_collector.hpp b/third_party/libosmium/include/osmium/area/multipolygon_collector.hpp index 9ad68e166d2..d57294120fd 100644 --- a/third_party/libosmium/include/osmium/area/multipolygon_collector.hpp +++ b/third_party/libosmium/include/osmium/area/multipolygon_collector.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include - #include #include #include @@ -48,6 +43,11 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include +#include + namespace osmium { namespace relations { diff --git a/third_party/libosmium/include/osmium/area/multipolygon_manager.hpp b/third_party/libosmium/include/osmium/area/multipolygon_manager.hpp index e5ee2c8f196..dd3c4d875b7 100644 --- a/third_party/libosmium/include/osmium/area/multipolygon_manager.hpp +++ b/third_party/libosmium/include/osmium/area/multipolygon_manager.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include - #include #include #include @@ -53,6 +46,13 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include +#include +#include +#include + namespace osmium { /** @@ -93,9 +93,9 @@ namespace osmium { * needed on closed ways or multipolygon relations * to build the area. */ - explicit MultipolygonManager(const assembler_config_type& assembler_config, const osmium::TagsFilter& filter = osmium::TagsFilter{true}) : - m_assembler_config(assembler_config), - m_filter(filter) { + explicit MultipolygonManager(assembler_config_type assembler_config, osmium::TagsFilter filter = osmium::TagsFilter{true}) : + m_assembler_config(std::move(assembler_config)), + m_filter(std::move(filter)) { } /** diff --git a/third_party/libosmium/include/osmium/area/multipolygon_manager_legacy.hpp b/third_party/libosmium/include/osmium/area/multipolygon_manager_legacy.hpp index 491557aa8f2..c611d3447f7 100644 --- a/third_party/libosmium/include/osmium/area/multipolygon_manager_legacy.hpp +++ b/third_party/libosmium/include/osmium/area/multipolygon_manager_legacy.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include - #include #include #include @@ -55,6 +48,13 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include +#include +#include +#include + namespace osmium { /** diff --git a/third_party/libosmium/include/osmium/area/problem_reporter.hpp b/third_party/libosmium/include/osmium/area/problem_reporter.hpp index 181d2d1ee64..36f0833fae8 100644 --- a/third_party/libosmium/include/osmium/area/problem_reporter.hpp +++ b/third_party/libosmium/include/osmium/area/problem_reporter.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE. */ -#include - #include #include #include +#include + namespace osmium { class NodeRef; @@ -62,18 +62,24 @@ namespace osmium { protected: // Type of object we are currently working on - osmium::item_type m_object_type; + osmium::item_type m_object_type = osmium::item_type::undefined; // ID of the relation/way we are currently working on - osmium::object_id_type m_object_id; + osmium::object_id_type m_object_id = 0; // Number of nodes in the area - size_t m_nodes; + size_t m_nodes = 0; public: ProblemReporter() = default; + ProblemReporter(const ProblemReporter&) = default; + ProblemReporter& operator=(const ProblemReporter&) = default; + + ProblemReporter(ProblemReporter&&) noexcept = default; + ProblemReporter& operator=(ProblemReporter&&) noexcept = default; + virtual ~ProblemReporter() = default; /** @@ -161,7 +167,7 @@ namespace osmium { * @param nr NodeRef of one end of the ring. * @param way Optional pointer to way the end node is in. */ - virtual void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) { + virtual void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) { } /** diff --git a/third_party/libosmium/include/osmium/area/problem_reporter_exception.hpp b/third_party/libosmium/include/osmium/area/problem_reporter_exception.hpp index cfc2b5428c5..2224f66eaae 100644 --- a/third_party/libosmium/include/osmium/area/problem_reporter_exception.hpp +++ b/third_party/libosmium/include/osmium/area/problem_reporter_exception.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include - #include #include #include +#include +#include + namespace osmium { class NodeRef; @@ -57,8 +57,6 @@ namespace osmium { ProblemReporterStream(m_sstream) { } - ~ProblemReporterException() override = default; - void report_duplicate_node(osmium::object_id_type node_id1, osmium::object_id_type node_id2, osmium::Location location) override { m_sstream.str(""); ProblemReporterStream::report_duplicate_node(node_id1, node_id2, location); @@ -90,7 +88,7 @@ namespace osmium { throw std::runtime_error{m_sstream.str()}; } - void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override { + void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override { m_sstream.str(""); ProblemReporterStream::report_ring_not_closed(nr, way); throw std::runtime_error{m_sstream.str()}; diff --git a/third_party/libosmium/include/osmium/area/problem_reporter_ogr.hpp b/third_party/libosmium/include/osmium/area/problem_reporter_ogr.hpp index 5f531c8f4f3..748cf059c54 100644 --- a/third_party/libosmium/include/osmium/area/problem_reporter_ogr.hpp +++ b/third_party/libosmium/include/osmium/area/problem_reporter_ogr.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -42,10 +42,6 @@ DEALINGS IN THE SOFTWARE. * @attention If you include this file, you'll need to link with `libgdal`. */ -#include - -#include - #include #include #include @@ -56,6 +52,10 @@ DEALINGS IN THE SOFTWARE. #include #include +#include + +#include + namespace osmium { namespace area { @@ -137,8 +137,6 @@ namespace osmium { ; } - ~ProblemReporterOGR() override = default; - void report_duplicate_node(osmium::object_id_type node_id1, osmium::object_id_type node_id2, osmium::Location location) override { write_point("duplicate_node", node_id1, node_id2, location); } @@ -162,7 +160,7 @@ namespace osmium { write_line("overlapping_segment", nr1.ref(), nr2.ref(), nr1.location(), nr2.location()); } - void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override { + void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override { write_point("ring_not_closed", nr.ref(), way ? way->id() : 0, nr.location()); } diff --git a/third_party/libosmium/include/osmium/area/problem_reporter_stream.hpp b/third_party/libosmium/include/osmium/area/problem_reporter_stream.hpp index 774e9c3b477..09c48d5dc3d 100644 --- a/third_party/libosmium/include/osmium/area/problem_reporter_stream.hpp +++ b/third_party/libosmium/include/osmium/area/problem_reporter_stream.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,8 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include - #include #include #include @@ -42,6 +40,8 @@ DEALINGS IN THE SOFTWARE. #include #include +#include + namespace osmium { namespace area { @@ -56,8 +56,6 @@ namespace osmium { m_out(&out) { } - ~ProblemReporterStream() override = default; - void header(const char* msg) { *m_out << "DATA PROBLEM: " << msg << " on " << item_type_to_char(m_object_type) << m_object_id << " (with " << m_nodes << " nodes): "; } @@ -91,7 +89,7 @@ namespace osmium { << " node_id2=" << nr2.ref() << " location2=" << nr2.location() << "\n"; } - void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override { + void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override { header("ring not closed"); *m_out << "node_id=" << nr.ref() << " location=" << nr.location(); if (way) { diff --git a/third_party/libosmium/include/osmium/area/stats.hpp b/third_party/libosmium/include/osmium/area/stats.hpp index 6133da8473b..7804111817a 100644 --- a/third_party/libosmium/include/osmium/area/stats.hpp +++ b/third_party/libosmium/include/osmium/area/stats.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 diff --git a/third_party/libosmium/include/osmium/builder/attr.hpp b/third_party/libosmium/include/osmium/builder/attr.hpp index bcd48613a62..2dd6239ea88 100644 --- a/third_party/libosmium/include/osmium/builder/attr.hpp +++ b/third_party/libosmium/include/osmium/builder/attr.hpp @@ -5,7 +5,7 @@ This file is part of Osmium (http://osmcode.org/libosmium). -Copyright 2013-2017 Jochen Topf and others (see README). +Copyright 2013-2018 Jochen Topf and others (see README). Boost Software License - Version 1.0 - August 17th, 2003 @@ -33,16 +33,6 @@ DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include @@ -56,6 +46,16 @@ DEALINGS IN THE SOFTWARE. #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + namespace osmium { namespace builder { @@ -94,13 +94,13 @@ namespace osmium { }; #else // True if Predicate matches for none of the types Ts - template class Predicate, typename... Ts> + template