Merge commit 'a3a7a822e136d2357660d85124d8e7bb26ea6f7c' into subtrees-protozero-vtzero

This commit is contained in:
Michael Krasnyk 2018-04-19 22:03:25 +03:00
commit 3a9acde2c3
No known key found for this signature in database
GPG Key ID: 49C12AD0F43D2108
353 changed files with 6183 additions and 7253 deletions

90
third_party/libosmium/.clang-tidy vendored Normal file
View File

@ -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\/.*'
...

3
third_party/libosmium/.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "test/data-tests/osm-testdata"]
path = test/data-tests/osm-testdata
url = https://github.com/osmcode/osm-testdata

View File

@ -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'
- 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'
- 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'
env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Dev'
addons: *clang35
- 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'
env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Release'
addons: *clang38
- 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'
env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Dev'
addons: *clang38
- os: linux
compiler: linux-clang39-release
env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Release'
addons: *clang39
- os: linux
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-clang40-dev
env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Dev'
addons: *clang40
- os: linux
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
#-----------------------------------------------------------------------------

View File

@ -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<Reader>`.
* 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

View File

@ -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()

View File

@ -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.

View File

@ -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

View File

@ -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
<http://code.google.com/p/include-what-you-use/>.
<https://include-what-you-use.org/>.
## Testing

View File

@ -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.

View File

@ -6,34 +6,54 @@
environment:
matrix:
- config: Dev
- config: MSYS2
autocrlf: true
- config: Dev
- config: Debug
autocrlf: true
- config: Release
autocrlf: true
- config: Debug
autocrlf: false
- config: RelWithDebInfo
autocrlf: true
- config: RelWithDebInfo
- 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"

View File

@ -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

View File

@ -4,36 +4,35 @@
*/
#include <osmium/handler.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
#include <osmium/visitor.hpp>
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';
}

View File

@ -4,15 +4,15 @@
*/
#include <osmium/handler.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
#include <osmium/visitor.hpp>
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';
}

View File

@ -4,17 +4,16 @@
*/
#include <osmium/handler.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/index/map/all.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
#include <cstdlib>
#include <iostream>
#include <string>
#include <osmium/index/map/all.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
using index_type = osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location>;
using location_handler_type = osmium::handler::NodeLocationsForWays<index_type>;

View File

@ -4,17 +4,17 @@
*/
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/wkb.hpp>
#include <osmium/handler.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
#include <osmium/visitor.hpp>
#include <osmium/geom/wkb.hpp>
#include <osmium/geom/mercator_projection.hpp>
struct GeomHandler : public osmium::handler::Handler {
osmium::geom::WKBFactory<osmium::geom::MercatorProjection> 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";

View File

@ -16,6 +16,12 @@
*/
#include <osmium/handler.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/index/map/all.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/visitor.hpp>
#include <algorithm>
#include <chrono>
#include <cmath>
@ -24,13 +30,6 @@
#include <limits>
#include <string>
#include <osmium/index/map/all.hpp>
#include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp>
#include <osmium/io/any_input.hpp>
#include <osmium/handler.hpp>
using static_index_type = osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location>;
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<osmium::unsigned_object_id_type, osmium::Location>::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<int>(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<double, std::milli>(end-start).count();
const double duration = std::chrono::duration<double, std::milli>(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<double, std::milli>(end-start).count();
const double duration = std::chrono::duration<double, std::milli>(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";

View File

@ -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:\=/%
CD ..
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
nuget install expat.v140 -Version 2.2.5
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
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
SET PATH=C:/projects/expat.v140.2.2.5/build/native/bin/x64/%config%;%PATH%
nuget install zlib-vc140-static-64 -Version 1.2.11
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
IF NOT EXIST %CUSTOM_CMAKE% ECHO extracting cmake... && 7z x cm.7z | %windir%\system32\find "ing archive"
nuget install bzip2.v140 -Version 1.0.6.9
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
IF NOT EXIST %LODEPSDIR% ECHO extracting binary dependencies... && 7z x lodeps.7z | %windir%\system32\find "ing archive"
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
SET PATH=C:/projects/bzip2.v140.1.0.6.9/build/native/bin/x64/%config%;%PATH%
ECHO %LODEPSDIR%
DIR %LODEPSDIR%
::TREE %LODEPSDIR%
CD libosmium
::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
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
ECHO config^: %config%
ECHO BOOST_VERSION^: %BOOST_VERSION%
SET libpostfix=""
IF "%config%"=="Debug" SET libpostfix="d"
ECHO our own cmake
cmake -version
CD %lodir%\..
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
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

View File

@ -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

41
third_party/libosmium/build-msys2.bat vendored Normal file
View File

@ -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%

View File

@ -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}"

View File

@ -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()

View File

@ -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)
#----------------------------------------------------------------------

View File

@ -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

View File

@ -26,7 +26,7 @@
*/
#include <cstdlib> // for std::exit
#include <getopt.h> // for getopt_long
#include <cstring> // for std::strcmp
#include <iostream> // 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<WKTDump>();
break;
case 'o':
handler.set<osmium::handler::Dump>(std::cout);
break;
default:
std::exit(1);
}
if (!std::strcmp(argv[1], "-w") || !std::strcmp(argv[1], "--dump-wkt")) {
handler.set<WKTDump>();
} else if (!std::strcmp(argv[1], "-o") || !std::strcmp(argv[1], "--dump-objects")) {
handler.set<osmium::handler::Dump>(std::cout);
} else {
print_usage(argv[0]);
}
const int remaining_args = argc - optind;
if (remaining_args != 1) {
std::cerr << "Usage: " << argv[0] << " [OPTIONS] OSMFILE\n";
std::exit(1);
}
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.

View File

@ -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);
}
}
}

View File

@ -18,8 +18,8 @@
*/
#include <cstdlib> // for std::exit
#include <cstring> // for std::strcmp
#include <exception> // for std::exception
#include <getopt.h> // for getopt_long
#include <iostream> // for std::cout, std::cerr
#include <string> // 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

View File

@ -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;
}

View File

@ -31,11 +31,8 @@
#include <osmium/io/any_output.hpp>
// We want to use the builder interface
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/builder/attr.hpp>
// Declare this to use the functions starting with the underscore (_) below.
using namespace osmium::builder::attr;
#include <osmium/builder/osm_object_builder.hpp>
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.

View File

@ -29,8 +29,8 @@
*/
#include <cerrno> // for errno
#include <cstring> // for std::strerror
#include <cstdlib> // for std::exit
#include <cstring> // for std::strerror
#include <iostream> // for std::cout, std::cerr
#include <string> // for std::string
#include <sys/stat.h> // 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 @@ public:
#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);

View File

@ -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:

View File

@ -24,8 +24,8 @@
#include <algorithm> // for std::all_of, std::equal_range
#include <cstdlib> // for std::exit
#include <cstring> // for std::strcmp
#include <fcntl.h> // for open
#include <getopt.h> // for getopt_long
#include <iostream> // for std::cout, std::cerr
#include <memory> // for std::unique_ptr
#include <string> // for std::string
@ -64,6 +64,12 @@ public:
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 @@ public:
template <typename TValue>
class IndexAccessDense : public IndexAccess<TValue> {
using index_type = typename osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, TValue>;
using index_type = typename osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, TValue>;
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}
};
if (argc > 1 && (!std::strcmp(argv[1], "-h") ||
!std::strcmp(argv[1], "--help"))) {
print_help();
std::exit(0);
}
while (true) {
const int c = getopt_long(argc, argv, "a:dhl:s:t:", long_options, nullptr);
if (c == -1) {
break;
}
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 @@ public:
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<TValue>& 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<osmium::Location>(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<osmium::unsigned_object_id_type>(options.dense_format(), fd);
return run(*index, options);
} else {
// index id -> offset
const auto index = create<std::size_t>(options.dense_format(), fd);
return run(*index, options);
}
} catch(const std::exception& e) {
// index id -> offset
const auto index = create<std::size_t>(options.dense_format(), fd);
return run(*index, options);
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << '\n';
std::exit(1);
}

View File

@ -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 <osmium/index/map/sparse_file_array.hpp>
#include <osmium/index/map/dense_file_array.hpp>
#include <osmium/index/map/sparse_file_array.hpp>
// For the NodeLocationForWays handler
#include <osmium/handler/node_locations_for_ways.hpp>
@ -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);

View File

@ -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()) {

View File

@ -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);

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cassert>
#include <iostream>
#include <vector>
#include <osmium/area/assembler_config.hpp>
#include <osmium/area/detail/basic_assembler_with_tags.hpp>
#include <osmium/area/detail/segment_list.hpp>
@ -50,6 +46,10 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/tag.hpp>
#include <osmium/osm/way.hpp>
#include <cassert>
#include <iostream>
#include <vector>
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.

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <set>
#include <string>
#include <map>
#include <utility>
#include <vector>
#include <osmium/area/assembler_config.hpp>
#include <osmium/area/detail/basic_assembler_with_tags.hpp>
#include <osmium/area/detail/proto_ring.hpp>
@ -62,6 +50,18 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/way.hpp>
#include <osmium/tags/filter.hpp>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
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());

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,6 +33,20 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/area/assembler_config.hpp>
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/area/detail/proto_ring.hpp>
#include <osmium/area/detail/segment_list.hpp>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/area/stats.hpp>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/util/iterator.hpp>
#include <osmium/util/timer.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
@ -45,21 +59,6 @@ DEALINGS IN THE SOFTWARE.
#include <utility>
#include <vector>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/util/iterator.hpp>
#include <osmium/util/timer.hpp>
#include <osmium/area/assembler_config.hpp>
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/area/detail/proto_ring.hpp>
#include <osmium/area/detail/segment_list.hpp>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/area/stats.hpp>
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<ProtoRing>::iterator r1 = *m1.ring_it;
std::list<ProtoRing>::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<std::pair<location_to_ring_map, bool>> rings;
std::vector<std::pair<location_to_ring_map, bool>> 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<const osmium::Way*> 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;
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstring>
#include <osmium/area/assembler_config.hpp>
#include <osmium/area/detail/basic_assembler.hpp>
#include <osmium/area/stats.hpp>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/osm/tag.hpp>
#include <cstring>
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());
}
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/area/detail/vector.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iosfwd>
#include <utility>
#include <osmium/area/detail/vector.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
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()};

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,6 +33,10 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
@ -40,10 +44,6 @@ DEALINGS IN THE SOFTWARE.
#include <set>
#include <vector>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/area/detail/node_ref_segment.hpp>
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<ProtoRing*> m_inner;
std::vector<ProtoRing*> 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

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
@ -43,15 +52,6 @@ DEALINGS IN THE SOFTWARE.
#include <unordered_set>
#include <vector>
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
namespace osmium {
namespace area {
@ -84,7 +84,7 @@ namespace osmium {
using slist_type = std::vector<NodeRefSegment>;
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) {
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstdint>
#include <iosfwd>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node_ref.hpp>
#include <cstdint>
#include <iosfwd>
namespace osmium {
namespace area {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <vector>
#include <osmium/area/stats.hpp>
#include <osmium/memory/buffer.hpp>
#include <osmium/osm/item_type.hpp>
@ -48,6 +43,11 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/way.hpp>
#include <osmium/relations/collector.hpp>
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <vector>
namespace osmium {
namespace relations {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
#include <osmium/area/stats.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/relation.hpp>
@ -53,6 +46,13 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/tags/taglist.hpp>
#include <osmium/tags/tags_filter.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
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)) {
}
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
#include <osmium/area/stats.hpp>
#include <osmium/handler.hpp>
#include <osmium/handler/check_order.hpp>
@ -55,6 +48,13 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/relations/relations_manager.hpp>
#include <osmium/storage/item_stash.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <vector>
namespace osmium {
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/types.hpp>
#include <cstddef>
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) {
}
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <stdexcept>
#include <osmium/area/problem_reporter_stream.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/types.hpp>
#include <sstream>
#include <stdexcept>
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()};

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> 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 <memory>
#include <gdalcpp.hpp>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/geom/factory.hpp>
#include <osmium/geom/ogr.hpp>
@ -56,6 +52,10 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <gdalcpp.hpp>
#include <memory>
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());
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,8 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <ostream>
#include <osmium/area/problem_reporter.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/location.hpp>
@ -42,6 +40,8 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <ostream>
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) {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,16 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <cstdint>
#include <ctime>
#include <initializer_list>
#include <iterator>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <osmium/builder/builder.hpp>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/memory/buffer.hpp>
@ -56,6 +46,16 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/timestamp.hpp>
#include <osmium/osm/types.hpp>
#include <cstddef>
#include <cstdint>
#include <ctime>
#include <initializer_list>
#include <iterator>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
namespace osmium {
namespace builder {
@ -94,13 +94,13 @@ namespace osmium {
};
#else
// True if Predicate matches for none of the types Ts
template <template<typename> class Predicate, typename... Ts>
template <template <typename> class Predicate, typename... Ts>
struct static_none_of : std::is_same<std::tuple<std::false_type, typename Predicate<Ts>::type...>,
std::tuple<typename Predicate<Ts>::type..., std::false_type>>
{};
// True if Predicate matches for all of the types Ts
template <template<typename> class Predicate, typename... Ts>
template <template <typename> class Predicate, typename... Ts>
struct static_all_of : std::is_same<std::tuple<std::true_type, typename Predicate<Ts>::type...>,
std::tuple<typename Predicate<Ts>::type..., std::true_type>>
{};
@ -364,17 +364,21 @@ namespace osmium {
template <typename TTagIterator>
inline constexpr detail::tags_from_iterator_pair<TTagIterator> _tags(TTagIterator first, TTagIterator last) {
return detail::tags_from_iterator_pair<TTagIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::tags_from_iterator_pair<typename TContainer::const_iterator> _tags(const TContainer& container) {
return detail::tags_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using tag_ilist = std::initializer_list<std::pair<const char*, const char*>>;
inline detail::tags_from_iterator_pair<tag_ilist::const_iterator> _tags(const tag_ilist& container) {
return detail::tags_from_iterator_pair<tag_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
@ -388,22 +392,28 @@ namespace osmium {
template <typename TIdIterator>
inline constexpr detail::nodes_from_iterator_pair<TIdIterator> _nodes(TIdIterator first, TIdIterator last) {
return detail::nodes_from_iterator_pair<TIdIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::nodes_from_iterator_pair<typename TContainer::const_iterator> _nodes(const TContainer& container) {
return detail::nodes_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
inline detail::nodes_from_iterator_pair<object_id_ilist::const_iterator> _nodes(const object_id_ilist& container) {
return detail::nodes_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
inline detail::nodes_from_iterator_pair<node_ref_ilist::const_iterator> _nodes(const node_ref_ilist& container) {
return detail::nodes_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
@ -422,17 +432,21 @@ namespace osmium {
template <typename TMemberIterator>
inline constexpr detail::members_from_iterator_pair<TMemberIterator> _members(TMemberIterator first, TMemberIterator last) {
return detail::members_from_iterator_pair<TMemberIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::members_from_iterator_pair<typename TContainer::const_iterator> _members(const TContainer& container) {
return detail::members_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using member_ilist = std::initializer_list<member_type>;
inline detail::members_from_iterator_pair<member_ilist::const_iterator> _members(const member_ilist& container) {
return detail::members_from_iterator_pair<member_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
@ -450,58 +464,74 @@ namespace osmium {
template <typename TCommentIterator>
inline constexpr detail::comments_from_iterator_pair<TCommentIterator> _comments(TCommentIterator first, TCommentIterator last) {
return detail::comments_from_iterator_pair<TCommentIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::comments_from_iterator_pair<typename TContainer::const_iterator> _comments(const TContainer& container) {
return detail::comments_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using comment_ilist = std::initializer_list<comment_type>;
inline detail::comments_from_iterator_pair<comment_ilist::const_iterator> _comments(const comment_ilist& container) {
return detail::comments_from_iterator_pair<comment_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
template <typename TIdIterator>
inline constexpr detail::outer_ring_from_iterator_pair<TIdIterator> _outer_ring(TIdIterator first, TIdIterator last) {
return detail::outer_ring_from_iterator_pair<TIdIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::outer_ring_from_iterator_pair<typename TContainer::const_iterator> _outer_ring(const TContainer& container) {
return detail::outer_ring_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
inline detail::outer_ring_from_iterator_pair<object_id_ilist::const_iterator> _outer_ring(const object_id_ilist& container) {
return detail::outer_ring_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
inline detail::outer_ring_from_iterator_pair<node_ref_ilist::const_iterator> _outer_ring(const node_ref_ilist& container) {
return detail::outer_ring_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
template <typename TIdIterator>
inline constexpr detail::inner_ring_from_iterator_pair<TIdIterator> _inner_ring(TIdIterator first, TIdIterator last) {
return detail::inner_ring_from_iterator_pair<TIdIterator>(first, last);
return {first, last};
}
template <typename TContainer>
inline detail::inner_ring_from_iterator_pair<typename TContainer::const_iterator> _inner_ring(const TContainer& container) {
return detail::inner_ring_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
inline detail::inner_ring_from_iterator_pair<object_id_ilist::const_iterator> _inner_ring(const object_id_ilist& container) {
return detail::inner_ring_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
inline detail::inner_ring_from_iterator_pair<node_ref_ilist::const_iterator> _inner_ring(const node_ref_ilist& container) {
return detail::inner_ring_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
using std::begin;
using std::end;
return {begin(container), end(container)};
}
@ -516,7 +546,7 @@ namespace osmium {
struct changeset_handler : public entity_handler {
template <typename TDummy>
static void set_value(osmium::Changeset&, const TDummy&) noexcept {
static void set_value(osmium::Changeset& /*changeset*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(osmium::Changeset& changeset, attr::_cid id) noexcept {
@ -548,7 +578,7 @@ namespace osmium {
struct object_handler : public entity_handler {
template <typename TDummy>
static void set_value(osmium::OSMObject&, const TDummy&) noexcept {
static void set_value(osmium::OSMObject& /*object*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(osmium::OSMObject& object, attr::_id id) noexcept {
@ -601,7 +631,7 @@ namespace osmium {
// ==============================================================
template <typename... TArgs>
inline constexpr const char* get_user(const attr::_user& user, const TArgs&...) noexcept {
inline constexpr const char* get_user(const attr::_user& user, const TArgs&... /*args*/) noexcept {
return user.value;
}
@ -611,7 +641,7 @@ namespace osmium {
template <typename TFirst, typename... TRest>
inline constexpr typename std::enable_if<!std::is_same<attr::_user, TFirst>::value, const char*>::type
get_user(const TFirst&, const TRest&... args) noexcept {
get_user(const TFirst& /*first*/, const TRest&... args) noexcept {
return get_user(args...);
}
@ -625,7 +655,7 @@ namespace osmium {
struct tags_handler {
template <typename TDummy>
static void set_value(TagListBuilder&, const TDummy&) noexcept {
static void set_value(TagListBuilder& /*tlb*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(TagListBuilder& builder, const attr::_tag& tag) {
@ -644,7 +674,7 @@ namespace osmium {
struct nodes_handler {
template <typename TDummy>
static void set_value(WayNodeListBuilder&, const TDummy&) noexcept {
static void set_value(WayNodeListBuilder& /*wnlb*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(WayNodeListBuilder& builder, const attr::_node& node_ref) {
@ -663,7 +693,7 @@ namespace osmium {
struct members_handler {
template <typename TDummy>
static void set_value(RelationMemberListBuilder&, const TDummy&) noexcept {
static void set_value(RelationMemberListBuilder& /*rmlb*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(RelationMemberListBuilder& builder, const attr::_member& member) {
@ -682,7 +712,7 @@ namespace osmium {
struct discussion_handler {
template <typename TDummy>
static void set_value(ChangesetDiscussionBuilder&, const TDummy&) noexcept {
static void set_value(ChangesetDiscussionBuilder& /*cdb*/, const TDummy& /*dummy*/) noexcept {
}
static void set_value(ChangesetDiscussionBuilder& builder, const attr::_comment& comment) {
@ -703,7 +733,7 @@ namespace osmium {
struct ring_handler {
template <typename TDummy>
static void set_value(AreaBuilder&, const TDummy&) noexcept {
static void set_value(AreaBuilder& /*ab*/, const TDummy& /*dummy*/) noexcept {
}
template <typename TIterator>
@ -728,7 +758,7 @@ namespace osmium {
template <typename TBuilder, typename THandler, typename... TArgs>
inline typename std::enable_if<!is_handled_by<THandler, TArgs...>::value>::type
add_list(osmium::builder::Builder&, const TArgs&...) noexcept {
add_list(osmium::builder::Builder& /*parent*/, const TArgs&... /*args*/) noexcept {
}
template <typename TBuilder, typename THandler, typename... TArgs>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/memory/buffer.hpp>
#include <osmium/memory/item.hpp>
#include <osmium/util/compatibility.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <osmium/memory/buffer.hpp>
#include <osmium/memory/item.hpp>
#include <osmium/util/compatibility.hpp>
namespace osmium {
/**
@ -60,12 +60,6 @@ namespace osmium {
Builder* m_parent;
std::size_t m_item_offset;
Builder(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(const Builder&) = delete;
Builder& operator=(Builder&&) = delete;
protected:
explicit Builder(osmium::memory::Buffer& buffer, Builder* parent, osmium::memory::item_size_type size) :
@ -203,6 +197,12 @@ namespace osmium {
public:
Builder(const Builder&) = delete;
Builder(Builder&&) = delete;
Builder& operator=(const Builder&) = delete;
Builder& operator=(Builder&&) = delete;
/// Return the buffer this builder is using.
osmium::memory::Buffer& buffer() noexcept {
return m_buffer;

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <initializer_list>
#include <functional>
#include <map>
#include <utility>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/memory/buffer.hpp>
#include <osmium/util/compatibility.hpp>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <map>
#include <utility>
namespace osmium {
class NodeRef;
@ -103,7 +103,7 @@ namespace osmium {
* @deprecated
* Use osmium::builder::add_tag_list() instead.
*/
OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, std::function<void(osmium::builder::TagListBuilder&)> func) {
OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, const std::function<void(osmium::builder::TagListBuilder&)>& func) {
const size_t pos = buffer.committed();
{
osmium::builder::TagListBuilder tl_builder(buffer);

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstddef>
#include <cstring>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <utility>
#include <osmium/builder/builder.hpp>
#include <osmium/memory/item.hpp>
#include <osmium/osm/area.hpp>
@ -60,9 +48,20 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/timestamp.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/util/cast.hpp>
#include <osmium/util/compatibility.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <utility>
namespace osmium {
namespace memory {
@ -85,6 +84,12 @@ namespace osmium {
new (&item()) TagList{};
}
TagListBuilder(const TagListBuilder&) = delete;
TagListBuilder& operator=(const TagListBuilder&) = delete;
TagListBuilder(TagListBuilder&&) = delete;
TagListBuilder& operator=(TagListBuilder&&) = delete;
~TagListBuilder() {
add_padding();
}
@ -196,6 +201,12 @@ namespace osmium {
new (&item()) T{};
}
NodeRefListBuilder(const NodeRefListBuilder&) = delete;
NodeRefListBuilder& operator=(const NodeRefListBuilder&) = delete;
NodeRefListBuilder(NodeRefListBuilder&&) = delete;
NodeRefListBuilder& operator=(NodeRefListBuilder&&) = delete;
~NodeRefListBuilder() {
add_padding();
}
@ -247,6 +258,12 @@ namespace osmium {
new (&item()) RelationMemberList{};
}
RelationMemberListBuilder(const RelationMemberListBuilder&) = delete;
RelationMemberListBuilder& operator=(const RelationMemberListBuilder&) = delete;
RelationMemberListBuilder(RelationMemberListBuilder&&) = delete;
RelationMemberListBuilder& operator=(RelationMemberListBuilder&&) = delete;
~RelationMemberListBuilder() {
add_padding();
}
@ -265,7 +282,7 @@ namespace osmium {
* osmium::max_osm_string_length
*/
void add_member(osmium::item_type type, object_id_type ref, const char* role, const std::size_t role_length, const osmium::OSMObject* full_member = nullptr) {
osmium::RelationMember* member = reserve_space_for<osmium::RelationMember>();
auto* member = reserve_space_for<osmium::RelationMember>();
new (member) osmium::RelationMember{ref, type, full_member != nullptr};
add_size(sizeof(RelationMember));
add_role(*member, role, role_length);
@ -339,6 +356,12 @@ namespace osmium {
new (&item()) ChangesetDiscussion{};
}
ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder&) = delete;
ChangesetDiscussionBuilder& operator=(const ChangesetDiscussionBuilder&) = delete;
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder&&) = delete;
ChangesetDiscussionBuilder& operator=(ChangesetDiscussionBuilder&&) = delete;
~ChangesetDiscussionBuilder() {
assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
add_padding();
@ -440,18 +463,25 @@ namespace osmium {
* Set user name.
*
* @param user Pointer to \0-terminated user name.
*
* @pre @code strlen(user) < 2^16 - 1 @endcode
*/
TDerived& set_user(const char* user) {
return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
const auto len = std::strlen(user);
assert(len < std::numeric_limits<string_size_type>::max());
return set_user(user, static_cast<string_size_type>(len));
}
/**
* Set user name.
*
* @param user User name.
*
* @pre @code user.size() < 2^16 - 1 @endcode
*/
TDerived& set_user(const std::string& user) {
return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
assert(user.size() < std::numeric_limits<string_size_type>::max());
return set_user(user.data(), static_cast<string_size_type>(user.size()));
}
/// @deprecated Use set_user(...) instead.
@ -649,18 +679,25 @@ namespace osmium {
* Set user name.
*
* @param user Pointer to \0-terminated user name.
*
* @pre @code strlen(user) < 2^16 - 1 @endcode
*/
ChangesetBuilder& set_user(const char* user) {
return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
const auto len = std::strlen(user);
assert(len <= std::numeric_limits<string_size_type>::max());
return set_user(user, static_cast<string_size_type>(len));
}
/**
* Set user name.
*
* @param user User name.
*
* @pre @code user.size() < 2^16 - 1 @endcode
*/
ChangesetBuilder& set_user(const std::string& user) {
return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
assert(user.size() < std::numeric_limits<string_size_type>::max());
return set_user(user.data(), static_cast<string_size_type>(user.size()));
}
/// @deprecated Use set_user(...) instead.

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/osm/diff_object.hpp>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <type_traits>
#include <utility>
#include <osmium/osm/diff_object.hpp>
namespace osmium {
class OSMObject;
@ -69,11 +69,11 @@ namespace osmium {
const bool use_curr_for_prev = m_prev->type() != m_curr->type() || m_prev->id() != m_curr->id();
const bool use_curr_for_next = m_next == m_end || m_next->type() != m_curr->type() || m_next->id() != m_curr->id();
m_diff = std::move(osmium::DiffObject{
m_diff = osmium::DiffObject{
*(use_curr_for_prev ? m_curr : m_prev),
*m_curr,
*(use_curr_for_next ? m_curr : m_next)
});
};
}
public:

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/handler.hpp>
#include <memory>
#include <utility>
#include <osmium/handler.hpp>
namespace osmium {
class Node;
@ -54,21 +54,29 @@ namespace osmium {
public:
HandlerWrapperBase() = default;
HandlerWrapperBase(const HandlerWrapperBase&) = default;
HandlerWrapperBase& operator=(const HandlerWrapperBase&) = default;
HandlerWrapperBase(HandlerWrapperBase&&) noexcept = default;
HandlerWrapperBase& operator=(HandlerWrapperBase&&) noexcept = default;
virtual ~HandlerWrapperBase() = default;
virtual void node(const osmium::Node&) {
virtual void node(const osmium::Node& /*node*/) {
}
virtual void way(const osmium::Way&) {
virtual void way(const osmium::Way& /*way*/) {
}
virtual void relation(const osmium::Relation&) {
virtual void relation(const osmium::Relation& /*relation*/) {
}
virtual void area(const osmium::Area&) {
virtual void area(const osmium::Area& /*area*/) {
}
virtual void changeset(const osmium::Changeset&) {
virtual void changeset(const osmium::Changeset& /*changeset*/) {
}
virtual void flush() {
@ -78,7 +86,7 @@ namespace osmium {
// The following uses trick from
// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
// to either call handler style functions or visitor style operator().
#define OSMIUM_DYNAMIC_HANDLER_DISPATCH(_name_, _type_) \
@ -98,12 +106,12 @@ auto _name_##_dispatch(THandler& handler, const osmium::_type_& object, long) ->
OSMIUM_DYNAMIC_HANDLER_DISPATCH(area, Area)
template <typename THandler>
auto flush_dispatch(THandler& handler, int) -> decltype(handler.flush(), void()) {
auto flush_dispatch(THandler& handler, int /*dispatch*/) -> decltype(handler.flush(), void()) {
handler.flush();
}
template <typename THandler>
void flush_dispatch(THandler&, long) {
void flush_dispatch(THandler& /*handler*/, long /*dispatch*/) { // NOLINT(google-runtime-int)
}
template <typename THandler>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <string>
#include <utility>
#include <vector>
#include <osmium/area/assembler.hpp>
#include <osmium/area/multipolygon_collector.hpp>
#include <osmium/handler/node_locations_for_ways.hpp> // IWYU pragma: keep
@ -47,6 +43,10 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/entity_bits.hpp>
#include <osmium/visitor.hpp>
#include <string>
#include <utility>
#include <vector>
namespace osmium {
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/osm/location.hpp>
#include <osmium/util/double.hpp>
#include <cmath>
#include <iosfwd>
#include <limits>
#include <string>
#include <osmium/osm/location.hpp>
#include <osmium/util/double.hpp>
namespace osmium {
namespace geom {
@ -70,8 +70,11 @@ namespace osmium {
/**
* Create Coordinates from a Location. Will throw
* osmium::invalid_location if the location is not valid.
*
* This constructor is not explicit on purpose allowing use of
* a Location everywhere a Coordinates object is needed.
*/
Coordinates(const osmium::Location& location) :
Coordinates(const osmium::Location& location) : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
x(location.lon()),
y(location.lat()) {
}
@ -95,9 +98,9 @@ namespace osmium {
*/
void append_to_string(std::string& s, const char infix, int precision) const {
if (valid()) {
osmium::util::double2string(s, x, precision);
osmium::double2string(s, x, precision);
s += infix;
osmium::util::double2string(s, y, precision);
osmium::double2string(s, y, precision);
} else {
s.append("invalid");
}
@ -143,7 +146,7 @@ namespace osmium {
}
inline bool operator!=(const Coordinates& lhs, const Coordinates& rhs) noexcept {
return ! operator==(lhs, rhs);
return !(lhs == rhs);
}
template <typename TChar, typename TTraits>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <stdexcept>
#include <string>
#include <utility>
#include <osmium/geom/coordinates.hpp>
#include <osmium/memory/collection.hpp>
#include <osmium/memory/item.hpp>
@ -50,6 +45,11 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <cstddef>
#include <stdexcept>
#include <string>
#include <utility>
namespace osmium {
/**
@ -267,7 +267,6 @@ namespace osmium {
size_t num_points = 0;
if (un == use_nodes::unique) {
osmium::Location last_location;
switch (dir) {
case direction::forward:
num_points = fill_linestring_unique(wnl.cbegin(), wnl.cend());
@ -294,7 +293,7 @@ namespace osmium {
return linestring_finish(num_points);
}
linestring_type create_linestring(const osmium::Way& way, use_nodes un=use_nodes::unique, direction dir = direction::forward) {
linestring_type create_linestring(const osmium::Way& way, use_nodes un = use_nodes::unique, direction dir = direction::forward) {
try {
return create_linestring(way.nodes(), un, dir);
} catch (osmium::geometry_error& e) {
@ -341,7 +340,6 @@ namespace osmium {
size_t num_points = 0;
if (un == use_nodes::unique) {
osmium::Location last_location;
switch (dir) {
case direction::forward:
num_points = fill_polygon_unique(wnl.cbegin(), wnl.cend());
@ -368,7 +366,7 @@ namespace osmium {
return polygon_finish(num_points);
}
polygon_type create_polygon(const osmium::Way& way, use_nodes un=use_nodes::unique, direction dir = direction::forward) {
polygon_type create_polygon(const osmium::Way& way, use_nodes un = use_nodes::unique, direction dir = direction::forward) {
try {
return create_polygon(way.nodes(), un, dir);
} catch (osmium::geometry_error& e) {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <cassert>
#include <cstddef>
#include <string>
#include <utility>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
namespace osmium {
namespace geom {
@ -60,7 +60,7 @@ namespace osmium {
using multipolygon_type = std::string;
using ring_type = std::string;
GeoJSONFactoryImpl(int /* srid */, int precision = 7) :
explicit GeoJSONFactoryImpl(int /*srid*/, int precision = 7) :
m_precision(precision) {
}
@ -68,7 +68,7 @@ namespace osmium {
// { "type": "Point", "coordinates": [100.0, 0.0] }
point_type make_point(const osmium::geom::Coordinates& xy) const {
std::string str {"{\"type\":\"Point\",\"coordinates\":"};
std::string str{"{\"type\":\"Point\",\"coordinates\":"};
xy.append_to_string(str, '[', ',', ']', m_precision);
str += "}";
return str;
@ -86,7 +86,7 @@ namespace osmium {
m_str += ',';
}
linestring_type linestring_finish(size_t /* num_points */) {
linestring_type linestring_finish(size_t /*num_points*/) {
assert(!m_str.empty());
std::string str;
@ -98,6 +98,28 @@ namespace osmium {
return str;
}
/* Polygon */
void polygon_start() {
m_str = "{\"type\":\"Polygon\",\"coordinates\":[[";
}
void polygon_add_location(const osmium::geom::Coordinates& xy) {
xy.append_to_string(m_str, '[', ',', ']', m_precision);
m_str += ',';
}
polygon_type polygon_finish(size_t /*num_points*/) {
assert(!m_str.empty());
std::string str;
using std::swap;
swap(str, m_str);
str.back() = ']';
str += "]}";
return str;
}
/* MultiPolygon */
void multipolygon_start() {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -52,14 +52,9 @@ DEALINGS IN THE SOFTWARE.
* @attention If you include this file, you'll need to link with `libgeos`.
*/
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <osmium/util/compatibility.hpp>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h>
@ -72,9 +67,14 @@ DEALINGS IN THE SOFTWARE.
#include <geos/geom/PrecisionModel.h>
#include <geos/util/GEOSException.h>
#include <osmium/geom/factory.hpp>
#include <osmium/geom/coordinates.hpp>
#include <osmium/util/compatibility.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <memory>
#include <string>
#include <utility>
#include <vector>
// MSVC doesn't support throw_with_nested yet
#ifdef _MSC_VER

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cmath>
#include <iterator>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/util.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/way.hpp>
#include <cmath>
#include <iterator>
namespace osmium {
namespace geom {
@ -48,7 +48,7 @@ namespace osmium {
/**
* @brief Functions to calculate arc distance on Earth using the haversine formula.
*
* See http://en.wikipedia.org/wiki/Haversine_formula
* See https://en.wikipedia.org/wiki/Haversine_formula
*
* Implementation derived from
* http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html
@ -69,7 +69,7 @@ namespace osmium {
double lath = sin(deg_to_rad(c1.y - c2.y) * 0.5);
lath *= lath;
const double tmp = cos(deg_to_rad(c1.y)) * cos(deg_to_rad(c2.y));
return 2.0 * EARTH_RADIUS_IN_METERS * asin(sqrt(lath + tmp*lonh));
return 2.0 * EARTH_RADIUS_IN_METERS * asin(sqrt(lath + tmp * lonh));
}
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cmath>
#include <string>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/util.hpp>
#include <osmium/osm/location.hpp>
#include <cmath>
#include <string>
namespace osmium {
namespace geom {
@ -54,7 +54,7 @@ namespace osmium {
}
inline double lat_to_y_with_tan(double lat) { // not constexpr because math functions aren't
return earth_radius_for_epsg3857 * std::log(std::tan(osmium::geom::PI/4 + deg_to_rad(lat)/2));
return earth_radius_for_epsg3857 * std::log(std::tan(osmium::geom::PI / 4 + deg_to_rad(lat) / 2));
}
#ifdef OSMIUM_USE_SLOW_MERCATOR_PROJECTION
@ -101,7 +101,7 @@ namespace osmium {
}
inline double y_to_lat(double y) { // not constexpr because math functions aren't
return rad_to_deg(2 * std::atan(std::exp(y / earth_radius_for_epsg3857)) - osmium::geom::PI/2);
return rad_to_deg(2 * std::atan(std::exp(y / earth_radius_for_epsg3857)) - osmium::geom::PI / 2);
}
} // namespace detail
@ -138,7 +138,11 @@ namespace osmium {
public:
MercatorProjection() {
// This is not "= default" on purpose because some compilers don't
// like it and complain that "default initialization of an object
// of const type 'const osmium::geom::MercatorProjection' requires
// a user-provided default constructor".
MercatorProjection() { // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
}
Coordinates operator()(osmium::Location location) const {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -42,16 +42,16 @@ DEALINGS IN THE SOFTWARE.
* @attention If you include this file, you'll need to link with `libgdal`.
*/
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <ogr_geometry.h>
#include <cassert>
#include <cstddef>
#include <memory>
#include <utility>
#include <ogr_geometry.h>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
namespace osmium {
namespace geom {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -42,16 +42,16 @@ DEALINGS IN THE SOFTWARE.
* @attention If you include this file, you'll need to link with `libproj`.
*/
#include <memory>
#include <string>
#include <proj_api.h>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/geom/util.hpp>
#include <osmium/osm/location.hpp>
#include <proj_api.h>
#include <memory>
#include <string>
namespace osmium {
namespace geom {
@ -161,7 +161,9 @@ namespace osmium {
Coordinates operator()(osmium::Location location) const {
if (m_epsg == 4326) {
return Coordinates{location.lon(), location.lat()};
} else if (m_epsg == 3857) {
}
if (m_epsg == 3857) {
return Coordinates{detail::lon_to_x(location.lon()),
detail::lat_to_y(location.lat())};
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <cstddef>
namespace osmium {
namespace geom {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cassert>
#include <cstdint>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/mercator_projection.hpp>
#include <osmium/osm/location.hpp>
#include <cassert>
#include <cstdint>
namespace osmium {
namespace geom {
@ -177,7 +177,7 @@ namespace osmium {
}
inline bool operator!=(const Tile& lhs, const Tile& rhs) noexcept {
return ! (lhs == rhs);
return !(lhs == rhs);
}
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <osmium/util/cast.hpp>
#include <osmium/util/endian.hpp>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
namespace osmium {
namespace geom {
@ -70,8 +70,8 @@ namespace osmium {
out.reserve(str.size() * 2);
for (char c : str) {
out += lookup_hex[(c >> 4) & 0xf];
out += lookup_hex[c & 0xf];
out += lookup_hex[(static_cast<unsigned int>(c) >> 4u) & 0xfu];
out += lookup_hex[ static_cast<unsigned int>(c) & 0xfu];
}
return out;
@ -83,7 +83,7 @@ namespace osmium {
* Type of WKB geometry.
* These definitions are from
* 99-049_OpenGIS_Simple_Features_Specification_For_SQL_Rev_1.1.pdf (for WKB)
* and http://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt (for EWKB).
* and https://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt (for EWKB).
* They are used to encode geometries into the WKB format.
*/
enum wkbGeometryType : uint32_t {
@ -140,8 +140,11 @@ namespace osmium {
}
void set_size(const std::size_t offset, const std::size_t size) {
uint32_t s = static_cast_with_assert<uint32_t>(size);
std::copy_n(reinterpret_cast<char*>(&s), sizeof(uint32_t), &m_data[offset]);
if (size > std::numeric_limits<uint32_t>::max()) {
throw geometry_error{"Too many points in geometry"};
}
const auto s = static_cast<uint32_t>(size);
std::copy_n(reinterpret_cast<const char*>(&s), sizeof(uint32_t), &m_data[offset]);
}
public:
@ -168,9 +171,9 @@ namespace osmium {
if (m_out_type == out_type::hex) {
return convert_to_hex(data);
} else {
return data;
}
return data;
}
/* LineString */
@ -194,9 +197,9 @@ namespace osmium {
if (m_out_type == out_type::hex) {
return convert_to_hex(data);
} else {
return data;
}
return data;
}
/* MultiPolygon */
@ -254,9 +257,9 @@ namespace osmium {
if (m_out_type == out_type::hex) {
return convert_to_hex(data);
} else {
return data;
}
return data;
}
}; // class WKBFactoryImpl

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
#include <cassert>
#include <cstddef>
#include <string>
#include <utility>
#include <osmium/geom/coordinates.hpp>
#include <osmium/geom/factory.hpp>
namespace osmium {
namespace geom {
@ -67,8 +67,7 @@ namespace osmium {
using multipolygon_type = std::string;
using ring_type = std::string;
WKTFactoryImpl(int srid, int precision = 7, wkt_type wtype = wkt_type::wkt) :
m_srid_prefix(),
explicit WKTFactoryImpl(int srid, int precision = 7, wkt_type wtype = wkt_type::wkt) :
m_precision(precision),
m_wkt_type(wtype) {
if (m_wkt_type == wkt_type::ewkt) {
@ -81,7 +80,7 @@ namespace osmium {
/* Point */
point_type make_point(const osmium::geom::Coordinates& xy) const {
std::string str {m_srid_prefix};
std::string str{m_srid_prefix};
str += "POINT";
xy.append_to_string(str, '(', ' ', ')', m_precision);
return str;
@ -110,6 +109,29 @@ namespace osmium {
return str;
}
/* Polygon */
void polygon_start() {
m_str = m_srid_prefix;
m_str += "POLYGON((";
}
void polygon_add_location(const osmium::geom::Coordinates& xy) {
xy.append_to_string(m_str, ' ', m_precision);
m_str += ',';
}
polygon_type polygon_finish(size_t /* num_points */) {
assert(!m_str.empty());
std::string str;
using std::swap;
swap(str, m_str);
str.back() = ')';
str += ")";
return str;
}
/* MultiPolygon */
void multipolygon_start() {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -72,40 +72,40 @@ namespace osmium {
public:
void osm_object(const osmium::OSMObject&) const noexcept {
void osm_object(const osmium::OSMObject& /*osm_object*/) const noexcept {
}
void node(const osmium::Node&) const noexcept {
void node(const osmium::Node& /*node*/) const noexcept {
}
void way(const osmium::Way&) const noexcept {
void way(const osmium::Way& /*way*/) const noexcept {
}
void relation(const osmium::Relation&) const noexcept {
void relation(const osmium::Relation& /*relation*/) const noexcept {
}
void area(const osmium::Area&) const noexcept {
void area(const osmium::Area& /*area*/) const noexcept {
}
void changeset(const osmium::Changeset&) const noexcept {
void changeset(const osmium::Changeset& /*changeset*/) const noexcept {
}
void tag_list(const osmium::TagList&) const noexcept {
void tag_list(const osmium::TagList& /*tag_list*/) const noexcept {
}
void way_node_list(const osmium::WayNodeList&) const noexcept {
void way_node_list(const osmium::WayNodeList& /*way_node_list*/) const noexcept {
}
void relation_member_list(const osmium::RelationMemberList&) const noexcept {
void relation_member_list(const osmium::RelationMemberList& /*relation_member_list*/) const noexcept {
}
void outer_ring(const osmium::OuterRing&) const noexcept {
void outer_ring(const osmium::OuterRing& /*outer_ring*/) const noexcept {
}
void inner_ring(const osmium::InnerRing&) const noexcept {
void inner_ring(const osmium::InnerRing& /*inner_ring*/) const noexcept {
}
void changeset_discussion(const osmium::ChangesetDiscussion&) const noexcept {
void changeset_discussion(const osmium::ChangesetDiscussion& /*changeset_discussion*/) const noexcept {
}
void flush() const noexcept {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
*/
#include <tuple>
#include <osmium/handler.hpp>
#include <tuple>
#define OSMIUM_CHAIN_HANDLER_CALL(_func_, _type_) \
template <int N, int SIZE, typename THandlers> \
struct call_ ## _func_ { \

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <limits>
#include <stdexcept>
#include <string>
#include <osmium/handler.hpp>
#include <osmium/osm/node.hpp>
#include <osmium/osm/object_comparisons.hpp>
@ -44,6 +40,10 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <limits>
#include <stdexcept>
#include <string>
namespace osmium {
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,8 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/handler.hpp>
#include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp>
@ -46,6 +44,8 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/way.hpp>
#include <osmium/visitor.hpp>
#include <cstddef>
namespace osmium {
namespace handler {
@ -78,11 +78,6 @@ namespace osmium {
m_relation_index(relation_index) {
}
DiskStore(const DiskStore&) = delete;
DiskStore& operator=(const DiskStore&) = delete;
~DiskStore() noexcept = default;
void node(const osmium::Node& node) {
m_node_index.set(node.positive_id(), m_offset);
m_offset += node.byte_size();

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
*/
#include <iomanip>
#include <iostream>
#include <string>
#include <osmium/handler.hpp>
#include <osmium/memory/collection.hpp>
#include <osmium/memory/item.hpp>
@ -54,6 +50,10 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/osm/way.hpp>
#include <osmium/visitor.hpp>
#include <iomanip>
#include <iostream>
#include <string>
namespace osmium {
namespace handler {
@ -136,10 +136,10 @@ namespace osmium {
public:
explicit Dump(std::ostream& out, bool with_size = true, const std::string& prefix = "") :
explicit Dump(std::ostream& out, bool with_size = true, std::string prefix = "") :
m_out(&out),
m_with_size(with_size),
m_prefix(prefix) {
m_prefix(std::move(prefix)) {
}
void tag_list(const osmium::TagList& tags) {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,19 +33,18 @@ DEALINGS IN THE SOFTWARE.
*/
#include <limits>
#include <type_traits>
#include <osmium/handler.hpp>
#include <osmium/index/index.hpp>
#include <osmium/index/map/dummy.hpp>
#include <osmium/index/node_locations_map.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/node.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/index/node_locations_map.hpp>
#include <limits>
#include <type_traits>
namespace osmium {
@ -99,7 +98,7 @@ namespace osmium {
public:
explicit NodeLocationsForWays(TStoragePosIDs& storage_pos,
TStorageNegIDs& storage_neg = get_dummy()) :
TStorageNegIDs& storage_neg = get_dummy()) noexcept :
m_storage_pos(storage_pos),
m_storage_neg(storage_neg) {
}
@ -107,8 +106,8 @@ namespace osmium {
NodeLocationsForWays(const NodeLocationsForWays&) = delete;
NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete;
NodeLocationsForWays(NodeLocationsForWays&&) = default;
NodeLocationsForWays& operator=(NodeLocationsForWays&&) = default;
NodeLocationsForWays(NodeLocationsForWays&&) noexcept = default;
NodeLocationsForWays& operator=(NodeLocationsForWays&&) noexcept = default;
~NodeLocationsForWays() noexcept = default;
@ -138,10 +137,9 @@ namespace osmium {
*/
osmium::Location get_node_location(const osmium::object_id_type id) const {
if (id >= 0) {
return m_storage_pos.get_noexcept(static_cast<osmium::unsigned_object_id_type>( id));
} else {
return m_storage_neg.get_noexcept(static_cast<osmium::unsigned_object_id_type>(-id));
return m_storage_pos.get_noexcept(static_cast<osmium::unsigned_object_id_type>(id));
}
return m_storage_neg.get_noexcept(static_cast<osmium::unsigned_object_id_type>(-id));
}
/**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
#include <osmium/handler.hpp>
#include <osmium/index/multimap.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/node_ref.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/osm/types.hpp>
#include <osmium/osm/way.hpp>
@ -70,11 +70,6 @@ namespace osmium {
m_index_r2r(r2r) {
}
ObjectRelations(const ObjectRelations&) = delete;
ObjectRelations& operator=(const ObjectRelations&) = delete;
~ObjectRelations() noexcept = default;
void way(const osmium::Way& way) {
for (const auto& node_ref : way.nodes()) {
m_index_n2w.set(node_ref.positive_ref(), way.positive_id());

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -54,7 +54,7 @@ namespace osmium {
}
assert(config.size() > 1);
const std::string& filename = config[1];
const int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644);
const int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644); // NOLINT(hicpp-signed-bitwise)
if (fd == -1) {
throw std::runtime_error{std::string{"can't open file '"} + filename + "': " + std::strerror(errno)};
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -54,8 +54,6 @@ namespace osmium {
mmap_vector_base<T>() {
}
~mmap_vector_anon() noexcept = default;
}; // class mmap_vector_anon
} // namespace detail

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/index/index.hpp>
#include <osmium/util/memory_mapping.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <new> // IWYU pragma: keep
#include <stdexcept>
#include <osmium/index/index.hpp>
#include <osmium/util/memory_mapping.hpp>
namespace osmium {
namespace detail {
@ -58,27 +58,24 @@ namespace osmium {
protected:
size_t m_size;
osmium::util::TypedMemoryMapping<T> m_mapping;
size_t m_size = 0;
osmium::TypedMemoryMapping<T> m_mapping;
public:
mmap_vector_base(int fd, size_t capacity, size_t size = 0) :
m_size(size),
m_mapping(capacity, osmium::util::MemoryMapping::mapping_mode::write_shared, fd) {
m_mapping(capacity, osmium::MemoryMapping::mapping_mode::write_shared, fd) {
assert(size <= capacity);
std::fill(data() + size, data() + capacity, osmium::index::empty_value<T>());
shrink_to_fit();
}
explicit mmap_vector_base(size_t capacity = mmap_vector_size_increment) :
m_size(0),
m_mapping(capacity) {
std::fill_n(data(), capacity, osmium::index::empty_value<T>());
}
~mmap_vector_base() noexcept = default;
using value_type = T;
using pointer = value_type*;
using const_pointer = const value_type*;

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/index/detail/mmap_vector_base.hpp>
#include <osmium/index/detail/tmpfile.hpp>
#include <osmium/util/file.hpp>
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <string>
#include <osmium/index/detail/mmap_vector_base.hpp>
#include <osmium/index/detail/tmpfile.hpp>
#include <osmium/util/file.hpp>
namespace osmium {
namespace detail {
@ -54,7 +54,7 @@ namespace osmium {
class mmap_vector_file : public mmap_vector_base<T> {
static std::size_t filesize(int fd) {
const auto size = osmium::util::file_size(fd);
const auto size = osmium::file_size(fd);
if (size % sizeof(T) != 0) {
throw std::runtime_error{"Index file has wrong size (must be multiple of " + std::to_string(sizeof(T)) + ")."};
@ -78,8 +78,6 @@ namespace osmium {
filesize(fd)) {
}
~mmap_vector_file() noexcept = default;
}; // class mmap_vector_file
} // namespace detail

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <utility>
#include <osmium/index/index.hpp>
#include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp>
#include <algorithm>
#include <cstddef>
#include <utility>
namespace osmium {
namespace index {
@ -67,8 +67,6 @@ namespace osmium {
m_vector(fd) {
}
~VectorBasedDenseMap() noexcept final = default;
void reserve(const std::size_t size) final {
m_vector.reserve(size);
}
@ -146,7 +144,7 @@ namespace osmium {
}; // class VectorBasedDenseMap
template <typename TId, typename TValue, template<typename...> class TVector>
template <typename TId, typename TValue, template <typename...> class TVector>
class VectorBasedSparseMap : public Map<TId, TValue> {
public:
@ -180,8 +178,6 @@ namespace osmium {
m_vector(fd) {
}
~VectorBasedSparseMap() final = default;
void set(const TId id, const TValue value) final {
m_vector.push_back(element_type(id, value));
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,21 +33,21 @@ DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cstddef>
#include <utility>
#include <osmium/index/index.hpp>
#include <osmium/index/multimap.hpp>
#include <osmium/io/detail/read_write.hpp>
#include <algorithm>
#include <cstddef>
#include <utility>
namespace osmium {
namespace index {
namespace multimap {
template <typename TId, typename TValue, template<typename...> class TVector>
template <typename TId, typename TValue, template <typename...> class TVector>
class VectorBasedSparseMultimap : public Multimap<TId, TValue> {
public:
@ -75,8 +75,6 @@ namespace osmium {
m_vector(fd) {
}
~VectorBasedSparseMultimap() noexcept final = default;
void set(const TId id, const TValue value) final {
m_vector.push_back(element_type(id, value));
}

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,6 +33,9 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/types.hpp>
#include <algorithm>
#include <cassert>
#include <cstddef>
@ -42,9 +45,6 @@ DEALINGS IN THE SOFTWARE.
#include <type_traits>
#include <vector>
#include <osmium/osm/item_type.hpp>
#include <osmium/osm/types.hpp>
namespace osmium {
namespace index {
@ -58,6 +58,14 @@ namespace osmium {
public:
IdSet() = default;
IdSet(const IdSet&) = default;
IdSet& operator=(const IdSet&) = default;
IdSet(IdSet&&) noexcept = default;
IdSet& operator=(IdSet&&) noexcept = default;
virtual ~IdSet() = default;
/**
@ -113,7 +121,7 @@ namespace osmium {
const auto slot = m_set->m_data[cid][IdSetDense<T>::offset(m_value)];
if (slot == 0) {
m_value += 8;
m_value &= ~0x7;
m_value &= ~0x7ull;
} else {
++m_value;
}
@ -154,7 +162,7 @@ namespace osmium {
}
bool operator!=(const IdSetDenseIterator<T>& rhs) const noexcept {
return ! (*this == rhs);
return !(*this == rhs);
}
T operator*() const noexcept {
@ -183,22 +191,22 @@ namespace osmium {
// which would mean less (but larger) memory allocations. For
// relations Ids it could be smaller, because they would all fit
// into a smaller allocation.
constexpr static const std::size_t chunk_bits = 22;
constexpr static const std::size_t chunk_size = 1 << chunk_bits;
constexpr static const std::size_t chunk_bits = 22u;
constexpr static const std::size_t chunk_size = 1u << chunk_bits;
std::vector<std::unique_ptr<unsigned char[]>> m_data;
T m_size = 0;
static std::size_t chunk_id(T id) noexcept {
return id >> (chunk_bits + 3);
return id >> (chunk_bits + 3u);
}
static std::size_t offset(T id) noexcept {
return (id >> 3) & ((1 << chunk_bits) - 1);
return (id >> 3u) & ((1u << chunk_bits) - 1u);
}
static unsigned char bitmask(T id) noexcept {
return 1 << (id & 0x7);
return 1u << (id & 0x7u);
}
T last() const noexcept {
@ -422,7 +430,7 @@ namespace osmium {
}; // class IdSetSmall
/// @deprecated Use nwr_array helper class instead.
template <template<typename> class IdSetType>
template <template <typename> class IdSetType>
class NWRIdSet {
using id_set_type = IdSetType<osmium::unsigned_object_id_type>;

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE.
*/
#include <osmium/util/string.hpp>
#include <algorithm>
#include <cstddef>
#include <functional>
@ -43,8 +45,6 @@ DEALINGS IN THE SOFTWARE.
#include <type_traits>
#include <vector>
#include <osmium/util/string.hpp>
namespace osmium {
struct map_factory_error : public std::runtime_error {
@ -98,13 +98,10 @@ namespace osmium {
static_assert(std::is_integral<TId>::value && std::is_unsigned<TId>::value,
"TId template parameter for class Map must be unsigned integral type");
Map(const Map&) = delete;
Map& operator=(const Map&) = delete;
protected:
Map(Map&&) = default;
Map& operator=(Map&&) = default;
Map(Map&&) noexcept = default;
Map& operator=(Map&&) noexcept = default;
public:
@ -114,11 +111,14 @@ namespace osmium {
/// The "value" type, usually a Location or size_t.
using value_type = TValue;
Map() = default;
Map() noexcept = default;
Map(const Map&) = delete;
Map& operator=(const Map&) = delete;
virtual ~Map() noexcept = default;
virtual void reserve(const size_t) {
virtual void reserve(const size_t /*size*/) {
// default implementation is empty
}
@ -210,14 +210,16 @@ namespace osmium {
MapFactory() = default;
~MapFactory() = default;
public:
MapFactory(const MapFactory&) = delete;
MapFactory& operator=(const MapFactory&) = delete;
MapFactory(MapFactory&&) = delete;
MapFactory& operator=(MapFactory&&) = delete;
public:
static MapFactory<id_type, value_type>& instance() {
static MapFactory<id_type, value_type> factory;
return factory;
@ -262,16 +264,16 @@ namespace osmium {
namespace map {
template <typename TId, typename TValue, template<typename, typename> class TMap>
template <typename TId, typename TValue, template <typename, typename> class TMap>
struct create_map {
TMap<TId, TValue>* operator()(const std::vector<std::string>&) {
TMap<TId, TValue>* operator()(const std::vector<std::string>& /*config_string*/) {
return new TMap<TId, TValue>();
}
};
} // namespace map
template <typename TId, typename TValue, template<typename, typename> class TMap>
template <typename TId, typename TValue, template <typename, typename> class TMap>
inline bool register_map(const std::string& name) {
return osmium::index::MapFactory<TId, TValue>::instance().register_map(name, [](const std::vector<std::string>& config) {
return map::create_map<TId, TValue, TMap>()(config);
@ -283,10 +285,11 @@ namespace osmium {
#define REGISTER_MAP(id, value, klass, name) \
namespace osmium { namespace index { namespace detail { \
const bool OSMIUM_CONCATENATE_(registered_, name) = osmium::index::register_map<id, value, klass>(#name); \
inline bool OSMIUM_CONCATENATE_(get_registered_, name)() noexcept { \
return OSMIUM_CONCATENATE_(registered_, name); \
} \
namespace OSMIUM_CONCATENATE_(register_map_, __COUNTER__) { \
const bool registered = osmium::index::register_map<id, value, klass>(#name); \
inline bool get_registered() noexcept { \
return registered; \
} } \
} } }
} // namespace index

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
*/
#include <string>
#include <vector>
#include <osmium/index/detail/create_map_with_fd.hpp>
#include <osmium/index/detail/mmap_vector_file.hpp>
#include <osmium/index/detail/vector_map.hpp>
#include <osmium/index/detail/create_map_with_fd.hpp>
#include <string>
#include <vector>
#define OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
*/
#include <vector>
#include <osmium/index/detail/vector_map.hpp>
#include <vector>
#define OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY
namespace osmium {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
*/
#include <cstddef>
#include <osmium/index/index.hpp>
#include <osmium/index/map.hpp>
#include <cstddef>
namespace osmium {
namespace index {
@ -56,9 +56,7 @@ namespace osmium {
Dummy() = default;
~Dummy() noexcept final = default;
void set(const TId, const TValue) final {
void set(const TId /*id*/, const TValue /*value*/) final {
// intentionally left blank
}

Some files were not shown because too many files have changed in this diff Show More