Squashed 'third_party/libosmium/' changes from 910f8f1..6522da5
6522da5 Merge pull request #79 from DennisOSRM/master 7c8d8dc add override keyword to close(), overridden function in include/osmium/io/detail/input_format.hpp d24841e Changes copyright dates in all files to a consistent "2013-2015". 3adc7d7 Another try to make it compile on Windows. 20dad8e Use auto instead of hard-coded types, hopefully fixes Windows build. b73ab3f Set build config in appveyor ctest call. 3e33857 Merge pull request #76 from BergWerkGIS/master c78ca6e Merge remote-tracking branch 'upstream/master' cf42013 enable test again 69e4a91 include compatibility.h 6f79b5c CMake: Remove Dart include, it seems to be superfluous. 4d40a18 Explicitly set copy constructors etc. for OutputIterator and test it. 69ee34c Run tests in build directory instead of source directory. 11c44c8 Fix typo. 675cc11 Fix formatting CMake config. 7aa3cb0 Add a benchmark counting amenity=post_box tags. 89fd942 Make it more evident that we handling constant tag lists. c72bbdf Add count() and empty() functions to Filter class. 88b9543 Disable annoying warnings from YouCompleteMe. 6cec403 Benchmarks: Only find files, not directories etc. in data dir. 09c4630 Follow redirects in benchmark download script. a8a552e Use Approx() function from Catch framework for floating point comparisons. 7db5086 Reorder data tests so fast tests run first. 24ce403 Fix #includes. ad9515c Add some comments in different config files to explain what they are. 987aa9c Some README updates. 3c18de7 Add configuration for YouCompleteMe Vim plugin. 433148e Explicit comparison against 0 to avoid warning with MSVC. e64a459 Small updates in benchmarks README. e4aff7f Add benchmark to compare static vs. dynamic index maps. f702634 Add missing include. 95a8c3b Merge branch 'master' of github.com:osmcode/libosmium 560a2ae Merge pull request #73 from osmcode/travis-fix f41e4ca remove incorrect cd f826107 Add some helper functions for working with entity_bits. 8fec1c1 Updated README: Lots of documentation is now on wiki. 6110cc8 Make cmake config work if no components are given. 8136557 Use 'Libosmium' instead of 'Osmium' as project name in doc. 10e631a Improved documenation: Dependencies to link with. 41d0ca4 Merge remote-tracking branch 'upstream/master' 6768026 SLN configuration is always 'Release' 5d985cf av: show env vars. 272ac88 don't use '%CONFIGURATION%' expands to e.g. 'Dev|x86' 59b15eb use cmake 3.1.0 again. old cmake on AppVeyor doesn't know yet about VS2014 SLN 0d0d71a try building with VS, Dev works only with VS at least locally 2fe6d02 name of geos.lib changed fc4662e test latest binary package d4a265f Add more labels to tests. 8722a3d Only check for valgrind if testing is enabled. cf7dc56 README improvements. 13a426e Fix cpack configuration. ae649c8 travis build: fix double install of make package c102040 Move cmake config for documentation into doc directory. 6064d55 Also list advanced cmake variables in travis build. c299bfa constexprt workaround for MSVC. afcf7a1 Cleanup/formatting of cmake config. a536720 Fix travis build by cloning osm-testdata in the right place. 2bdbf7f cmake: Don't clone osm-testdata repository any more. 5bdbb28 Rename test/osm-testdata to test/data-tests. 0ad0020 cmake: build data tests only by default on Dev builds 2cefa50 Add some benchmarks. 3fdb6e1 Remove outdated make_osmium_project.sh script. aca58ac Fix cmake config: overwriting of variables. 152e318 Fix compilation of examples that need wingetopt on Windows. ae17cd0 Remove superfluous warning on Windows for header test builds. f88d4c2 Switch to /W3 on Windows. 8edeba5 Remove duplicate copy constructor. cdb474e Cleanup examples cmake config ca9045a Cmake cleanup. 501eb61 Update to new version of catch unit test framework. 0646d6c Parenthesize expression to make test clearer and avoid warnings. dfdaeae Disable a warning that gdal throws on Windows. eacfe4f Explicitly test int !=0 to convert to bool. b3ba693 Cleanup of cmake config (mostly warning options Linux vs. Win) 3f5cb81 Appveyor: Also show advanced cmake variables. b544bd9 Never return valid but empty buffer from Reader.read() call. a34bb5d Declare var in a more local scope. b83e5f1 Merge pull request #66 from BergWerkGIS/master 04ef1b2 Last try for today, should solve geos test failures a749d6c hey AppVeyor: what's going on? 73131fb av: boost not found?? show directory tree 5e02886 av: should solve most "***Exception: Other" except for geos.dll related problem. should solve projection test fails. a7ae560 FlexReader now takes location handler as parameter. 6f1bd8d Disable non-existing Debian build in Makefile. 3d75178 Change warning level on MSVC. 3f0abc0 Appveyor: List cached variables from cmake. d1e1e9f Travis/Appveyor build in Dev and Release mode. Call ctest on Appveyor. 116bcc9 Fix default node location store. dedfe0e Make classes we submit to queue properly copyable. 8a432c9 Try the same ugly hack on OPLOutputBlock. 9c5b314 Try a hack to see whether it works on MSVC. 9592132 Give XMLOutputBlock a copy constructor. 991f91a Disable warning C4715: "not all control paths return a value" 340a4d7 Fix copy constructor. 7ceae00 Give OPLOutputBlock a copy constructor which basically does a move. e82951a Use rvalue as paremeter for queue submit function. 54a9cec Use explicit cast to double to silence warning. 7c5d04c Simplified use of ogr includes. 43fd388 Use appveyor supplied cmake. ce4311e cmake cleanup. 1108517 Disable warnings from MSVC in OGR headers. 2fe820c Harmonize signature of virtual member function dump_as_list(). 93c31b4 Parenthesize string in pragma message. 54ae1a0 Explicitly int to bool conversion to silence warning on MSVC. 4bde9b7 Formatting: Use spaces instead of tabs. 7224d84 cmake: Don't try to set C++ version with -std= with MSVC. 53fbcfd Remove trailing semikolon (which gcc doesn't like). 3b0c9ed Removed command that doesn't work on older cmakes. de6cc78 Merge pull request #62 from BergWerkGIS/master 9126530 Use less warning options on Windows. 6ec79fb Silence unknown pragma warning on Windows. b611589 Add static_cast to silence warning on windows. 18e54e9 remove call to build2.bat b0d9d28 try again with -DCMAKE_BUILD_TYPE=Release b495018 usage installed cmake, -DCMAKE_BUILD_TYPE=Dev 5bac95d Merge remote-tracking branch 'upstream/master' d41ea31 cmake: Do not use -Werror when using MSVC compiler 04cfe00 Provide convenience include file to include all index maps. 72fbaa7 Rename multimap indexes according to new schema. af49a27 Make registering index map types easier. 0a35701 av: remove debug echo calls 886c15f av: ditch -DCMAKE_BUILD_TYPE=Dev ad0a629 The great renaming of map index classes. 97b4d34 av: try again bf243b2 Move some hpp files into detail directory and fix include guards. 64e4841 av: try again calling cmake directly 1700789 Add way to dynamically choose node location index. da49b7f av: try again with build2.bat 4bf55f5 is appveyor working again? 5e63433 delete ws_32.lib patch. generate makefile instead of VS 1054016 Merge remote-tracking branch 'upstream/master' 8c198fc av: try even newer cmake 7cccb06 av: maybe newer cmake helps d04967a av: no existing env var was still there 80763c6 av: no build.bat, call cmake directly 3b58fc6 av: no cmds over spanning serveral lines? 33c09a0 CALL bat 34639c6 maybe double quotes? 72572de explicitly call VS2014 cmd prompt 6955e87 1st try on AppVeyor git-subtree-dir: third_party/libosmium git-subtree-split: 6522da53748e12379bbfaf70ad29ee7bd98ef02d
This commit is contained in:
parent
73efcc6b0c
commit
bb78bc8fe3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
core
|
||||
*.swp
|
||||
build*
|
||||
.ycm_extra_conf.pyc
|
||||
|
18
.travis.yml
18
.travis.yml
@ -1,9 +1,19 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Configuration for continuous integration service at travis-ci.org
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
language: cpp
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
env:
|
||||
- CONFIGURATION=Dev
|
||||
- CONFIGURATION=Release
|
||||
|
||||
before_install:
|
||||
# we need at least g++-4.8 for c++11 features
|
||||
- sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
|
||||
@ -16,8 +26,8 @@ install:
|
||||
- sudo rm /usr/bin/cpp
|
||||
- sudo ln -s /usr/bin/cpp-4.8 /usr/bin/cpp
|
||||
# upgrade libosmium dependencies
|
||||
- sudo apt-get install --yes make libboost-dev libboost-program-options-dev libsparsehash-dev libprotobuf-dev protobuf-compiler libgeos++-dev libproj-dev
|
||||
- sudo apt-get install --yes make libgdal1h libgdal-dev
|
||||
- sudo apt-get install --yes make libboost-dev libboost-program-options-dev libsparsehash-dev libprotobuf-dev protobuf-compiler libgeos++-dev libproj-dev libgdal1h libgdal-dev
|
||||
- git clone https://github.com/osmcode/osm-testdata.git
|
||||
# OSMPBF is too old, install from git
|
||||
#- sudo apt-get install --yes libosmpbf-dev
|
||||
- git clone https://github.com/scrosby/OSM-binary.git
|
||||
@ -26,8 +36,6 @@ install:
|
||||
- sudo make install
|
||||
- cd ../..
|
||||
|
||||
#env:
|
||||
|
||||
before_script:
|
||||
- true
|
||||
|
||||
@ -35,7 +43,7 @@ script:
|
||||
- if [ "${CXX}" = 'g++' ]; then export CXX=g++-4.8; fi;
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -L -DCMAKE_BUILD_TYPE=Dev ..
|
||||
- cmake -LA -DCMAKE_BUILD_TYPE=${CONFIGURATION} ..
|
||||
- make VERBOSE=1
|
||||
# Disable multipolygon test because it needs ruby and the 'json' gem, but the
|
||||
# travis ruby installation doesn't find the gem it did install itself.
|
||||
|
44
.ycm_extra_conf.py
Normal file
44
.ycm_extra_conf.py
Normal file
@ -0,0 +1,44 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Configuration for YouCompleteMe Vim plugin
|
||||
#
|
||||
# http://valloric.github.io/YouCompleteMe/
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# some default flags
|
||||
# for more information install clang-3.2-doc package and
|
||||
# check UsersManual.html
|
||||
flags = [
|
||||
'-Werror',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-pedantic',
|
||||
'-Wno-return-type',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-unused-variable',
|
||||
|
||||
'-std=c++11',
|
||||
|
||||
# '-x' and 'c++' also required
|
||||
# use 'c' for C projects
|
||||
'-x',
|
||||
'c++',
|
||||
|
||||
# libosmium include dirs
|
||||
'-Iinclude',
|
||||
'-Itest/include',
|
||||
'-Itest/data-test/include',
|
||||
|
||||
# include third party libraries
|
||||
'-I/usr/include/gdal',
|
||||
]
|
||||
|
||||
# youcompleteme is calling this function to get flags
|
||||
# You can also set database for flags. Check: JSONCompilationDatabase.html in
|
||||
# clang-3.2-doc package
|
||||
def FlagsForFile( filename ):
|
||||
return {
|
||||
'flags': flags,
|
||||
'do_cache': True
|
||||
}
|
309
CMakeLists.txt
309
CMakeLists.txt
@ -1,18 +1,20 @@
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Libosmium CMakeLists.txt
|
||||
# CMake Config
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
# Libosmium
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Project version
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
project(libosmium)
|
||||
|
||||
@ -20,85 +22,103 @@ set(LIBOSMIUM_VERSION_MAJOR 0)
|
||||
set(LIBOSMIUM_VERSION_MINOR 0)
|
||||
set(LIBOSMIUM_VERSION_PATCH 1)
|
||||
|
||||
set(LIBOSMIUM_VERSION ${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH})
|
||||
set(LIBOSMIUM_VERSION
|
||||
${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH})
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Build options
|
||||
#
|
||||
# (Change with -DOPTION=VALUE on cmake command line.)
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
option(BUILD_EXAMPLES "compile example programs" ON)
|
||||
option(BUILD_UNIT_TESTS "compile unit tests, please run them with ctest" ON)
|
||||
option(BUILD_DATA_TESTS "compile data tests, please run them with ctest" ON)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
|
||||
option(BUILD_HEADERS "compile every header file on its own" ON)
|
||||
set(dev_build ON)
|
||||
else()
|
||||
option(BUILD_HEADERS "compile every header file on its own" OFF)
|
||||
set(dev_build OFF)
|
||||
endif()
|
||||
|
||||
option(BUILD_EXAMPLES "compile example programs" ON)
|
||||
option(BUILD_TESTING "compile unit tests, please run them with ctest" ON)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
option(BUILD_HEADERS "compile every header file on its own" ${dev_build})
|
||||
option(BUILD_BENCHMARKS "compile benchmark programs" ${dev_build})
|
||||
option(BUILD_DATA_TESTS "compile data tests, please run them with ctest" ${dev_build})
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Find external dependencies
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# check that the essential libraries were found
|
||||
if(BUILD_EXAMPLES OR BUILD_TESTING OR BUILD_UNIT_TESTS OR BUILD_DATA_TESTS OR BUILD_HEADERS)
|
||||
find_package(Boost 1.38)
|
||||
mark_as_advanced(CLEAR BOOST_ROOT)
|
||||
|
||||
find_package(Boost 1.38)
|
||||
mark_as_advanced(CLEAR BOOST_ROOT)
|
||||
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
else()
|
||||
set(BOOST_ROOT "NOT FOUND: please choose" CACHE PATH "")
|
||||
message(FATAL_ERROR "PLEASE, specify the directory where the Boost library is installed in BOOST_ROOT")
|
||||
endif()
|
||||
|
||||
set(OSMIUM_INCLUDE_DIR include)
|
||||
find_package(Osmium COMPONENTS io gdal geos proj sparsehash)
|
||||
include_directories(${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(${GETOPT_INCLUDE_DIR})
|
||||
list(APPEND OSMIUM_LIBRARIES ${GETOPT_LIBRARY})
|
||||
else()
|
||||
set(GETOPT_MISSING 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
else()
|
||||
set(BOOST_ROOT "NOT FOUND: please choose" CACHE PATH "")
|
||||
message(FATAL_ERROR "PLEASE, specify the directory where the Boost library is installed in BOOST_ROOT")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
set(OSMIUM_INCLUDE_DIR include)
|
||||
find_package(Osmium COMPONENTS io gdal geos proj sparsehash)
|
||||
include_directories(${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(${GETOPT_INCLUDE_DIR})
|
||||
list(APPEND OSMIUM_LIBRARIES ${GETOPT_LIBRARY})
|
||||
else()
|
||||
set(GETOPT_MISSING 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(include)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Decide which C++ version to use (Minimum/default: C++11).
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if(NOT USE_CPP_VERSION)
|
||||
set(USE_CPP_VERSION c++11)
|
||||
#-----------------------------------------------------------------------------
|
||||
if(NOT MSVC)
|
||||
if(NOT USE_CPP_VERSION)
|
||||
set(USE_CPP_VERSION c++11)
|
||||
endif()
|
||||
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
|
||||
# following only available from cmake 2.8.12:
|
||||
# add_compile_options(-std=${USE_CPP_VERSION})
|
||||
# so using this instead:
|
||||
add_definitions(-std=${USE_CPP_VERSION})
|
||||
endif()
|
||||
message(STATUS "Use C++ version: ${USE_CPP_VERSION}")
|
||||
# following only available from cmake 2.8.12:
|
||||
# add_compile_options(-std=${USE_CPP_VERSION})
|
||||
# so using this instead:
|
||||
add_definitions(-std=${USE_CPP_VERSION})
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEV "-O3 -g"
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Compiler and Linker flags
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
if(MSVC)
|
||||
set(USUAL_COMPILE_OPTIONS "/Ox")
|
||||
else()
|
||||
set(USUAL_COMPILE_OPTIONS "-O3 -g")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DWIN32 -D_WIN32 -DMSWIN32 -DBGDWIN32
|
||||
-DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0600)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEV "${USUAL_COMPILE_OPTIONS}"
|
||||
CACHE STRING "Flags used by the compiler during developer builds."
|
||||
FORCE)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEV ""
|
||||
CACHE STRING "Flags used by the linker during developer builds."
|
||||
FORCE)
|
||||
@ -107,61 +127,76 @@ mark_as_advanced(
|
||||
CMAKE_EXE_LINKER_FLAGS_DEV
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g"
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${USUAL_COMPILE_OPTIONS}"
|
||||
CACHE STRING "Flags used by the compiler during RELWITHDEBINFO builds."
|
||||
FORCE)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Build Type
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug Release RelWithDebInfo MinSizeRel Dev")
|
||||
|
||||
# In 'Dev' mode: compile with very strict warnings and turn them into errors.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
|
||||
if(NOT MSVC)
|
||||
add_definitions(-Werror)
|
||||
endif()
|
||||
add_definitions(${OSMIUM_WARNING_OPTIONS})
|
||||
endif()
|
||||
|
||||
# Force RelWithDebInfo build type if none was given
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE)
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
set(build_type ${CMAKE_BUILD_TYPE})
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE)
|
||||
set(build_type "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DWIN32 -D_WIN32 -DMSWIN32 -DBGDWIN32 -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_WIN32_IE=0x0600)
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
else()
|
||||
set(CPACK_GENERATOR TGZ)
|
||||
endif()
|
||||
set(CMAKE_BUILD_TYPE ${build_type}
|
||||
CACHE STRING
|
||||
"Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}."
|
||||
FORCE)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Set up testing
|
||||
# Unit and data tests
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
enable_testing()
|
||||
|
||||
find_program(MEMORYCHECK_COMMAND valgrind)
|
||||
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full --show-reachable=yes --error-exitcode=1")
|
||||
set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.supp")
|
||||
if(BUILD_TESTING OR BUILD_DATA_TESTS)
|
||||
find_program(MEMORYCHECK_COMMAND valgrind)
|
||||
|
||||
if(BUILD_UNIT_TESTS OR BUILD_TESTING)
|
||||
set(MEMORYCHECK_COMMAND_OPTIONS
|
||||
"--trace-children=yes --leak-check=full --show-reachable=yes --error-exitcode=1")
|
||||
|
||||
set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.supp")
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
if(BUILD_DATA_TESTS OR BUILD_TESTING)
|
||||
add_subdirectory(test/osm-testdata)
|
||||
if(BUILD_DATA_TESTS)
|
||||
add_subdirectory(test/data-tests)
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Optional "cppcheck" target that checks C++ code
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Looking for cppcheck")
|
||||
find_program(CPPCHECK cppcheck)
|
||||
|
||||
if(CPPCHECK)
|
||||
message(STATUS "Looking for cppcheck - found")
|
||||
set(CPPCHECK_OPTIONS --enable=warning,style,performance,portability,information,missingInclude)
|
||||
set(CPPCHECK_OPTIONS
|
||||
--enable=warning,style,performance,portability,information,missingInclude)
|
||||
|
||||
# cpp doesn't find system includes for some reason, suppress that report
|
||||
set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem)
|
||||
@ -169,7 +204,7 @@ if(CPPCHECK)
|
||||
file(GLOB_RECURSE ALL_INCLUDES include/osmium/*.hpp)
|
||||
file(GLOB ALL_EXAMPLES examples/*.cpp)
|
||||
file(GLOB ALL_UNIT_TESTS test/t/*/test_*.cpp)
|
||||
file(GLOB ALL_DATA_TESTS test/osm-testdata/*.cpp)
|
||||
file(GLOB ALL_DATA_TESTS test/data-tests/*.cpp)
|
||||
|
||||
if(Osmium_DEBUG)
|
||||
message(STATUS "Checking includes : ${ALL_INCLUDES}")
|
||||
@ -178,7 +213,11 @@ if(CPPCHECK)
|
||||
message(STATUS "Checking data test code: ${ALL_DATA_TESTS}")
|
||||
endif()
|
||||
|
||||
set(CPPCHECK_FILES ${ALL_INCLUDES} ${ALL_EXAMPLES} ${ALL_UNIT_TESTS} ${ALL_DATA_TESTS})
|
||||
set(CPPCHECK_FILES
|
||||
${ALL_INCLUDES}
|
||||
${ALL_EXAMPLES}
|
||||
${ALL_UNIT_TESTS}
|
||||
${ALL_DATA_TESTS})
|
||||
|
||||
add_custom_target(cppcheck
|
||||
${CPPCHECK}
|
||||
@ -188,48 +227,42 @@ if(CPPCHECK)
|
||||
)
|
||||
else()
|
||||
message(STATUS "Looking for cppcheck - not found")
|
||||
message(STATUS " Make target cppcheck not available")
|
||||
message(STATUS " Build target 'cppcheck' will not be available.")
|
||||
endif(CPPCHECK)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Doxygen-based documentation
|
||||
# Examples, benchmarks and documentation
|
||||
#
|
||||
#----------------------------------------------------------------------
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
configure_file(doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html" DESTINATION "share/doc/libosmium-dev")
|
||||
else()
|
||||
message(STATUS "Doxygen not found, so 'doc' target will not be available.")
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# This will try to compile include files on their own to detect missing
|
||||
# include directives and other dependency-related problems. Note that if this
|
||||
# work, it is not enough to be sure it will compile in production code.
|
||||
# But if it reports an error we know we are missing something.
|
||||
if(BUILD_HEADERS)
|
||||
file(GLOB_RECURSE ALL_HPPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include" include/osmium/*.hpp)
|
||||
if(BUILD_BENCHMARKS)
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
|
||||
# In 'Dev' mode: compile with very strict warnings and turn them into errors.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
|
||||
add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS})
|
||||
endif()
|
||||
add_subdirectory(doc)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Headers
|
||||
#
|
||||
# This will try to compile include files on their own to detect missing
|
||||
# include directives and other dependency-related problems. Note that if this
|
||||
# work, it is not enough to be sure it will compile in production code.
|
||||
# But if it reports an error we know we are missing something.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
if(BUILD_HEADERS)
|
||||
file(GLOB_RECURSE
|
||||
ALL_HPPS
|
||||
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
include/osmium/*.hpp)
|
||||
|
||||
file(MAKE_DIRECTORY header_check)
|
||||
|
||||
@ -244,7 +277,19 @@ if(BUILD_HEADERS)
|
||||
|
||||
# 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} OBJECT ${DUMMYCPP} include/${hpp})
|
||||
add_library(${libname} STATIC ${DUMMYCPP} include/${hpp})
|
||||
|
||||
if(MSVC)
|
||||
# Remove warning LNK4221: "This object file does not define any
|
||||
# previously undefined public symbols, so it will not be used by
|
||||
# any link operation that consumes this library". This is a dummy
|
||||
# library anyways.
|
||||
target_link_libraries(${libname} /wd4221)
|
||||
endif()
|
||||
|
||||
#### this is better but only supported from cmake 3.0:
|
||||
###add_library(${libname} OBJECT ${DUMMYCPP} include/${hpp})
|
||||
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@ -254,6 +299,38 @@ install(DIRECTORY include/osmium DESTINATION include)
|
||||
# don't have it. We probably don't want to install it.
|
||||
#install(FILES include/boost_unicode_iterator.hpp DESTINATION include)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Packaging
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBOSMIUM_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${LIBOSMIUM_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${LIBOSMIUM_VERSION_PATCH})
|
||||
|
||||
if(WIN32)
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
else()
|
||||
set(CPACK_GENERATOR TGZ)
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Print warnings at the end
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
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("or set the OSM_TESTDATA cmake variable to its path.")
|
||||
message("=============================================================\n")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
10
Makefile
10
Makefile
@ -11,11 +11,11 @@ clean:
|
||||
distclean:
|
||||
rm -fr build
|
||||
|
||||
deb:
|
||||
debuild -I -us -uc
|
||||
|
||||
deb-clean:
|
||||
debuild clean
|
||||
#deb:
|
||||
# debuild -I -us -uc
|
||||
#
|
||||
#deb-clean:
|
||||
# debuild clean
|
||||
|
||||
indent:
|
||||
astyle --style=java --indent-namespaces --indent-switches --pad-header --lineend=linux --suffix=none --recursive include/\*.hpp examples/\*.cpp test/\*.cpp
|
||||
|
@ -1,43 +0,0 @@
|
||||
|
||||
Changes from old versions of Osmium
|
||||
===================================
|
||||
|
||||
This version has some substantial changes and users of Osmium will have to
|
||||
rewrite their code. Use the examples provided in the "example" directory
|
||||
or in the osmium-contrib repository to get an idea what needs changing.
|
||||
These examples are often similar to the examples provided with the old
|
||||
Osmium so they should give you an idea how your code has to change.
|
||||
|
||||
Here are some of the more important changes:
|
||||
|
||||
* Osmium now needs C++11. It will not work with older compilers. You need
|
||||
at least GCC 4.7.3 or clang (LLVM) 3.2.
|
||||
|
||||
* Namespaces are now all lower case. Everything is in the "osmium" namespace
|
||||
or sub-namespaces of it. Many classes and functions have been moved to
|
||||
different, more logical or shorter namespaces.
|
||||
|
||||
* You can't just instantiate OSM objects such as Nodes, Ways, or Relations.
|
||||
You need a Buffer first to hold them and use the Builder classes to
|
||||
create them. This is a bit more cumbersome, but greatly reduces the need
|
||||
for memory management and makes Osmium faster and easier to parallelize.
|
||||
|
||||
* Usually you don't act on single OSM objects any more, but on groups of
|
||||
them in a Buffer.
|
||||
|
||||
* Reading and writing of OSM data is much simpler. Use the Reader and Writer
|
||||
classes as they hide much of the detail and have much nicer interfaces
|
||||
than the old Input/Output classes.
|
||||
|
||||
* The class Osmium::OSM::Position was renamed to osmium::Location. This
|
||||
better reflects that it is a location on the planet we are talking about.
|
||||
The word "position" has many meanings and is, for instance, often used
|
||||
to denote a position in a file or buffer or so.
|
||||
|
||||
* The dependency on boost has been greatly reduced. C++11 offers many
|
||||
features that used to be only available with boost, such as shared_ptr.
|
||||
Osmium now uses the C++11 versions of these.
|
||||
|
||||
* Osmium now makes use of the new C++11 threading support when reading and
|
||||
writing OSM files.
|
||||
|
175
README.md
175
README.md
@ -1,112 +1,47 @@
|
||||
# Osmium Library
|
||||
# Libosmium
|
||||
|
||||
http://osmcode.org/libosmium
|
||||
|
||||
A fast and flexible C++ library for working with OpenStreetMap data.
|
||||
|
||||
NOTE: This is a beta version of the next-generation Osmium. For production
|
||||
use, see the Osmium version at https://github.com/joto/osmium .
|
||||
|
||||
There are a few applications that use the Osmium library in the examples
|
||||
directory. See the [osmium-contrib](http://github.com/osmcode/osmium-contrib)
|
||||
repository for more example code.
|
||||
|
||||
[](http://travis-ci.org/osmcode/libosmium)
|
||||
[](https://ci.appveyor.com/project/Mapbox/libosmium)
|
||||
|
||||
Libosmium is developed on Linux, but also works on OSX and Windows (with some
|
||||
limitations).
|
||||
|
||||
There are a few applications that use the Osmium library in the examples
|
||||
directory. See the [osmium-contrib](http://github.com/osmcode/osmium-contrib)
|
||||
repository for more example code.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Because Osmium uses many C++11 features you need a modern compiler and standard
|
||||
C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.2. (Some parts may
|
||||
work with older versions.)
|
||||
Because Libosmium uses many C++11 features you need a modern compiler and
|
||||
standard C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.4.
|
||||
(Some parts may work with older versions.)
|
||||
|
||||
Different parts of Osmium (and the applications built on top of it) need
|
||||
Different parts of Libosmium (and the applications built on top of it) need
|
||||
different libraries. You DO NOT NEED to install all of them, just install those
|
||||
you need for the programs you need.
|
||||
you need for your programs.
|
||||
|
||||
boost-iterator, boost-regex
|
||||
http://www.boost.org/
|
||||
Debian/Ubuntu: libboost-dev
|
||||
openSUSE: boost-devel
|
||||
Homebrew: boost
|
||||
|
||||
boost-program-options (for parsing command line options in some examples)
|
||||
http://www.boost.org/doc/libs/1_54_0/doc/html/program_options.html
|
||||
Debian/Ubuntu: libboost-program-options-dev
|
||||
|
||||
Google protocol buffers (for PBF support)
|
||||
http://code.google.com/p/protobuf/ (at least version 2.3.0 needed)
|
||||
Debian/Ubuntu: libprotobuf-dev protobuf-compiler
|
||||
openSUSE: protobuf-devel
|
||||
Homebrew: protobuf
|
||||
Also see http://wiki.openstreetmap.org/wiki/PBF_Format
|
||||
|
||||
OSMPBF (for PBF support)
|
||||
https://github.com/scrosby/OSM-binary
|
||||
Debian/Ubuntu: libosmpbf-dev
|
||||
(The package in Ubuntu 14.04 and older is too old, install from source
|
||||
in these cases.)
|
||||
Homebrew: osm-pbf
|
||||
|
||||
Expat (for parsing XML files)
|
||||
http://expat.sourceforge.net/
|
||||
Debian/Ubuntu: libexpat1-dev
|
||||
openSUSE: libexpat-devel
|
||||
Homebrew: expat
|
||||
|
||||
zlib (for PBF and for gzip support when reading/writing XML)
|
||||
http://www.zlib.net/
|
||||
Debian/Ubuntu: zlib1g-dev
|
||||
openSUSE: zlib-devel
|
||||
|
||||
bz2lib (for bzip2 support when reading/writing XML)
|
||||
http://www.bzip.org/
|
||||
Debian/Ubuntu: libbz2-dev
|
||||
|
||||
Google sparsehash
|
||||
http://code.google.com/p/google-sparsehash/
|
||||
Debian/Ubuntu: libsparsehash-dev
|
||||
openSUSE: sparsehash
|
||||
Homebrew: google-sparsehash
|
||||
|
||||
GDAL (for OGR support)
|
||||
http://gdal.org/
|
||||
Debian/Ubuntu: libgdal1-dev
|
||||
openSUSE: libgdal-devel
|
||||
Homebrew: gdal
|
||||
|
||||
GEOS (for GEOS support)
|
||||
http://trac.osgeo.org/geos/
|
||||
Debian/Ubuntu: libgeos++-dev
|
||||
openSUSE: libgeos-devel
|
||||
Homebrew: geos
|
||||
|
||||
libproj (for projection support)
|
||||
http://trac.osgeo.org/proj/
|
||||
Debian/Ubuntu: libproj-dev
|
||||
|
||||
Doxygen (to build API documentation) and tools
|
||||
http://www.stack.nl/~dimitri/doxygen/
|
||||
Debian/Ubuntu: doxygen graphviz xmlstarlet
|
||||
Homebrew: doxygen
|
||||
|
||||
You need to either install the packages for your distribution or install those
|
||||
libraries from source. Most libraries should be available in all distributions.
|
||||
For details see the
|
||||
[list of dependencies](https://github.com/osmcode/libosmium/wiki/Libosmium-dependencies).
|
||||
|
||||
|
||||
## Directories
|
||||
|
||||
* include: C/C++ include files. All of Osmium is in those header files which
|
||||
are needed for building Osmium applications.
|
||||
* benchmarks: Some benchmarks checking different parts of Libosmium.
|
||||
|
||||
* cmake: CMake configuration scripts.
|
||||
|
||||
* doc: Config for documentation.
|
||||
|
||||
* examples: Osmium example applications.
|
||||
|
||||
* test: Tests (see below).
|
||||
* include: C/C++ include files. All of Libosmium is in those header files
|
||||
which are needed for building Osmium applications.
|
||||
|
||||
* doc: Config for documentation.
|
||||
* test: Tests (see below).
|
||||
|
||||
|
||||
## Building
|
||||
@ -124,61 +59,15 @@ cmake:
|
||||
|
||||
This will build the examples and tests. Call `ctest` to run the tests.
|
||||
|
||||
To build the documentation you need Doxygen. If cmake can find it it will
|
||||
enable the `doc` target so you can build the documentation like this:
|
||||
|
||||
make doc
|
||||
|
||||
If the 'cppcheck' binary is found, cmake will add another target to the
|
||||
Makfile which allows you to call cppheck on all `*.cpp` and `*.hpp` files:
|
||||
|
||||
make cppcheck
|
||||
|
||||
For Mac users: If you have clang 3.2 or newer, use the system compiler.
|
||||
If not you have to build the compiler yourself. See the instructions
|
||||
on http://clang.llvm.org/ .
|
||||
|
||||
Preliminary support for cmake is provided. You can use this instead of "make":
|
||||
For more see the
|
||||
[Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Building-Libosmium).
|
||||
|
||||
|
||||
## Testing
|
||||
|
||||
### Unit Tests
|
||||
|
||||
There are a few unit tests using the Catch unit test framework in the "test"
|
||||
directory. Many more tests are needed, any help appreciated.
|
||||
|
||||
For [Catch](https://github.com/philsquared/Catch/) only one header file is
|
||||
needed which is included (`test/include/catch.hpp`).
|
||||
|
||||
To compile these unit tests make sure `BUILD_UNIT_TESTS` is set in the cmake
|
||||
config, then build the project and call
|
||||
|
||||
ctest
|
||||
|
||||
You can run tests matching a pattern by calling
|
||||
|
||||
ctest -R test_name
|
||||
|
||||
for instance:
|
||||
|
||||
ctest basic_test_node
|
||||
|
||||
will run the `basic_test_node` and `basic_test_node_ref` tests.
|
||||
|
||||
### Data Tests
|
||||
|
||||
In addition there are some test based on the OSM Test Data Repository at
|
||||
http://osmcode.org/osm-testdata/ . Make sure `BUILD_DATA_TESTS` is set in the
|
||||
cmake config, then build the project and call `ctest`.
|
||||
|
||||
Some of these tests need Ruby and then 'json' gem installed.
|
||||
|
||||
### Valgrind
|
||||
|
||||
Running tests with valgrind:
|
||||
|
||||
ctest -D ExperimentalMemCheck
|
||||
See the
|
||||
[Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Testing-Libosmium)
|
||||
for instructions.
|
||||
|
||||
|
||||
## Osmium on 32bit Machines
|
||||
@ -198,20 +87,18 @@ Please report any issues you have and we might be able to solve them.
|
||||
|
||||
## Switching from the old Osmium
|
||||
|
||||
See `README-changes-from-old-osmium`.
|
||||
If you have been using the old version of Osmium at
|
||||
https://github.com/joto/osmium you might want to read about the
|
||||
[changes needed](https://github.com/osmcode/libosmium/wiki/Changes-from-old-versions-of-Osmium).
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The Osmium Library is available under the Boost Software License. See
|
||||
LICENSE.txt.
|
||||
Libosmium is available under the Boost Software License. See LICENSE.txt.
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
The Osmium Library was mainly written and is maintained by Jochen Topf
|
||||
(jochen@topf.org).
|
||||
|
||||
Other authors:
|
||||
* Peter Körner (github@mazdermind.de) (PBF writer, ...)
|
||||
Libosmium was mainly written and is maintained by Jochen Topf
|
||||
(jochen@topf.org). See the git commit log for other authors.
|
||||
|
||||
|
72
appveyor.yml
72
appveyor.yml
@ -1,11 +1,13 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Configuration for appveyor.com
|
||||
# Configuration for continuous integration service at appveyor.com
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- configuration: Dev
|
||||
# - configuration: Release
|
||||
- config: Dev
|
||||
- config: Release
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
@ -14,7 +16,7 @@ branches:
|
||||
- master
|
||||
|
||||
# Operating system (build VM template)
|
||||
os: Windows Server 2012 R2
|
||||
os: Visual Studio 2014 CTP4
|
||||
|
||||
# scripts that are called at very beginning, before repo cloning
|
||||
init:
|
||||
@ -25,31 +27,51 @@ clone_folder: c:\projects\libosmium
|
||||
platform: x64
|
||||
|
||||
install:
|
||||
# by default, all script lines are interpreted as batch
|
||||
# show all availble env vars
|
||||
- SET
|
||||
- ECHO cmake on AppVeyor
|
||||
- cmake -version
|
||||
- CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
- SET PATH=c:\projects\libosmium\cmake-3.1.0-win32-x86\bin;%PATH%
|
||||
- SET LODEPSDIR=c:\projects\libosmium\libosmium-deps
|
||||
- SET PROJ_LIB=%LODEPSDIR%\proj\share
|
||||
- set GDAL_DATA=%LODEPSDIR%\gdal\data
|
||||
#geos.dll
|
||||
- SET PATH=%LODEPSDIR%\geos\lib;%PATH%
|
||||
#gdal.dll
|
||||
- SET PATH=%LODEPSDIR%\gdal\lib;%PATH%
|
||||
#libexpat.dll
|
||||
- SET PATH=%LODEPSDIR%\expat\lib;%PATH%
|
||||
#libtiff.dll
|
||||
- SET PATH=%LODEPSDIR%\libtiff\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:\=/%
|
||||
- ps: Start-FileDownload https://mapnik.s3.amazonaws.com/deps/cmake-3.1.0-win32-x86.7z -FileName cm.7z
|
||||
- ps: Start-FileDownload https://mapnik.s3.amazonaws.com/dist/dev/libosmium-deps-win-14.0-x64.7z -FileName lodeps.7z
|
||||
- 7z x cm.7z > null
|
||||
- 7z x lodeps.7z > nul
|
||||
- echo %LODEPSDIR%
|
||||
- dir %LODEPSDIR%
|
||||
- ECHO our own cmake
|
||||
- cmake -version
|
||||
- cd c:\projects
|
||||
- nuget install boost
|
||||
- nuget install bzip2
|
||||
- nuget install zlib
|
||||
- nuget install GDAL
|
||||
- nuget install expat
|
||||
- nuget install protobuf
|
||||
- dir /S c:\projects
|
||||
- git clone https://github.com/scrosby/OSM-binary
|
||||
- cd OSM-binary
|
||||
- mkdir build
|
||||
- cd build
|
||||
- call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
|
||||
- cmake .. -G "Visual Studio 12 Win64" -DSEARCH_PREFIX=c:\projects -T CTP_Nov2013
|
||||
- msbuild /clp:Verbosity=minimal /nologo OSM-binary.sln
|
||||
- git clone https://github.com/osmcode/osm-testdata.git
|
||||
|
||||
build_script:
|
||||
- cd c:\projects\libosmium
|
||||
- mkdir build
|
||||
- cd build
|
||||
- call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
|
||||
- SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
|
||||
- SET P=c:/projects/libosmium
|
||||
- cmake .. -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_PREFIX_PATH=c:\projects -DBoost_USE_STATIC_LIBS=ON -T CTP_Nov2013
|
||||
- msbuild /clp:Verbosity=minimal /nologo libosmium.sln
|
||||
- msbuild /clp:Verbosity=minimal /nologo tests.vcxproj
|
||||
- echo %config%
|
||||
- cmake .. -LA -G "Visual Studio 14 Win64" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include
|
||||
- msbuild libosmium.sln /p:Configuration=Release /toolsversion:14.0 /p:Platform=x64 /p:PlatformToolset=v140
|
||||
#- cmake .. -LA -G "NMake Makefiles" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include
|
||||
#- nmake
|
||||
|
||||
test_script:
|
||||
# Disable multipolygon test because it needs ruby and the 'json' gem
|
||||
- ctest -V -C %config% -E testdata-multipolygon
|
||||
|
||||
|
48
benchmarks/CMakeLists.txt
Normal file
48
benchmarks/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# CMake Config
|
||||
#
|
||||
# Libosmium benchmarks
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
message(STATUS "Configuring benchmarks")
|
||||
|
||||
set(BENCHMARKS
|
||||
count
|
||||
count_tag
|
||||
index_map
|
||||
static_vs_dynamic_index
|
||||
CACHE STRING "Benchmark programs"
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Configure benchmarks
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
message(STATUS "Configuring benchmarks - Building these benchmarks:")
|
||||
foreach(benchmark ${BENCHMARKS})
|
||||
message(STATUS " - osmium_benchmark_${benchmark}")
|
||||
add_executable(osmium_benchmark_${benchmark}
|
||||
"osmium_benchmark_${benchmark}.cpp")
|
||||
target_link_libraries(osmium_benchmark_${benchmark}
|
||||
${OSMIUM_IO_LIBRARIES}
|
||||
${BENCHMARK_LIBS_${benchmark}})
|
||||
configure_file(run_benchmark_${benchmark}.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/run_benchmark_${benchmark}.sh
|
||||
@ONLY)
|
||||
endforeach()
|
||||
|
||||
foreach(file setup run_benchmarks)
|
||||
configure_file(${file}.sh ${CMAKE_CURRENT_BINARY_DIR}/${file}.sh @ONLY)
|
||||
endforeach()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Configuring benchmarks - done")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
41
benchmarks/README.md
Normal file
41
benchmarks/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
# Benchmarks
|
||||
|
||||
Benchmarks check the performance of different parts of Libosmium.
|
||||
|
||||
## Preparations
|
||||
|
||||
To run the benchmarks first make a directory for the data files somewhere
|
||||
(outside the repository) and set the `DATA_DIR` environment variable:
|
||||
|
||||
export DATA_DIR=benchmark_data
|
||||
mkdir $DATA_DIR
|
||||
|
||||
Then copy the OSM files you want to do the benchmarks with into this directory.
|
||||
You can use the `download_data.sh` script to download a selection of OSM files
|
||||
in different sizes, but you can use a different selection, too. The benchmarks
|
||||
will use whatever files you have in the `DATA_DIR` directory.
|
||||
|
||||
The download script will start the data files names with a number in order of
|
||||
the size of the file from smallest to largest. You can use the same convention
|
||||
or use a different one. Benchmarks will be run on the files in alphabetical
|
||||
order.
|
||||
|
||||
The files don't have to be in that directory, you can add soft links from that
|
||||
directory to the real file locations if that suits you.
|
||||
|
||||
## Compiling the benchmarks
|
||||
|
||||
To build the benchmarks set the `BUILD_BENCHMARKS` option when configuring with
|
||||
CMake and run the compilation by calling `make` (or whatever build tool you
|
||||
are using).
|
||||
|
||||
## Running the benchmarks
|
||||
|
||||
Go to the build directory and run `benchmarks/run_benchmarks.sh`. You can also
|
||||
run each benchmark on its own by calling the respective script in the
|
||||
`benchmarks` directory.
|
||||
|
||||
Results of the benchmarks will be printed to stdout, you might want to redirect
|
||||
them into a file.
|
||||
|
12
benchmarks/download_data.sh
Executable file
12
benchmarks/download_data.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# download_data.sh
|
||||
#
|
||||
|
||||
cd $DATA_DIR
|
||||
curl --location --output 1_liechtenstein.osm.pbf http://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf # about 1 MB
|
||||
curl --location --output 2_bremen.osm.pbf http://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf # about 13 MB
|
||||
curl --location --output 3_sachsen.osm.pbf http://download.geofabrik.de/europe/germany/sachsen-latest.osm.pbf # about 120 MB
|
||||
curl --location --output 4_germany.osm.pbf http://download.geofabrik.de/europe/germany-latest.osm.pbf # about 2 GB
|
||||
curl --location --output 5_planet.osm.pbf http://planet.osm.org/pbf/planet-latest.osm.pbf # about 26 GB
|
||||
|
54
benchmarks/osmium_benchmark_count.cpp
Normal file
54
benchmarks/osmium_benchmark_count.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
|
||||
The code in this file is released into the Public Domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
struct CountHandler : public osmium::handler::Handler {
|
||||
|
||||
int nodes = 0;
|
||||
int ways = 0;
|
||||
int relations = 0;
|
||||
|
||||
void node(osmium::Node&) {
|
||||
++nodes;
|
||||
}
|
||||
|
||||
void way(osmium::Way&) {
|
||||
++ways;
|
||||
}
|
||||
|
||||
void relation(osmium::Relation&) {
|
||||
++relations;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Usage: " << argv[0] << " OSMFILE\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string input_filename = argv[1];
|
||||
|
||||
osmium::io::Reader reader(input_filename);
|
||||
|
||||
CountHandler handler;
|
||||
osmium::apply(reader, handler);
|
||||
reader.close();
|
||||
|
||||
std::cout << "Nodes: " << handler.nodes << "\n";
|
||||
std::cout << "Ways: " << handler.ways << "\n";
|
||||
std::cout << "Relations: " << handler.relations << "\n";
|
||||
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
|
55
benchmarks/osmium_benchmark_count_tag.cpp
Normal file
55
benchmarks/osmium_benchmark_count_tag.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
|
||||
The code in this file is released into the Public Domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
struct CountHandler : public osmium::handler::Handler {
|
||||
|
||||
int counter = 0;
|
||||
int all = 0;
|
||||
|
||||
void node(osmium::Node& node) {
|
||||
++all;
|
||||
const char* amenity = node.tags().get_value_by_key("amenity");
|
||||
if (amenity && !strcmp(amenity, "post_box")) {
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
void way(osmium::Way&) {
|
||||
++all;
|
||||
}
|
||||
|
||||
void relation(osmium::Relation&) {
|
||||
++all;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Usage: " << argv[0] << " OSMFILE\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string input_filename = argv[1];
|
||||
|
||||
osmium::io::Reader reader(input_filename);
|
||||
|
||||
CountHandler handler;
|
||||
osmium::apply(reader, handler);
|
||||
reader.close();
|
||||
|
||||
std::cout << "r_all=" << handler.all << " r_counter=" << handler.counter << "\n";
|
||||
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
|
41
benchmarks/osmium_benchmark_index_map.cpp
Normal file
41
benchmarks/osmium_benchmark_index_map.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
|
||||
The code in this file is released into the Public Domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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>
|
||||
|
||||
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_type> location_handler_type;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " OSMFILE FORMAT\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string input_filename = argv[1];
|
||||
std::string location_store = argv[2];
|
||||
|
||||
osmium::io::Reader reader(input_filename);
|
||||
|
||||
const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
|
||||
std::unique_ptr<index_type> index = map_factory.create_map(location_store);
|
||||
location_handler_type location_handler(*index);
|
||||
location_handler.ignore_errors();
|
||||
|
||||
osmium::apply(reader, location_handler);
|
||||
reader.close();
|
||||
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
|
136
benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp
Normal file
136
benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
|
||||
This benchmarks compares the run time for statically vs. dynamically
|
||||
configured index maps. You can configure index maps at compile-time using
|
||||
typedefs or at run-time using polymorphism.
|
||||
|
||||
This will read the input file into a buffer and then run the
|
||||
NodeLocationForWays handler multiple times over the complete data. The
|
||||
number of runs depends on the size of the input, but is never smaller
|
||||
than 10.
|
||||
|
||||
Do not run this with very large input files! It will need about 10 times
|
||||
as much RAM as the file size of the input file.
|
||||
|
||||
The code in this file is released into the Public Domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#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>
|
||||
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> static_index_type;
|
||||
const std::string location_store="sparse_mem_array";
|
||||
|
||||
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> dynamic_index_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<static_index_type> static_location_handler_type;
|
||||
typedef osmium::handler::NodeLocationsForWays<dynamic_index_type> dynamic_location_handler_type;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Usage: " << argv[0] << " OSMFILE\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string input_filename = argv[1];
|
||||
|
||||
osmium::memory::Buffer buffer = osmium::io::read_file(input_filename);
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
|
||||
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 int runs = std::max(10, static_cast<int>(5000ull / buffer_size));
|
||||
|
||||
std::cout << "input: filename=" << input_filename << " buffer_size=" << buffer_size << "MBytes\n";
|
||||
std::cout << "runs: " << runs << "\n";
|
||||
|
||||
double static_min = std::numeric_limits<double>::max();
|
||||
double static_sum = 0;
|
||||
double static_max = 0;
|
||||
|
||||
double dynamic_min = std::numeric_limits<double>::max();
|
||||
double dynamic_sum = 0;
|
||||
double dynamic_max = 0;
|
||||
|
||||
for (int i = 0; i < runs; ++i) {
|
||||
|
||||
{
|
||||
// static index
|
||||
osmium::memory::Buffer tmp_buffer(buffer.committed());
|
||||
for (const auto& item : buffer) {
|
||||
tmp_buffer.add_item(item);
|
||||
tmp_buffer.commit();
|
||||
}
|
||||
|
||||
static_index_type static_index;
|
||||
static_location_handler_type static_location_handler(static_index);
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
osmium::apply(tmp_buffer, static_location_handler);
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
|
||||
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;
|
||||
static_sum += duration;
|
||||
}
|
||||
|
||||
{
|
||||
// dynamic index
|
||||
osmium::memory::Buffer tmp_buffer(buffer.committed());
|
||||
for (const auto& item : buffer) {
|
||||
tmp_buffer.add_item(item);
|
||||
tmp_buffer.commit();
|
||||
}
|
||||
|
||||
std::unique_ptr<dynamic_index_type> index = map_factory.create_map(location_store);
|
||||
dynamic_location_handler_type dynamic_location_handler(*index);
|
||||
dynamic_location_handler.ignore_errors();
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
osmium::apply(tmp_buffer, dynamic_location_handler);
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
|
||||
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;
|
||||
dynamic_sum += duration;
|
||||
}
|
||||
}
|
||||
|
||||
double static_avg = static_sum/runs;
|
||||
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";
|
||||
|
||||
double rfactor = 100.0;
|
||||
double diff_min = std::round((dynamic_min - static_min) * rfactor) / rfactor;
|
||||
double diff_avg = std::round((dynamic_avg - static_avg) * rfactor) / rfactor;
|
||||
double diff_max = std::round((dynamic_max - static_max) * rfactor) / rfactor;
|
||||
|
||||
double prfactor = 10.0;
|
||||
double percent_min = std::round((100.0 * diff_min / static_min) * prfactor) / prfactor;
|
||||
double percent_avg = std::round((100.0 * diff_avg / static_avg) * prfactor) / prfactor;
|
||||
double percent_max = std::round((100.0 * diff_max / static_max) * prfactor) / prfactor;
|
||||
|
||||
std::cout << "difference:";
|
||||
std::cout << " min=" << diff_min << "ms (" << percent_min << "%)";
|
||||
std::cout << " avg=" << diff_avg << "ms (" << percent_avg << "%)";
|
||||
std::cout << " max=" << diff_max << "ms (" << percent_max << "%)\n";
|
||||
}
|
||||
|
22
benchmarks/run_benchmark_count.sh
Executable file
22
benchmarks/run_benchmark_count.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run_benchmark_count.sh
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BENCHMARK_NAME=count
|
||||
|
||||
. @CMAKE_BINARY_DIR@/benchmarks/setup.sh
|
||||
|
||||
CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME
|
||||
|
||||
echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options"
|
||||
for data in $OB_DATA_FILES; do
|
||||
filename=`basename $data`
|
||||
filesize=`stat --format="%s" --dereference $data`
|
||||
for n in $OB_SEQ; do
|
||||
$OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%"
|
||||
done
|
||||
done
|
||||
|
22
benchmarks/run_benchmark_count_tag.sh
Executable file
22
benchmarks/run_benchmark_count_tag.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run_benchmark_count_tag.sh
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BENCHMARK_NAME=count_tag
|
||||
|
||||
. @CMAKE_BINARY_DIR@/benchmarks/setup.sh
|
||||
|
||||
CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME
|
||||
|
||||
echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options"
|
||||
for data in $OB_DATA_FILES; do
|
||||
filename=`basename $data`
|
||||
filesize=`stat --format="%s" --dereference $data`
|
||||
for n in $OB_SEQ; do
|
||||
$OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%"
|
||||
done
|
||||
done
|
||||
|
27
benchmarks/run_benchmark_index_map.sh
Executable file
27
benchmarks/run_benchmark_index_map.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run_benchmark_index_map.sh
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BENCHMARK_NAME=index_map
|
||||
|
||||
. @CMAKE_BINARY_DIR@/benchmarks/setup.sh
|
||||
|
||||
CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME
|
||||
|
||||
#MAPS="sparse_mem_map sparse_mem_table sparse_mem_array sparse_mmap_array sparse_file_array dense_mem_array dense_mmap_array dense_file_array"
|
||||
MAPS="sparse_mem_map sparse_mem_table sparse_mem_array sparse_mmap_array sparse_file_array"
|
||||
|
||||
echo "# file size num mem time cpu_kernel cpu_user cpu_percent cmd options"
|
||||
for data in $OB_DATA_FILES; do
|
||||
filename=`basename $data`
|
||||
filesize=`stat --format="%s" --dereference $data`
|
||||
for map in $MAPS; do
|
||||
for n in $OB_SEQ; do
|
||||
$OB_TIME_CMD -f "$filename $filesize $n $OB_TIME_FORMAT" $CMD $data $map 2>&1 >/dev/null | sed -e "s%$DATA_DIR/%%" | sed -e "s%$OB_DIR/%%"
|
||||
done
|
||||
done
|
||||
done
|
||||
|
21
benchmarks/run_benchmark_static_vs_dynamic_index.sh
Executable file
21
benchmarks/run_benchmark_static_vs_dynamic_index.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run_benchmark_static_vs_dynamic_index.sh
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BENCHMARK_NAME=static_vs_dynamic_index
|
||||
|
||||
. @CMAKE_BINARY_DIR@/benchmarks/setup.sh
|
||||
|
||||
CMD=$OB_DIR/osmium_benchmark_$BENCHMARK_NAME
|
||||
|
||||
for data in $OB_DATA_FILES; do
|
||||
filesize=`stat --format="%s" --dereference $data`
|
||||
if [ $filesize -lt 500000000 ]; then
|
||||
echo "========================"
|
||||
$CMD $data
|
||||
fi
|
||||
done
|
||||
|
15
benchmarks/run_benchmarks.sh
Executable file
15
benchmarks/run_benchmarks.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run_benchmarks.sh
|
||||
#
|
||||
# Run all benchmarks.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
for benchmark in @CMAKE_BINARY_DIR@/benchmarks/run_benchmark_*.sh; do
|
||||
name=`basename $benchmark`
|
||||
echo "Running $name..."
|
||||
$benchmark
|
||||
done
|
||||
|
34
benchmarks/setup.sh
Executable file
34
benchmarks/setup.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# setup.sh
|
||||
#
|
||||
|
||||
if [ -z $DATA_DIR ]; then
|
||||
echo "Please set DATA_DIR environment variable before running benchmark"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OB_DIR=@CMAKE_BINARY_DIR@/benchmarks
|
||||
|
||||
OB_RUNS=3
|
||||
OB_SEQ=`seq -s' ' 1 $OB_RUNS`
|
||||
|
||||
OB_TIME_CMD=/usr/bin/time
|
||||
OB_TIME_FORMAT="%M %e %S %U %P %C"
|
||||
|
||||
OB_DATA_FILES=`find -L $DATA_DIR -mindepth 1 -maxdepth 1 -type f | sort`
|
||||
|
||||
echo "BENCHMARK: $BENCHMARK_NAME"
|
||||
echo "---------------------"
|
||||
echo "CPU:"
|
||||
grep '^model name' /proc/cpuinfo | tail -1
|
||||
grep '^cpu MHz' /proc/cpuinfo | tail -1
|
||||
grep '^cpu cores' /proc/cpuinfo | tail -1
|
||||
grep '^siblings' /proc/cpuinfo | tail -1
|
||||
|
||||
echo "---------------------"
|
||||
echo "MEMORY:"
|
||||
free
|
||||
echo "---------------------"
|
||||
echo "RESULTS:"
|
||||
|
@ -9,16 +9,15 @@
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# Copy this file (and OsmiumOptions.cmake) somewhere into your project
|
||||
# directory, where cmake can find it. Usually this will be a directory
|
||||
# called "cmake" which you can add to your module search path with the
|
||||
# following line in your CMakeLists.txt:
|
||||
# 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:
|
||||
#
|
||||
# include(OsmiumOptions)
|
||||
# find_package(Osmium REQUIRED COMPONENTS <XXX>)
|
||||
# include_directories(${OSMIUM_INCLUDE_DIRS})
|
||||
#
|
||||
@ -75,6 +74,8 @@ find_package_handle_standard_args(OSMIUM REQUIRED_VARS OSMIUM_INCLUDE_DIR)
|
||||
# Copy the results to the output variables.
|
||||
if(OSMIUM_FOUND)
|
||||
set(OSMIUM_INCLUDE_DIRS ${OSMIUM_INCLUDE_DIR})
|
||||
else()
|
||||
set(OSMIUM_INCLUDE_DIRS "")
|
||||
endif()
|
||||
|
||||
if(Osmium_FIND_REQUIRED AND NOT OSMIUM_FOUND)
|
||||
@ -234,10 +235,22 @@ endif()
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
list(REMOVE_DUPLICATES OSMIUM_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_LIBRARIES)
|
||||
|
||||
if(OSMIUM_XML_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(OSMIUM_PBF_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(OSMIUM_IO_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES)
|
||||
endif()
|
||||
|
||||
if(OSMIUM_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES OSMIUM_LIBRARIES)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#
|
||||
@ -256,7 +269,14 @@ endif()
|
||||
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-wd4996 -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions(-wd4996)
|
||||
add_definitions(-wd4068)
|
||||
|
||||
# Disable warning C4715: "not all control paths return a value" because
|
||||
# it generates too many false positives.
|
||||
add_definitions(-wd4715)
|
||||
|
||||
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
@ -271,7 +291,11 @@ endif()
|
||||
|
||||
# This is a set of recommended warning options that can be added when compiling
|
||||
# libosmium code.
|
||||
set(OSMIUM_WARNING_OPTIONS "-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast -Wno-return-type" CACHE STRING "Recommended warning options for libosmium")
|
||||
if(MSVC)
|
||||
set(OSMIUM_WARNING_OPTIONS "/W3 /wd4514" CACHE STRING "Recommended warning options for libosmium")
|
||||
else()
|
||||
set(OSMIUM_WARNING_OPTIONS "-Wall -Wextra -pedantic -Wredundant-decls -Wdisabled-optimization -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wold-style-cast -Wno-return-type" CACHE STRING "Recommended warning options for libosmium")
|
||||
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")
|
||||
|
||||
|
34
doc/CMakeLists.txt
Normal file
34
doc/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# CMake Config
|
||||
#
|
||||
# Libosmium documentation
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
message(STATUS "Configuring documentation")
|
||||
|
||||
message(STATUS "Looking for doxygen")
|
||||
find_package(Doxygen)
|
||||
|
||||
if(DOXYGEN_FOUND)
|
||||
message(STATUS "Looking for doxygen - found")
|
||||
configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||
)
|
||||
# install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html"
|
||||
# DESTINATION "share/doc/libosmium-dev")
|
||||
else()
|
||||
message(STATUS "Looking for doxygen - not found")
|
||||
message(STATUS " Disabled making of documentation.")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Configuring documentation - done")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
|
||||
# title of most generated pages and in a few other places.
|
||||
# The default value is: My Project.
|
||||
|
||||
PROJECT_NAME = "Osmium"
|
||||
PROJECT_NAME = "Libosmium"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
|
@ -1,64 +1,115 @@
|
||||
message(STATUS "Configuring examples...")
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# CMake Config
|
||||
#
|
||||
# Libosmium examples
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if(GETOPT_MISSING)
|
||||
message(FATAL_ERROR "On Visual Studio the wingetopt library is needed to compile examples")
|
||||
endif()
|
||||
message(STATUS "Configuring examples")
|
||||
|
||||
set(SIMPLE_EXAMPLES
|
||||
osmium_convert
|
||||
osmium_count
|
||||
osmium_create_node_cache
|
||||
osmium_debug
|
||||
osmium_read
|
||||
osmium_serdump
|
||||
osmium_use_node_cache
|
||||
set(EXAMPLES
|
||||
area_test
|
||||
convert
|
||||
count
|
||||
create_node_cache
|
||||
debug
|
||||
index
|
||||
read
|
||||
serdump
|
||||
toogr
|
||||
toogr2
|
||||
toogr2_exp
|
||||
use_node_cache
|
||||
CACHE STRING "Example programs"
|
||||
)
|
||||
|
||||
if(SPARSEHASH_FOUND)
|
||||
list(APPEND SIMPLE_EXAMPLES osmium_area_test)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Examples depending on wingetopt
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
set(GETOPT_EXAMPLES area_test convert serdump toogr toogr2 toogr2_exp)
|
||||
if(NOT GETOPT_MISSING)
|
||||
foreach(example ${GETOPT_EXAMPLES})
|
||||
list(APPEND EXAMPLE_LIBS_${example} ${GETOPT_LIBRARY})
|
||||
endforeach()
|
||||
else()
|
||||
message("Skipped osmium_area_test example - needed Google SparseHash")
|
||||
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()
|
||||
|
||||
# In 'Dev' mode: compile with very strict warnings and turn them into errors.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
|
||||
add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Examples depending on SparseHash
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
if(NOT SPARSEHASH_FOUND)
|
||||
list(REMOVE_ITEM EXAMPLES area_test)
|
||||
message(STATUS "Configuring examples - Skipping examples because Google SparseHash not found:")
|
||||
message(STATUS " - osmium_area_test")
|
||||
endif()
|
||||
|
||||
foreach(example ${SIMPLE_EXAMPLES})
|
||||
message(STATUS "Configuring example ${example}...")
|
||||
add_executable(${example} "${example}.cpp")
|
||||
target_link_libraries(${example} ${OSMIUM_LIBRARIES})
|
||||
endforeach(example)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Examples depending on Boost Program Options
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
unset(Boost_LIBRARIES)
|
||||
unset(Boost_FOUND)
|
||||
find_package(Boost 1.38 COMPONENTS program_options)
|
||||
|
||||
if(Boost_PROGRAM_OPTIONS_FOUND)
|
||||
set(example
|
||||
osmium_index
|
||||
)
|
||||
message(STATUS "Configuring example ${example}...")
|
||||
add_executable(${example} "${example}.cpp")
|
||||
target_link_libraries(${example} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OSMIUM_LIBRARIES})
|
||||
list(APPEND EXAMPLE_LIBS_index ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
||||
else()
|
||||
message("Can not build osmium_index example without Boost program_options")
|
||||
list(REMOVE_ITEM EXAMPLES index)
|
||||
message(STATUS "Configuring examples - Skipping examples because Boost program_options not found:")
|
||||
message(STATUS " - osmium_index")
|
||||
endif()
|
||||
|
||||
set(OGR_EXAMPLES
|
||||
osmium_toogr
|
||||
osmium_toogr2
|
||||
osmium_toogr2_exp
|
||||
)
|
||||
|
||||
if(GDAL_FOUND AND GEOS_FOUND AND SPARSEHASH_FOUND)
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Examples depending on GDAL/PROJ.4/SparseHash
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
set(OGR_EXAMPLES toogr toogr2 toogr2_exp)
|
||||
|
||||
if(GDAL_FOUND AND PROJ_FOUND AND SPARSEHASH_FOUND)
|
||||
foreach(example ${OGR_EXAMPLES})
|
||||
message(STATUS "Configuring example ${example}...")
|
||||
add_executable(${example} "${example}.cpp")
|
||||
target_link_libraries(${example} ${OSMIUM_LIBRARIES})
|
||||
endforeach(example)
|
||||
list(APPEND EXAMPLE_LIBS_${example} ${GDAL_LIBRARIES})
|
||||
list(APPEND EXAMPLE_LIBS_${example} ${PROJ_LIBRARIES})
|
||||
endforeach()
|
||||
else()
|
||||
message("GDAL+GEOS+SparseHash not found, skipping OGR examples")
|
||||
message(STATUS "Configuring examples - Skipping examples because GDAL and/or Proj.4 and/or SparseHash not found:")
|
||||
foreach(example ${OGR_EXAMPLES})
|
||||
message(STATUS " - osmium_${example}")
|
||||
list(REMOVE_ITEM EXAMPLES ${example})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Configure examples
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Configuring examples - Building these examples:")
|
||||
foreach(example ${EXAMPLES})
|
||||
message(STATUS " - osmium_${example}")
|
||||
add_executable(osmium_${example} "osmium_${example}.cpp")
|
||||
target_link_libraries(osmium_${example} ${OSMIUM_IO_LIBRARIES} ${EXAMPLE_LIBS_${example}})
|
||||
endforeach()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Configuring examples - done")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -18,12 +18,12 @@
|
||||
#include <osmium/handler/dump.hpp>
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_table.hpp>
|
||||
#include <osmium/index/map/sparse_mem_table.hpp>
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
class WKTDump : public osmium::handler::Handler {
|
||||
|
@ -16,15 +16,15 @@
|
||||
#include <osmium/io/xml_input.hpp>
|
||||
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/map/mmap_vector_file.hpp>
|
||||
#include <osmium/index/map/dense_mmap_array.hpp>
|
||||
#include <osmium/index/map/dense_file_array.hpp>
|
||||
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::DenseMapFile<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
|
@ -14,15 +14,16 @@
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <osmium/index/map/mmap_vector_file.hpp>
|
||||
#include <osmium/index/map/dense_file_array.hpp>
|
||||
#include <osmium/index/map/sparse_file_array.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
template <typename TKey, typename TValue>
|
||||
class IndexSearch {
|
||||
|
||||
typedef typename osmium::index::map::DenseMapFile<TKey, TValue> dense_index_type;
|
||||
typedef typename osmium::index::map::SparseMapFile<TKey, TValue> sparse_index_type;
|
||||
typedef typename osmium::index::map::DenseFileArray<TKey, TValue> dense_index_type;
|
||||
typedef typename osmium::index::map::SparseFileArray<TKey, TValue> sparse_index_type;
|
||||
|
||||
int m_fd;
|
||||
bool m_dense_format;
|
||||
@ -186,11 +187,11 @@ public:
|
||||
}
|
||||
|
||||
bool dense_format() const {
|
||||
return vm.count("array");
|
||||
return vm.count("array") != 0;
|
||||
}
|
||||
|
||||
bool do_dump() const {
|
||||
return vm.count("dump");
|
||||
return vm.count("dump") != 0;
|
||||
}
|
||||
|
||||
std::vector<osmium::unsigned_object_id_type> search_keys() const {
|
||||
|
@ -24,27 +24,26 @@
|
||||
#include <osmium/handler/disk_store.hpp>
|
||||
#include <osmium/handler/object_relations.hpp>
|
||||
|
||||
#include <osmium/index/map/stl_vector.hpp>
|
||||
#include <osmium/index/multimap/stl_multimap.hpp>
|
||||
#include <osmium/index/multimap/stl_vector.hpp>
|
||||
#include <osmium/index/map/sparse_mem_array.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_multimap.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_array.hpp>
|
||||
#include <osmium/index/multimap/hybrid.hpp>
|
||||
|
||||
// ==============================================================================
|
||||
// Choose the following depending on the size of the input OSM files:
|
||||
// ==============================================================================
|
||||
// for smaller OSM files (extracts)
|
||||
typedef osmium::index::map::SparseMapMem<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
//typedef osmium::index::map::SparseMapFile<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
|
||||
typedef osmium::index::multimap::SparseMultimapMem<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
|
||||
//typedef osmium::index::multimap::StlMultimap<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
|
||||
typedef osmium::index::multimap::SparseMemArray<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
|
||||
//typedef osmium::index::multimap::SparseMemMultimap<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
|
||||
//typedef osmium::index::multimap::Hybrid<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
|
||||
|
||||
// ==============================================================================
|
||||
// for very large OSM files (planet)
|
||||
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
//typedef osmium::index::map::DenseMapMem map_type;
|
||||
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, size_t> offset_index_type;
|
||||
// ==============================================================================
|
||||
|
||||
void print_help() {
|
||||
|
@ -10,25 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
# include <ogr_api.h>
|
||||
# include <ogrsf_frmts.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// usually you only need one or two of these
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_table.hpp>
|
||||
#include <osmium/index/map/stl_map.hpp>
|
||||
#include <osmium/index/map/mmap_vector_anon.hpp>
|
||||
|
||||
#include <osmium/index/map/all.hpp>
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
@ -37,10 +19,7 @@
|
||||
#include <osmium/handler.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
|
||||
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
@ -181,21 +160,28 @@ void print_help() {
|
||||
<< "If INFILE is not given stdin is assumed.\n" \
|
||||
<< "If OUTFILE is not given 'ogr_out' is used.\n" \
|
||||
<< "\nOptions:\n" \
|
||||
<< " -h, --help This help message\n" \
|
||||
<< " -f, --format=FORMAT Output OGR format (Default: 'SQLite')\n";
|
||||
<< " -h, --help This help message\n" \
|
||||
<< " -l, --location_store=TYPE Set location store\n" \
|
||||
<< " -f, --format=FORMAT Output OGR format (Default: 'SQLite')\n" \
|
||||
<< " -L See available location stores\n";
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"format", required_argument, 0, 'f'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"format", required_argument, 0, 'f'},
|
||||
{"location_store", required_argument, 0, 'l'},
|
||||
{"list_location_stores", no_argument, 0, 'L'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
std::string output_format("SQLite");
|
||||
std::string output_format { "SQLite" };
|
||||
std::string location_store { "sparse_mem_array" };
|
||||
|
||||
while (true) {
|
||||
int c = getopt_long(argc, argv, "hf:", long_options, 0);
|
||||
int c = getopt_long(argc, argv, "hf:l:L", long_options, 0);
|
||||
if (c == -1) {
|
||||
break;
|
||||
}
|
||||
@ -207,6 +193,15 @@ int main(int argc, char* argv[]) {
|
||||
case 'f':
|
||||
output_format = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
location_store = optarg;
|
||||
break;
|
||||
case 'L':
|
||||
std::cout << "Available map types:\n";
|
||||
for (const auto& map_type : map_factory.map_types()) {
|
||||
std::cout << " " << map_type << "\n";
|
||||
}
|
||||
exit(0);
|
||||
default:
|
||||
exit(1);
|
||||
}
|
||||
@ -229,9 +224,9 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
osmium::io::Reader reader(input_filename);
|
||||
|
||||
index_pos_type index_pos;
|
||||
std::unique_ptr<index_pos_type> index_pos = map_factory.create_map(location_store);
|
||||
index_neg_type index_neg;
|
||||
location_handler_type location_handler(index_pos, index_neg);
|
||||
location_handler_type location_handler(*index_pos, index_neg);
|
||||
location_handler.ignore_errors();
|
||||
|
||||
MyOGRHandler ogr_handler(output_format, output_filename);
|
||||
@ -245,7 +240,7 @@ int main(int argc, char* argv[]) {
|
||||
if (locations_fd < 0) {
|
||||
throw std::system_error(errno, std::system_category(), "Open failed");
|
||||
}
|
||||
index_pos.dump_as_list(locations_fd);
|
||||
index_pos->dump_as_list(locations_fd);
|
||||
close(locations_fd);
|
||||
}
|
||||
|
||||
|
@ -13,24 +13,11 @@
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
# include <ogr_api.h>
|
||||
# include <ogrsf_frmts.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// usually you only need one or two of these
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_table.hpp>
|
||||
#include <osmium/index/map/stl_map.hpp>
|
||||
#include <osmium/index/map/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/map/sparse_mem_table.hpp>
|
||||
#include <osmium/index/map/sparse_mem_map.hpp>
|
||||
#include <osmium/index/map/sparse_mmap_array.hpp>
|
||||
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
@ -45,9 +32,9 @@
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
|
||||
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::SparseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
|
@ -15,24 +15,7 @@
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
# include <ogr_api.h>
|
||||
# include <ogrsf_frmts.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// usually you only need one or two of these
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_table.hpp>
|
||||
#include <osmium/index/map/stl_map.hpp>
|
||||
#include <osmium/index/map/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/map/sparse_mem_array.hpp>
|
||||
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
@ -43,13 +26,8 @@
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/experimental/flex_reader.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
|
||||
//typedef osmium::index::map::StlMap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::SparseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
typedef osmium::handler::NodeLocationsForWays<index_type> location_handler_type;
|
||||
|
||||
class MyOGRHandler : public osmium::handler::Handler {
|
||||
|
||||
@ -303,10 +281,9 @@ int main(int argc, char* argv[]) {
|
||||
input_filename = "-";
|
||||
}
|
||||
|
||||
index_pos_type index_pos;
|
||||
index_neg_type index_neg;
|
||||
location_handler_type location_handler(index_pos, index_neg);
|
||||
osmium::experimental::FlexReader<location_handler_type> exr(input_filename, osmium::osm_entity_bits::object);
|
||||
index_type index_pos;
|
||||
location_handler_type location_handler(index_pos);
|
||||
osmium::experimental::FlexReader<location_handler_type> exr(input_filename, location_handler, osmium::osm_entity_bits::object);
|
||||
|
||||
MyOGRHandler ogr_handler(output_format, output_filename);
|
||||
|
||||
|
@ -16,15 +16,15 @@
|
||||
#include <osmium/io/xml_input.hpp>
|
||||
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/map/mmap_vector_file.hpp>
|
||||
#include <osmium/index/map/dense_file_array.hpp>
|
||||
#include <osmium/index/map/dense_mmap_array.hpp>
|
||||
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
//typedef osmium::index::map::DenseMapMmap<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::DenseMapFile<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
//typedef osmium::index::map::DenseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::DenseFileArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
|
@ -44,60 +44,60 @@
|
||||
|
||||
static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
|
||||
return MAP_FAILED;
|
||||
if (fd == -1) {
|
||||
if (!(flags & MAP_ANON) || offset)
|
||||
return MAP_FAILED;
|
||||
} else if (flags & MAP_ANON)
|
||||
return MAP_FAILED;
|
||||
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
|
||||
return MAP_FAILED;
|
||||
if (fd == -1) {
|
||||
if (!(flags & MAP_ANON) || offset)
|
||||
return MAP_FAILED;
|
||||
} else if (flags & MAP_ANON)
|
||||
return MAP_FAILED;
|
||||
|
||||
DWORD flProtect;
|
||||
if (prot & PROT_WRITE) {
|
||||
if (prot & PROT_EXEC)
|
||||
flProtect = PAGE_EXECUTE_READWRITE;
|
||||
else
|
||||
flProtect = PAGE_READWRITE;
|
||||
} else if (prot & PROT_EXEC) {
|
||||
if (prot & PROT_READ)
|
||||
flProtect = PAGE_EXECUTE_READ;
|
||||
else if (prot & PROT_EXEC)
|
||||
flProtect = PAGE_EXECUTE;
|
||||
} else
|
||||
flProtect = PAGE_READONLY;
|
||||
DWORD flProtect;
|
||||
if (prot & PROT_WRITE) {
|
||||
if (prot & PROT_EXEC)
|
||||
flProtect = PAGE_EXECUTE_READWRITE;
|
||||
else
|
||||
flProtect = PAGE_READWRITE;
|
||||
} else if (prot & PROT_EXEC) {
|
||||
if (prot & PROT_READ)
|
||||
flProtect = PAGE_EXECUTE_READ;
|
||||
else if (prot & PROT_EXEC)
|
||||
flProtect = PAGE_EXECUTE;
|
||||
} else
|
||||
flProtect = PAGE_READONLY;
|
||||
|
||||
off_t end = length + offset;
|
||||
HANDLE mmap_fd, h;
|
||||
if (fd == -1)
|
||||
mmap_fd = INVALID_HANDLE_VALUE;
|
||||
else
|
||||
mmap_fd = (HANDLE)_get_osfhandle(fd);
|
||||
h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
|
||||
if (h == NULL)
|
||||
return MAP_FAILED;
|
||||
off_t end = length + offset;
|
||||
HANDLE mmap_fd, h;
|
||||
if (fd == -1)
|
||||
mmap_fd = INVALID_HANDLE_VALUE;
|
||||
else
|
||||
mmap_fd = (HANDLE)_get_osfhandle(fd);
|
||||
h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
|
||||
if (h == NULL)
|
||||
return MAP_FAILED;
|
||||
|
||||
DWORD dwDesiredAccess;
|
||||
if (prot & PROT_WRITE)
|
||||
dwDesiredAccess = FILE_MAP_WRITE;
|
||||
else
|
||||
dwDesiredAccess = FILE_MAP_READ;
|
||||
if (prot & PROT_EXEC)
|
||||
dwDesiredAccess |= FILE_MAP_EXECUTE;
|
||||
if (flags & MAP_PRIVATE)
|
||||
dwDesiredAccess |= FILE_MAP_COPY;
|
||||
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
|
||||
if (ret == NULL) {
|
||||
CloseHandle(h);
|
||||
ret = MAP_FAILED;
|
||||
}
|
||||
return ret;
|
||||
DWORD dwDesiredAccess;
|
||||
if (prot & PROT_WRITE)
|
||||
dwDesiredAccess = FILE_MAP_WRITE;
|
||||
else
|
||||
dwDesiredAccess = FILE_MAP_READ;
|
||||
if (prot & PROT_EXEC)
|
||||
dwDesiredAccess |= FILE_MAP_EXECUTE;
|
||||
if (flags & MAP_PRIVATE)
|
||||
dwDesiredAccess |= FILE_MAP_COPY;
|
||||
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
|
||||
if (ret == NULL) {
|
||||
CloseHandle(h);
|
||||
ret = MAP_FAILED;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int munmap(void *addr, size_t length)
|
||||
{
|
||||
UnmapViewOfFile(addr);
|
||||
return 0;
|
||||
/* ruh-ro, we leaked handle from CreateFileMapping() ... */
|
||||
UnmapViewOfFile(addr);
|
||||
return 0;
|
||||
/* ruh-ro, we leaked handle from CreateFileMapping() ... */
|
||||
}
|
||||
|
||||
#undef DWORD_HI
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,18 +33,38 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains code for reporting problems through OGR when
|
||||
* assembling multipolygons.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with `libgdal`.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4458)
|
||||
#else
|
||||
# pragma GCC diagnostic push
|
||||
# ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
# endif
|
||||
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
# pragma GCC diagnostic ignored "-Wpadded"
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
|
||||
#include <ogr_api.h>
|
||||
#include <ogrsf_frmts.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#else
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
# include <ogr_api.h>
|
||||
# include <ogrsf_frmts.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -37,7 +37,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -36,6 +36,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/builder/builder.hpp>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -41,7 +41,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
* @short Experimental code that is not "officially" supported.
|
||||
* @brief Experimental code that is not "officially" supported.
|
||||
*/
|
||||
namespace experimental {
|
||||
|
||||
@ -51,9 +51,7 @@ namespace osmium {
|
||||
bool m_with_areas;
|
||||
osmium::osm_entity_bits::type m_entities;
|
||||
|
||||
typename TLocationHandler::index_pos_type m_index_pos;
|
||||
typename TLocationHandler::index_neg_type m_index_neg;
|
||||
TLocationHandler m_location_handler;
|
||||
TLocationHandler& m_location_handler;
|
||||
|
||||
osmium::io::Reader m_reader;
|
||||
osmium::area::Assembler::config_type m_assembler_config;
|
||||
@ -61,12 +59,10 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
explicit FlexReader(const osmium::io::File& file, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
m_with_areas(entities & osmium::osm_entity_bits::area),
|
||||
explicit FlexReader(const osmium::io::File& file, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
m_with_areas((entities & osmium::osm_entity_bits::area) != 0),
|
||||
m_entities((entities & ~osmium::osm_entity_bits::area) | (m_with_areas ? osmium::osm_entity_bits::node | osmium::osm_entity_bits::way : osmium::osm_entity_bits::nothing)),
|
||||
m_index_pos(),
|
||||
m_index_neg(),
|
||||
m_location_handler(m_index_pos, m_index_neg),
|
||||
m_location_handler(location_handler),
|
||||
m_reader(file, m_entities),
|
||||
m_assembler_config(),
|
||||
m_collector(m_assembler_config)
|
||||
@ -79,21 +75,20 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
explicit FlexReader(const std::string& filename, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
FlexReader(osmium::io::File(filename), entities) {
|
||||
explicit FlexReader(const std::string& filename, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
FlexReader(osmium::io::File(filename), location_handler, entities) {
|
||||
}
|
||||
|
||||
explicit FlexReader(const char* filename, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
FlexReader(osmium::io::File(filename), entities) {
|
||||
explicit FlexReader(const char* filename, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
|
||||
FlexReader(osmium::io::File(filename), location_handler, entities) {
|
||||
}
|
||||
|
||||
osmium::memory::Buffer read() {
|
||||
std::vector<osmium::memory::Buffer> area_buffers;
|
||||
|
||||
osmium::memory::Buffer buffer = m_reader.read();
|
||||
|
||||
if (buffer) {
|
||||
if (m_with_areas) {
|
||||
std::vector<osmium::memory::Buffer> area_buffers;
|
||||
osmium::apply(buffer, m_location_handler, m_collector.handler([&area_buffers](osmium::memory::Buffer&& area_buffer) {
|
||||
area_buffers.push_back(std::move(area_buffer));
|
||||
}));
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 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.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains code for conversion of OSM geometries into GDAL
|
||||
* geometries.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with `libgeos`.
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <geos/geom/Coordinate.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,19 +33,49 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains code for conversion of OSM geometries into OGR
|
||||
* geometries.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with `libgdal`.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4458)
|
||||
# pragma warning(disable : 4251)
|
||||
#else
|
||||
# pragma GCC diagnostic push
|
||||
# ifdef __clang__
|
||||
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
# endif
|
||||
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
# pragma GCC diagnostic ignored "-Wpadded"
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
|
||||
/* Strictly speaking the following include would be enough here,
|
||||
but everybody using this file will very likely need the other includes,
|
||||
so we are adding them here, so that not everybody will need all those
|
||||
pragmas to disable warnings. */
|
||||
//#include <ogr_geometry.h>
|
||||
#include <ogr_api.h>
|
||||
#include <ogrsf_frmts.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#else
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
# include <ogr_geometry.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 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.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains code for projecting OSM locations to arbitrary
|
||||
* coordinate reference systems. It is based on the Proj.4 library.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with `libproj`.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@ -77,11 +86,11 @@ namespace osmium {
|
||||
}
|
||||
|
||||
bool is_latlong() const {
|
||||
return pj_is_latlong(m_crs.get());
|
||||
return pj_is_latlong(m_crs.get()) != 0;
|
||||
}
|
||||
|
||||
bool is_geocent() const {
|
||||
return pj_is_geocent(m_crs.get());
|
||||
return pj_is_geocent(m_crs.get()) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -44,6 +44,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <osmium/index/node_locations_map.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace handler {
|
||||
@ -102,6 +104,9 @@ namespace osmium {
|
||||
NodeLocationsForWays(const NodeLocationsForWays&) = delete;
|
||||
NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete;
|
||||
|
||||
NodeLocationsForWays(NodeLocationsForWays&&) = default;
|
||||
NodeLocationsForWays& operator=(NodeLocationsForWays&&) = default;
|
||||
|
||||
~NodeLocationsForWays() noexcept = default;
|
||||
|
||||
void ignore_errors() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
73
include/osmium/index/detail/create_map_with_fd.hpp
Normal file
73
include/osmium/index/detail/create_map_with_fd.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class T>
|
||||
inline T* create_map_with_fd(const std::vector<std::string>& config) {
|
||||
if (config.size() == 1) {
|
||||
return new T();
|
||||
} else {
|
||||
assert(config.size() > 1);
|
||||
const std::string& filename = config[1];
|
||||
int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644);
|
||||
if (fd == -1) {
|
||||
throw std::runtime_error(std::string("can't open file '") + filename + "': " + strerror(errno));
|
||||
}
|
||||
return new T(fd);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_DETAIL_CREATE_MAP_WITH_FD_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
#define OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -45,8 +45,8 @@ namespace osmium {
|
||||
namespace detail {
|
||||
|
||||
/**
|
||||
* This class looks and behaves like STL vector, but uses mmap internally.
|
||||
*/
|
||||
* This class looks and behaves like STL vector, but uses mmap internally.
|
||||
*/
|
||||
template <typename T>
|
||||
class mmap_vector_anon : public mmap_vector_base<T, mmap_vector_anon> {
|
||||
|
||||
@ -75,4 +75,4 @@ namespace osmium {
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
#endif // OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
#define OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <stdexcept>
|
||||
|
||||
#include <osmium/index/detail/typed_mmap.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -180,4 +181,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
#define OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -82,4 +82,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_DETAIL_TMPFILE_HPP
|
||||
#define OSMIUM_DETAIL_TMPFILE_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_TMPFILE_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_TMPFILE_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -59,4 +59,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_DETAIL_TMPFILE
|
||||
#endif // OSMIUM_INDEX_DETAIL_TMPFILE_HPP
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_DETAIL_TYPED_MMAP_HPP
|
||||
#define OSMIUM_DETAIL_TYPED_MMAP_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -226,4 +226,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_DETAIL_TYPED_MMAP_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_VECTOR_HPP
|
||||
#define OSMIUM_INDEX_MAP_VECTOR_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
@ -198,7 +199,7 @@ namespace osmium {
|
||||
std::sort(m_vector.begin(), m_vector.end());
|
||||
}
|
||||
|
||||
void dump_as_list(int fd) const override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
|
||||
}
|
||||
|
||||
@ -234,4 +235,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_VECTOR_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_VECTOR_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_VECTOR_HPP
|
||||
#ifndef OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP
|
||||
#define OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -37,6 +37,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
@ -136,7 +137,7 @@ namespace osmium {
|
||||
);
|
||||
}
|
||||
|
||||
void dump_as_list(int fd) const override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
|
||||
}
|
||||
|
||||
@ -148,4 +149,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_VECTOR_HPP
|
||||
#endif // OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,10 +33,18 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/index.hpp> // IWYU pragma: export
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
#include <osmium/util/string.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -140,7 +148,7 @@ namespace osmium {
|
||||
// default implementation is empty
|
||||
}
|
||||
|
||||
virtual void dump_as_list(int /*fd*/) const {
|
||||
virtual void dump_as_list(const int /*fd*/) {
|
||||
std::runtime_error("can't dump as list");
|
||||
}
|
||||
|
||||
@ -148,6 +156,98 @@ namespace osmium {
|
||||
|
||||
} // namespace map
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
class MapFactory {
|
||||
|
||||
public:
|
||||
|
||||
typedef TId id_type;
|
||||
typedef TValue value_type;
|
||||
typedef osmium::index::map::Map<id_type, value_type> map_type;
|
||||
typedef std::function<map_type*(const std::vector<std::string>&)> create_map_func;
|
||||
|
||||
private:
|
||||
|
||||
std::map<const std::string, create_map_func> m_callbacks;
|
||||
|
||||
MapFactory() = default;
|
||||
|
||||
MapFactory(const MapFactory&) = delete;
|
||||
MapFactory& operator=(const MapFactory&) = delete;
|
||||
|
||||
MapFactory(MapFactory&&) = delete;
|
||||
MapFactory& operator=(MapFactory&&) = delete;
|
||||
|
||||
OSMIUM_NORETURN static void error(const std::string& map_type_name) {
|
||||
std::string error_message {"Support for map type '"};
|
||||
error_message += map_type_name;
|
||||
error_message += "' not compiled into this binary.";
|
||||
throw std::runtime_error(error_message);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static MapFactory<id_type, value_type>& instance() {
|
||||
static MapFactory<id_type, value_type> factory;
|
||||
return factory;
|
||||
}
|
||||
|
||||
bool register_map(const std::string& map_type_name, create_map_func func) {
|
||||
return m_callbacks.emplace(map_type_name, func).second;
|
||||
}
|
||||
|
||||
std::vector<std::string> map_types() const {
|
||||
std::vector<std::string> result;
|
||||
|
||||
for (const auto& cb : m_callbacks) {
|
||||
result.push_back(cb.first);
|
||||
}
|
||||
|
||||
std::sort(result.begin(), result.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<map_type> create_map(const std::string& config_string) const {
|
||||
std::vector<std::string> config = osmium::split_string(config_string, ',');
|
||||
|
||||
if (config.empty()) {
|
||||
throw std::runtime_error("Need non-empty map type name.");
|
||||
}
|
||||
|
||||
auto it = m_callbacks.find(config[0]);
|
||||
if (it != m_callbacks.end()) {
|
||||
return std::unique_ptr<map_type>((it->second)(config));
|
||||
}
|
||||
|
||||
error(config[0]);
|
||||
}
|
||||
|
||||
}; // class MapFactory
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue, template<typename, typename> class TMap>
|
||||
struct create_map {
|
||||
TMap<TId, TValue>* operator()(const std::vector<std::string>&) {
|
||||
return new TMap<TId, TValue>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
#define REGISTER_MAP(id, value, klass, name) \
|
||||
namespace { \
|
||||
const bool registered_index_map_##name = osmium::index::register_map<id, value, klass>(#name); \
|
||||
}
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
46
include/osmium/index/map/all.hpp
Normal file
46
include/osmium/index/map/all.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_ALL_HPP
|
||||
#define OSMIUM_INDEX_MAP_ALL_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/map/dense_file_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/dense_mem_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/dense_mmap_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/dummy.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/sparse_file_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/sparse_mem_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/sparse_mem_map.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/sparse_mem_table.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/map/sparse_mmap_array.hpp> // IWYU pragma: keep
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_ALL_HPP
|
67
include/osmium/index/map/dense_file_array.hpp
Normal file
67
include/osmium/index/map/dense_file_array.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using DenseFileArray = VectorBasedDenseMap<osmium::detail::mmap_vector_file<TValue>, TId, TValue>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
struct create_map<TId, TValue, DenseFileArray> {
|
||||
DenseFileArray<TId, TValue>* operator()(const std::vector<std::string>& config) {
|
||||
return osmium::index::detail::create_map_with_fd<DenseFileArray<TId, TValue>>(config);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_DENSE_FILE_ARRAY_HPP
|
57
include/osmium/index/map/dense_mem_array.hpp
Normal file
57
include/osmium/index/map/dense_mem_array.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using DenseMemArray = VectorBasedDenseMap<std::vector<TValue>, TId, TValue>;
|
||||
|
||||
} // namespace map
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_DENSE_MEM_ARRAY_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
|
||||
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
|
||||
#ifndef OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -35,8 +35,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <osmium/index/map/vector.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_DENSE_MMAP_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -45,10 +47,7 @@ namespace osmium {
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using DenseMapMmap = VectorBasedDenseMap<osmium::detail::mmap_vector_anon<TValue>, TId, TValue>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMapMmap = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_anon>;
|
||||
using DenseMmapArray = VectorBasedDenseMap<osmium::detail::mmap_vector_anon<TValue>, TId, TValue>;
|
||||
|
||||
} // namespace map
|
||||
|
||||
@ -58,4 +57,4 @@ namespace osmium {
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP
|
||||
#endif // OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -35,6 +35,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
67
include/osmium/index/map/sparse_file_array.hpp
Normal file
67
include/osmium/index/map/sparse_file_array.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_FILE_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseFileArray = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_file>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
struct create_map<TId, TValue, SparseFileArray> {
|
||||
SparseFileArray<TId, TValue>* operator()(const std::vector<std::string>& config) {
|
||||
return osmium::index::detail::create_map_with_fd<SparseFileArray<TId, TValue>>(config);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_SPARSE_FILE_ARRAY_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_STL_VECTOR_HPP
|
||||
#define OSMIUM_INDEX_MAP_STL_VECTOR_HPP
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -35,7 +35,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/map/vector.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -43,14 +45,11 @@ namespace osmium {
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using DenseMapMem = VectorBasedDenseMap<std::vector<TValue>, TId, TValue>;
|
||||
|
||||
template <typename T>
|
||||
using StdVectorWrap = std::vector<T>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMapMem = VectorBasedSparseMap<TId, TValue, StdVectorWrap>;
|
||||
using SparseMemArray = VectorBasedSparseMap<TId, TValue, StdVectorWrap>;
|
||||
|
||||
} // namespace map
|
||||
|
||||
@ -58,4 +57,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_STL_VECTOR_HPP
|
||||
#endif // OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_STL_MAP_HPP
|
||||
#define OSMIUM_INDEX_MAP_STL_MAP_HPP
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -41,8 +41,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@ -54,7 +57,7 @@ namespace osmium {
|
||||
* lot of memory, but might make sense for small maps.
|
||||
*/
|
||||
template <typename TId, typename TValue>
|
||||
class StlMap : public osmium::index::map::Map<TId, TValue> {
|
||||
class SparseMemMap : public osmium::index::map::Map<TId, TValue> {
|
||||
|
||||
// This is a rough estimate for the memory needed for each
|
||||
// element in the map (id + value + pointers to left, right,
|
||||
@ -66,9 +69,9 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
StlMap() = default;
|
||||
SparseMemMap() = default;
|
||||
|
||||
~StlMap() override final = default;
|
||||
~SparseMemMap() override final = default;
|
||||
|
||||
void set(const TId id, const TValue value) override final {
|
||||
m_elements[id] = value;
|
||||
@ -94,14 +97,14 @@ namespace osmium {
|
||||
m_elements.clear();
|
||||
}
|
||||
|
||||
void dump_as_list(const int fd) const override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
typedef typename std::map<TId, TValue>::value_type t;
|
||||
std::vector<t> v;
|
||||
std::copy(m_elements.begin(), m_elements.end(), std::back_inserter(v));
|
||||
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(t) * v.size());
|
||||
}
|
||||
|
||||
}; // class StlMap
|
||||
}; // class SparseMemMap
|
||||
|
||||
} // namespace map
|
||||
|
||||
@ -109,4 +112,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_STL_MAP_HPP
|
||||
#endif // OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -34,15 +34,17 @@ DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <google/sparsetable>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@ -50,9 +52,9 @@ namespace osmium {
|
||||
namespace map {
|
||||
|
||||
/**
|
||||
* The SparseTable index stores elements in a Google sparsetable,
|
||||
* The SparseMemTable index stores elements in a Google sparsetable,
|
||||
* a data structure that can hold sparsly filled tables in a
|
||||
* very space efficient way. It will resize automatically.
|
||||
* space efficient way. It will resize automatically.
|
||||
*
|
||||
* Use this index if the ID space is only sparsly
|
||||
* populated, such as when working with smaller OSM files (like
|
||||
@ -61,7 +63,7 @@ namespace osmium {
|
||||
* This will only work on 64 bit machines.
|
||||
*/
|
||||
template <typename TId, typename TValue>
|
||||
class SparseTable : public osmium::index::map::Map<TId, TValue> {
|
||||
class SparseMemTable : public osmium::index::map::Map<TId, TValue> {
|
||||
|
||||
TId m_grow_size;
|
||||
|
||||
@ -79,12 +81,12 @@ namespace osmium {
|
||||
* The storage will grow by at least this size
|
||||
* every time it runs out of space.
|
||||
*/
|
||||
explicit SparseTable(const TId grow_size=10000) :
|
||||
explicit SparseMemTable(const TId grow_size=10000) :
|
||||
m_grow_size(grow_size),
|
||||
m_elements(grow_size) {
|
||||
}
|
||||
|
||||
~SparseTable() override final = default;
|
||||
~SparseMemTable() override final = default;
|
||||
|
||||
void set(const TId id, const TValue value) override final {
|
||||
if (id >= m_elements.size()) {
|
||||
@ -117,7 +119,7 @@ namespace osmium {
|
||||
m_elements.clear();
|
||||
}
|
||||
|
||||
void dump_as_list(const int fd) const override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
std::vector<std::pair<TId, TValue>> v;
|
||||
int n=0;
|
||||
for (const TValue value : m_elements) {
|
||||
@ -129,7 +131,7 @@ namespace osmium {
|
||||
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(std::pair<TId, TValue>) * v.size());
|
||||
}
|
||||
|
||||
}; // class SparseTable
|
||||
}; // class SparseMemTable
|
||||
|
||||
} // namespace map
|
||||
|
||||
@ -137,4 +139,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_BYID_SPARSE_TABLE_HPP
|
||||
#endif // OSMIUM_INDEX_BYID_SPARSE_MEM_TABLE_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
|
||||
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
|
||||
#ifndef OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,8 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/map/vector.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#ifdef __linux__
|
||||
|
||||
#include <osmium/index/detail/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MMAP_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -43,10 +47,7 @@ namespace osmium {
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using DenseMapFile = VectorBasedDenseMap<osmium::detail::mmap_vector_file<TValue>, TId, TValue>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMapFile = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_file>;
|
||||
using SparseMmapArray = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_anon>;
|
||||
|
||||
} // namespace map
|
||||
|
||||
@ -54,4 +55,6 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP
|
||||
#endif // __linux__
|
||||
|
||||
#endif // OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -34,11 +34,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp> // IWYU pragma: export
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@ -114,7 +113,7 @@ namespace osmium {
|
||||
// default implementation is empty
|
||||
}
|
||||
|
||||
virtual void dump_as_list(int /*fd*/) const {
|
||||
virtual void dump_as_list(const int /*fd*/) {
|
||||
std::runtime_error("can't dump as list");
|
||||
}
|
||||
|
||||
|
41
include/osmium/index/multimap/all.hpp
Normal file
41
include/osmium/index/multimap/all.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_ALL_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_ALL_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/multimap/sparse_file_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/multimap/sparse_mem_array.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/multimap/sparse_mem_multimap.hpp> // IWYU pragma: keep
|
||||
#include <osmium/index/multimap/sparse_mmap_array.hpp> // IWYU pragma: keep
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_ALL_HPP
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -36,9 +36,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/index/multimap/stl_vector.hpp>
|
||||
#include <osmium/index/multimap/stl_multimap.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_array.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_multimap.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -49,8 +50,8 @@ namespace osmium {
|
||||
template <typename TId, typename TValue>
|
||||
class HybridIterator {
|
||||
|
||||
typedef SparseMultimapMem<TId, TValue> main_map_type;
|
||||
typedef StlMultimap<TId, TValue> extra_map_type;
|
||||
typedef SparseMemArray<TId, TValue> main_map_type;
|
||||
typedef SparseMemMultimap<TId, TValue> extra_map_type;
|
||||
|
||||
typedef typename std::pair<TId, TValue> element_type;
|
||||
|
||||
@ -117,8 +118,8 @@ namespace osmium {
|
||||
template <typename TId, typename TValue>
|
||||
class Hybrid : public Multimap<TId, TValue> {
|
||||
|
||||
typedef SparseMultimapMem<TId, TValue> main_map_type;
|
||||
typedef StlMultimap<TId, TValue> extra_map_type;
|
||||
typedef SparseMemArray<TId, TValue> main_map_type;
|
||||
typedef SparseMemMultimap<TId, TValue> extra_map_type;
|
||||
|
||||
main_map_type m_main;
|
||||
extra_map_type m_extra;
|
||||
@ -174,7 +175,7 @@ namespace osmium {
|
||||
m_main.sort();
|
||||
}
|
||||
|
||||
void dump_as_list(int fd) override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
consolidate();
|
||||
m_main.dump_as_list(fd);
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,8 +33,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/multimap/vector.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#include <osmium/index/detail/vector_multimap.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -43,7 +43,7 @@ namespace osmium {
|
||||
namespace multimap {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMultimapFile = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_file>;
|
||||
using SparseFileArray = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_file>;
|
||||
|
||||
} // namespace multimap
|
||||
|
||||
@ -51,4 +51,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/multimap/vector.hpp>
|
||||
#include <osmium/index/detail/vector_multimap.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -47,7 +47,7 @@ namespace osmium {
|
||||
using StdVectorWrap = std::vector<T>;
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMultimapMem = VectorBasedSparseMultimap<TId, TValue, StdVectorWrap>;
|
||||
using SparseMemArray = VectorBasedSparseMultimap<TId, TValue, StdVectorWrap>;
|
||||
|
||||
} // namespace multimap
|
||||
|
||||
@ -55,4 +55,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -53,7 +53,7 @@ namespace osmium {
|
||||
* lot of memory, but might make sense for small maps.
|
||||
*/
|
||||
template <typename TId, typename TValue>
|
||||
class StlMultimap : public osmium::index::multimap::Multimap<TId, TValue> {
|
||||
class SparseMemMultimap : public osmium::index::multimap::Multimap<TId, TValue> {
|
||||
|
||||
// This is a rough estimate for the memory needed for each
|
||||
// element in the map (id + value + pointers to left, right,
|
||||
@ -76,9 +76,9 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
StlMultimap() = default;
|
||||
SparseMemMultimap() = default;
|
||||
|
||||
~StlMultimap() noexcept override final = default;
|
||||
~SparseMemMultimap() noexcept override final = default;
|
||||
|
||||
void unsorted_set(const TId id, const TValue value) {
|
||||
m_elements.emplace(id, value);
|
||||
@ -130,7 +130,7 @@ namespace osmium {
|
||||
// intentionally left blank
|
||||
}
|
||||
|
||||
void dump_as_list(const int fd) const override final {
|
||||
void dump_as_list(const int fd) override final {
|
||||
std::vector<element_type> v;
|
||||
for (const auto& element : m_elements) {
|
||||
v.emplace_back(element.first, element.second);
|
||||
@ -140,7 +140,7 @@ namespace osmium {
|
||||
osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(element_type) * v.size());
|
||||
}
|
||||
|
||||
}; // class StlMultimap
|
||||
}; // class SparseMemMultimap
|
||||
|
||||
} // namespace multimap
|
||||
|
||||
@ -148,4 +148,4 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
|
@ -1,11 +1,11 @@
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
|
||||
#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP
|
||||
#define OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 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.
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <osmium/index/multimap/vector.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_anon.hpp>
|
||||
#include <osmium/index/detail/vector_multimap.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@ -45,7 +45,7 @@ namespace osmium {
|
||||
namespace multimap {
|
||||
|
||||
template <typename TId, typename TValue>
|
||||
using SparseMultimapMmap = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_anon>;
|
||||
using SparseMmapArray = VectorBasedSparseMultimap<TId, TValue, osmium::detail::mmap_vector_anon>;
|
||||
|
||||
} // namespace multimap
|
||||
|
||||
@ -55,4 +55,4 @@ namespace osmium {
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP
|
||||
#endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP
|
70
include/osmium/index/node_locations_map.hpp
Normal file
70
include/osmium/index/node_locations_map.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP
|
||||
#define OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/map.hpp> // IWYU pragma: keep
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseFileArray, dense_file_array)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseMemArray, dense_mem_array)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_DENSE_MMAP_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::DenseMmapArray, dense_mmap_array)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_FILE_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseFileArray, sparse_file_array)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemArray, sparse_mem_array)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemMap, sparse_mem_map)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemTable, sparse_mem_table)
|
||||
#endif
|
||||
|
||||
#ifdef OSMIUM_HAS_INDEX_MAP_SPARSE_MMAP_ARRAY
|
||||
REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMmapArray, sparse_mmap_array)
|
||||
#endif
|
||||
|
||||
#endif // OSMIUM_INDEX_NODE_LOCATIONS_MAP_HPP
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 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.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Include this file if you want to read or write compressed OSM XML files.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with `libz`
|
||||
* and `libbz2`.
|
||||
*/
|
||||
|
||||
#include <osmium/io/bzip2_compression.hpp> // IWYU pragma: export
|
||||
#include <osmium/io/gzip_compression.hpp> // IWYU pragma: export
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Include this file if you want to read all kinds of OSM files.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with
|
||||
* `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only),
|
||||
* `libexpat`, `libz`, `libbz2`, and enable multithreading.
|
||||
*/
|
||||
|
||||
#include <osmium/io/any_compression.hpp> // IWYU pragma: export
|
||||
|
||||
#include <osmium/io/pbf_input.hpp> // IWYU pragma: export
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013,2014 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2015 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@ -33,6 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Include this file if you want to write all kinds of OSM files.
|
||||
*
|
||||
* @attention If you include this file, you'll need to link with
|
||||
* `libprotobuf-lite`, `libosmpbf`, `ws2_32` (Windows only),
|
||||
* `libz`, `libbz2`, and enable multithreading.
|
||||
*/
|
||||
|
||||
#include <osmium/io/any_compression.hpp> // IWYU pragma: export
|
||||
|
||||
#include <osmium/io/opl_output.hpp> // IWYU pragma: export
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user