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:
Dennis Luxen 2015-02-05 15:13:48 +01:00
parent 73efcc6b0c
commit bb78bc8fe3
215 changed files with 2699 additions and 1297 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
core core
*.swp *.swp
build* build*
.ycm_extra_conf.pyc

View File

@ -1,9 +1,19 @@
#-----------------------------------------------------------------------------
#
# Configuration for continuous integration service at travis-ci.org
#
#-----------------------------------------------------------------------------
language: cpp language: cpp
compiler: compiler:
- gcc - gcc
- clang - clang
env:
- CONFIGURATION=Dev
- CONFIGURATION=Release
before_install: before_install:
# we need at least g++-4.8 for c++11 features # we need at least g++-4.8 for c++11 features
- sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
@ -16,8 +26,8 @@ install:
- sudo rm /usr/bin/cpp - sudo rm /usr/bin/cpp
- sudo ln -s /usr/bin/cpp-4.8 /usr/bin/cpp - sudo ln -s /usr/bin/cpp-4.8 /usr/bin/cpp
# upgrade libosmium dependencies # 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 libboost-dev libboost-program-options-dev libsparsehash-dev libprotobuf-dev protobuf-compiler libgeos++-dev libproj-dev libgdal1h libgdal-dev
- sudo apt-get install --yes make libgdal1h libgdal-dev - git clone https://github.com/osmcode/osm-testdata.git
# OSMPBF is too old, install from git # OSMPBF is too old, install from git
#- sudo apt-get install --yes libosmpbf-dev #- sudo apt-get install --yes libosmpbf-dev
- git clone https://github.com/scrosby/OSM-binary.git - git clone https://github.com/scrosby/OSM-binary.git
@ -26,8 +36,6 @@ install:
- sudo make install - sudo make install
- cd ../.. - cd ../..
#env:
before_script: before_script:
- true - true
@ -35,7 +43,7 @@ script:
- if [ "${CXX}" = 'g++' ]; then export CXX=g++-4.8; fi; - if [ "${CXX}" = 'g++' ]; then export CXX=g++-4.8; fi;
- mkdir build - mkdir build
- cd build - cd build
- cmake -L -DCMAKE_BUILD_TYPE=Dev .. - cmake -LA -DCMAKE_BUILD_TYPE=${CONFIGURATION} ..
- make VERBOSE=1 - make VERBOSE=1
# Disable multipolygon test because it needs ruby and the 'json' gem, but the # 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. # travis ruby installation doesn't find the gem it did install itself.

44
.ycm_extra_conf.py Normal file
View 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
}

View File

@ -1,18 +1,20 @@
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
# Libosmium CMakeLists.txt # CMake Config
# #
#---------------------------------------------------------------------- # Libosmium
#
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
# Project version # Project version
# #
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
project(libosmium) project(libosmium)
@ -20,85 +22,103 @@ set(LIBOSMIUM_VERSION_MAJOR 0)
set(LIBOSMIUM_VERSION_MINOR 0) set(LIBOSMIUM_VERSION_MINOR 0)
set(LIBOSMIUM_VERSION_PATCH 1) 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 # Build options
# #
# (Change with -DOPTION=VALUE on cmake command line.) # (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") if(CMAKE_BUILD_TYPE STREQUAL "Dev")
option(BUILD_HEADERS "compile every header file on its own" ON) set(dev_build ON)
else() else()
option(BUILD_HEADERS "compile every header file on its own" OFF) set(dev_build OFF)
endif() 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 # Find external dependencies
# #
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
# check that the essential libraries were found find_package(Boost 1.38)
if(BUILD_EXAMPLES OR BUILD_TESTING OR BUILD_UNIT_TESTS OR BUILD_DATA_TESTS OR BUILD_HEADERS) mark_as_advanced(CLEAR BOOST_ROOT)
find_package(Boost 1.38) if(Boost_FOUND)
mark_as_advanced(CLEAR BOOST_ROOT) include_directories(${Boost_INCLUDE_DIRS})
else()
if(Boost_FOUND) set(BOOST_ROOT "NOT FOUND: please choose" CACHE PATH "")
include_directories(${Boost_INCLUDE_DIRS}) message(FATAL_ERROR "PLEASE, specify the directory where the Boost library is installed in BOOST_ROOT")
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)
endif() 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). # Decide which C++ version to use (Minimum/default: C++11).
# #
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
if(NOT MSVC)
if(NOT USE_CPP_VERSION) if(NOT USE_CPP_VERSION)
set(USE_CPP_VERSION c++11) 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() 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." CACHE STRING "Flags used by the compiler during developer builds."
FORCE) FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEV "" set(CMAKE_EXE_LINKER_FLAGS_DEV ""
CACHE STRING "Flags used by the linker during developer builds." CACHE STRING "Flags used by the linker during developer builds."
FORCE) FORCE)
@ -107,61 +127,76 @@ mark_as_advanced(
CMAKE_EXE_LINKER_FLAGS_DEV 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." CACHE STRING "Flags used by the compiler during RELWITHDEBINFO builds."
FORCE) FORCE)
#-----------------------------------------------------------------------------
#
# Build Type
#
#-----------------------------------------------------------------------------
set(CMAKE_CONFIGURATION_TYPES "Debug Release RelWithDebInfo MinSizeRel Dev") 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 # Force RelWithDebInfo build type if none was given
if (CMAKE_BUILD_TYPE STREQUAL "") if(CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}." FORCE) set(build_type ${CMAKE_BUILD_TYPE})
else() 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() endif()
set(CMAKE_BUILD_TYPE ${build_type}
#---------------------------------------------------------------------- CACHE STRING
"Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}."
if(WIN32) FORCE)
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 up testing # Unit and data tests
# #
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
enable_testing() enable_testing()
find_program(MEMORYCHECK_COMMAND valgrind) if(BUILD_TESTING OR BUILD_DATA_TESTS)
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full --show-reachable=yes --error-exitcode=1") find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.supp")
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) add_subdirectory(test)
endif() endif()
if(BUILD_DATA_TESTS OR BUILD_TESTING) if(BUILD_DATA_TESTS)
add_subdirectory(test/osm-testdata) add_subdirectory(test/data-tests)
endif() endif()
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
# Optional "cppcheck" target that checks C++ code # Optional "cppcheck" target that checks C++ code
# #
#---------------------------------------------------------------------- #-----------------------------------------------------------------------------
message(STATUS "Looking for cppcheck") message(STATUS "Looking for cppcheck")
find_program(CPPCHECK cppcheck) find_program(CPPCHECK cppcheck)
if(CPPCHECK) if(CPPCHECK)
message(STATUS "Looking for cppcheck - found") 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 # cpp doesn't find system includes for some reason, suppress that report
set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem) set(CPPCHECK_OPTIONS ${CPPCHECK_OPTIONS} --suppress=missingIncludeSystem)
@ -169,7 +204,7 @@ if(CPPCHECK)
file(GLOB_RECURSE ALL_INCLUDES include/osmium/*.hpp) file(GLOB_RECURSE ALL_INCLUDES include/osmium/*.hpp)
file(GLOB ALL_EXAMPLES examples/*.cpp) file(GLOB ALL_EXAMPLES examples/*.cpp)
file(GLOB ALL_UNIT_TESTS test/t/*/test_*.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) if(Osmium_DEBUG)
message(STATUS "Checking includes : ${ALL_INCLUDES}") message(STATUS "Checking includes : ${ALL_INCLUDES}")
@ -178,7 +213,11 @@ if(CPPCHECK)
message(STATUS "Checking data test code: ${ALL_DATA_TESTS}") message(STATUS "Checking data test code: ${ALL_DATA_TESTS}")
endif() 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 add_custom_target(cppcheck
${CPPCHECK} ${CPPCHECK}
@ -188,48 +227,42 @@ if(CPPCHECK)
) )
else() else()
message(STATUS "Looking for cppcheck - not found") 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) 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) if(BUILD_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()
#---------------------------------------------------------------------- if(BUILD_BENCHMARKS)
# This will try to compile include files on their own to detect missing add_subdirectory(benchmarks)
# include directives and other dependency-related problems. Note that if this endif()
# 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)
# In 'Dev' mode: compile with very strict warnings and turn them into errors. add_subdirectory(doc)
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
add_definitions(-Werror ${OSMIUM_WARNING_OPTIONS})
endif() #-----------------------------------------------------------------------------
#
# 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) 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, # There is no way in CMake to just compile but not link a C++ file,
# so we pretend to build a library here. # 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() endforeach()
endif() endif()
@ -254,6 +299,38 @@ install(DIRECTORY include/osmium DESTINATION include)
# don't have it. We probably don't want to install it. # don't have it. We probably don't want to install it.
#install(FILES include/boost_unicode_iterator.hpp DESTINATION include) #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) 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()
#-----------------------------------------------------------------------------

View File

@ -11,11 +11,11 @@ clean:
distclean: distclean:
rm -fr build rm -fr build
deb: #deb:
debuild -I -us -uc # debuild -I -us -uc
#
deb-clean: #deb-clean:
debuild clean # debuild clean
indent: indent:
astyle --style=java --indent-namespaces --indent-switches --pad-header --lineend=linux --suffix=none --recursive include/\*.hpp examples/\*.cpp test/\*.cpp astyle --style=java --indent-namespaces --indent-switches --pad-header --lineend=linux --suffix=none --recursive include/\*.hpp examples/\*.cpp test/\*.cpp

View File

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

@ -1,112 +1,47 @@
# Osmium Library # Libosmium
http://osmcode.org/libosmium http://osmcode.org/libosmium
A fast and flexible C++ library for working with OpenStreetMap data. 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.
[![Build Status](https://secure.travis-ci.org/osmcode/libosmium.png)](http://travis-ci.org/osmcode/libosmium) [![Build Status](https://secure.travis-ci.org/osmcode/libosmium.png)](http://travis-ci.org/osmcode/libosmium)
[![Build status](https://ci.appveyor.com/api/projects/status/mkbg6e6stdgq7c1b?svg=true)](https://ci.appveyor.com/project/Mapbox/libosmium) [![Build status](https://ci.appveyor.com/api/projects/status/mkbg6e6stdgq7c1b?svg=true)](https://ci.appveyor.com/project/Mapbox/libosmium)
Libosmium is developed on Linux, but also works on OSX and Windows (with some Libosmium is developed on Linux, but also works on OSX and Windows (with some
limitations). 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 ## Prerequisites
Because Osmium uses many C++11 features you need a modern compiler and standard Because Libosmium uses many C++11 features you need a modern compiler and
C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.2. (Some parts may standard C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.4.
work with older versions.) (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 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 For details see the
http://www.boost.org/ [list of dependencies](https://github.com/osmcode/libosmium/wiki/Libosmium-dependencies).
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.
## Directories ## Directories
* include: C/C++ include files. All of Osmium is in those header files which * benchmarks: Some benchmarks checking different parts of Libosmium.
are needed for building Osmium applications.
* cmake: CMake configuration scripts.
* doc: Config for documentation.
* examples: Osmium example applications. * 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 ## Building
@ -124,61 +59,15 @@ cmake:
This will build the examples and tests. Call `ctest` to run the tests. 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 For more see the
enable the `doc` target so you can build the documentation like this: [Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Building-Libosmium).
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":
## Testing ## Testing
### Unit Tests See the
[Libosmium Wiki](https://github.com/osmcode/libosmium/wiki/Testing-Libosmium)
There are a few unit tests using the Catch unit test framework in the "test" for instructions.
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
## Osmium on 32bit Machines ## 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 ## 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 ## License
The Osmium Library is available under the Boost Software License. See Libosmium is available under the Boost Software License. See LICENSE.txt.
LICENSE.txt.
## Authors ## Authors
The Osmium Library was mainly written and is maintained by Jochen Topf Libosmium was mainly written and is maintained by Jochen Topf
(jochen@topf.org). (jochen@topf.org). See the git commit log for other authors.
Other authors:
* Peter Körner (github@mazdermind.de) (PBF writer, ...)

View File

@ -1,11 +1,13 @@
#-----------------------------------------------------------------------------
# #
# Configuration for appveyor.com # Configuration for continuous integration service at appveyor.com
# #
#-----------------------------------------------------------------------------
environment: environment:
matrix: matrix:
- configuration: Dev - config: Dev
# - configuration: Release - config: Release
# branches to build # branches to build
branches: branches:
@ -14,7 +16,7 @@ branches:
- master - master
# Operating system (build VM template) # 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 # scripts that are called at very beginning, before repo cloning
init: init:
@ -25,31 +27,51 @@ clone_folder: c:\projects\libosmium
platform: x64 platform: x64
install: 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 - cd c:\projects
- nuget install boost - git clone https://github.com/osmcode/osm-testdata.git
- 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
build_script: build_script:
- cd c:\projects\libosmium - cd c:\projects\libosmium
- mkdir build - mkdir build
- cd build - cd build
- call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 - echo %config%
- SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% - 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
- SET P=c:/projects/libosmium - msbuild libosmium.sln /p:Configuration=Release /toolsversion:14.0 /p:Platform=x64 /p:PlatformToolset=v140
- cmake .. -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=%Configuration% -DCMAKE_PREFIX_PATH=c:\projects -DBoost_USE_STATIC_LIBS=ON -T CTP_Nov2013 #- 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
- msbuild /clp:Verbosity=minimal /nologo libosmium.sln #- nmake
- msbuild /clp:Verbosity=minimal /nologo tests.vcxproj
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
View 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
View 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
View 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

View 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();
}

View 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();
}

View 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();
}

View 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";
}

View 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

View 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

View 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

View 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
View 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
View 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:"

View File

@ -9,16 +9,15 @@
# #
# Usage: # Usage:
# #
# Copy this file (and OsmiumOptions.cmake) somewhere into your project # Copy this file somewhere into your project directory, where cmake can
# directory, where cmake can find it. Usually this will be a directory # find it. Usually this will be a directory called "cmake" which you can
# called "cmake" which you can add to your module search path with the # add to the CMake module search path with the following line in your
# following line in your CMakeLists.txt: # CMakeLists.txt:
# #
# list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") # list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# #
# Then add the following in your CMakeLists.txt: # Then add the following in your CMakeLists.txt:
# #
# include(OsmiumOptions)
# find_package(Osmium REQUIRED COMPONENTS <XXX>) # find_package(Osmium REQUIRED COMPONENTS <XXX>)
# include_directories(${OSMIUM_INCLUDE_DIRS}) # 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. # Copy the results to the output variables.
if(OSMIUM_FOUND) if(OSMIUM_FOUND)
set(OSMIUM_INCLUDE_DIRS ${OSMIUM_INCLUDE_DIR}) set(OSMIUM_INCLUDE_DIRS ${OSMIUM_INCLUDE_DIR})
else()
set(OSMIUM_INCLUDE_DIRS "")
endif() endif()
if(Osmium_FIND_REQUIRED AND NOT OSMIUM_FOUND) if(Osmium_FIND_REQUIRED AND NOT OSMIUM_FOUND)
@ -234,10 +235,22 @@ endif()
#---------------------------------------------------------------------- #----------------------------------------------------------------------
list(REMOVE_DUPLICATES OSMIUM_INCLUDE_DIRS) list(REMOVE_DUPLICATES OSMIUM_INCLUDE_DIRS)
list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_PBF_LIBRARIES) if(OSMIUM_XML_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_IO_LIBRARIES) list(REMOVE_DUPLICATES OSMIUM_XML_LIBRARIES)
list(REMOVE_DUPLICATES OSMIUM_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) add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
if(MSVC) 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() endif()
if(APPLE) if(APPLE)
@ -271,7 +291,11 @@ endif()
# This is a set of recommended warning options that can be added when compiling # This is a set of recommended warning options that can be added when compiling
# libosmium code. # 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") 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
View 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")
#-----------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places. # title of most generated pages and in a few other places.
# The default value is: My Project. # 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 # 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 # could be handy for archiving the generated documentation or if some version

View File

@ -1,64 +1,115 @@
message(STATUS "Configuring examples...") #-----------------------------------------------------------------------------
#
# CMake Config
#
# Libosmium examples
#
#-----------------------------------------------------------------------------
if(GETOPT_MISSING) message(STATUS "Configuring examples")
message(FATAL_ERROR "On Visual Studio the wingetopt library is needed to compile examples")
endif()
set(SIMPLE_EXAMPLES set(EXAMPLES
osmium_convert area_test
osmium_count convert
osmium_create_node_cache count
osmium_debug create_node_cache
osmium_read debug
osmium_serdump index
osmium_use_node_cache 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() 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() 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() 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_LIBRARIES)
unset(Boost_FOUND) unset(Boost_FOUND)
find_package(Boost 1.38 COMPONENTS program_options) find_package(Boost 1.38 COMPONENTS program_options)
if(Boost_PROGRAM_OPTIONS_FOUND) if(Boost_PROGRAM_OPTIONS_FOUND)
set(example list(APPEND EXAMPLE_LIBS_index ${Boost_PROGRAM_OPTIONS_LIBRARY})
osmium_index
)
message(STATUS "Configuring example ${example}...")
add_executable(${example} "${example}.cpp")
target_link_libraries(${example} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OSMIUM_LIBRARIES})
else() 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() 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}) foreach(example ${OGR_EXAMPLES})
message(STATUS "Configuring example ${example}...") list(APPEND EXAMPLE_LIBS_${example} ${GDAL_LIBRARIES})
add_executable(${example} "${example}.cpp") list(APPEND EXAMPLE_LIBS_${example} ${PROJ_LIBRARIES})
target_link_libraries(${example} ${OSMIUM_LIBRARIES}) endforeach()
endforeach(example)
else() 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() 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")
#-----------------------------------------------------------------------------

View File

@ -18,12 +18,12 @@
#include <osmium/handler/dump.hpp> #include <osmium/handler/dump.hpp>
#include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/index/map/dummy.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/io/any_input.hpp>
#include <osmium/visitor.hpp> #include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type; 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; typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
class WKTDump : public osmium::handler::Handler { class WKTDump : public osmium::handler::Handler {

View File

@ -16,15 +16,15 @@
#include <osmium/io/xml_input.hpp> #include <osmium/io/xml_input.hpp>
#include <osmium/index/map/dummy.hpp> #include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp> #include <osmium/index/map/dense_mmap_array.hpp>
#include <osmium/index/map/mmap_vector_file.hpp> #include <osmium/index/map/dense_file_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp> #include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type; 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::DenseMmapArray<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::DenseFileArray<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::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;

View File

@ -14,15 +14,16 @@
#include <boost/program_options.hpp> #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/location.hpp>
#include <osmium/osm/types.hpp> #include <osmium/osm/types.hpp>
template <typename TKey, typename TValue> template <typename TKey, typename TValue>
class IndexSearch { class IndexSearch {
typedef typename osmium::index::map::DenseMapFile<TKey, TValue> dense_index_type; typedef typename osmium::index::map::DenseFileArray<TKey, TValue> dense_index_type;
typedef typename osmium::index::map::SparseMapFile<TKey, TValue> sparse_index_type; typedef typename osmium::index::map::SparseFileArray<TKey, TValue> sparse_index_type;
int m_fd; int m_fd;
bool m_dense_format; bool m_dense_format;
@ -186,11 +187,11 @@ public:
} }
bool dense_format() const { bool dense_format() const {
return vm.count("array"); return vm.count("array") != 0;
} }
bool do_dump() const { bool do_dump() const {
return vm.count("dump"); return vm.count("dump") != 0;
} }
std::vector<osmium::unsigned_object_id_type> search_keys() const { std::vector<osmium::unsigned_object_id_type> search_keys() const {

View File

@ -24,27 +24,26 @@
#include <osmium/handler/disk_store.hpp> #include <osmium/handler/disk_store.hpp>
#include <osmium/handler/object_relations.hpp> #include <osmium/handler/object_relations.hpp>
#include <osmium/index/map/stl_vector.hpp> #include <osmium/index/map/sparse_mem_array.hpp>
#include <osmium/index/multimap/stl_multimap.hpp> #include <osmium/index/multimap/sparse_mem_multimap.hpp>
#include <osmium/index/multimap/stl_vector.hpp> #include <osmium/index/multimap/sparse_mem_array.hpp>
#include <osmium/index/multimap/hybrid.hpp> #include <osmium/index/multimap/hybrid.hpp>
// ============================================================================== // ==============================================================================
// Choose the following depending on the size of the input OSM files: // Choose the following depending on the size of the input OSM files:
// ============================================================================== // ==============================================================================
// for smaller OSM files (extracts) // 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::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::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::SparseMemArray<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::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; //typedef osmium::index::multimap::Hybrid<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type> map_type;
// ============================================================================== // ==============================================================================
// for very large OSM files (planet) // 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::DenseMmapArray<osmium::unsigned_object_id_type, size_t> offset_index_type;
//typedef osmium::index::map::DenseMapMem map_type;
// ============================================================================== // ==============================================================================
void print_help() { void print_help() {

View File

@ -10,25 +10,7 @@
#include <iostream> #include <iostream>
#include <getopt.h> #include <getopt.h>
#pragma GCC diagnostic push #include <osmium/index/map/all.hpp>
#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/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp> #include <osmium/visitor.hpp>
@ -37,10 +19,7 @@
#include <osmium/handler.hpp> #include <osmium/handler.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type; typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
typedef osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location> index_pos_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::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 INFILE is not given stdin is assumed.\n" \
<< "If OUTFILE is not given 'ogr_out' is used.\n" \ << "If OUTFILE is not given 'ogr_out' is used.\n" \
<< "\nOptions:\n" \ << "\nOptions:\n" \
<< " -h, --help This help message\n" \ << " -h, --help This help message\n" \
<< " -f, --format=FORMAT Output OGR format (Default: 'SQLite')\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[]) { 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[] = { static struct option long_options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"format", required_argument, 0, 'f'}, {"format", required_argument, 0, 'f'},
{"location_store", required_argument, 0, 'l'},
{"list_location_stores", no_argument, 0, 'L'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
std::string output_format("SQLite"); std::string output_format { "SQLite" };
std::string location_store { "sparse_mem_array" };
while (true) { 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) { if (c == -1) {
break; break;
} }
@ -207,6 +193,15 @@ int main(int argc, char* argv[]) {
case 'f': case 'f':
output_format = optarg; output_format = optarg;
break; 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: default:
exit(1); exit(1);
} }
@ -229,9 +224,9 @@ int main(int argc, char* argv[]) {
osmium::io::Reader reader(input_filename); 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; 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(); location_handler.ignore_errors();
MyOGRHandler ogr_handler(output_format, output_filename); MyOGRHandler ogr_handler(output_format, output_filename);
@ -245,7 +240,7 @@ int main(int argc, char* argv[]) {
if (locations_fd < 0) { if (locations_fd < 0) {
throw std::system_error(errno, std::system_category(), "Open failed"); 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); close(locations_fd);
} }

View File

@ -13,24 +13,11 @@
#include <iostream> #include <iostream>
#include <getopt.h> #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 // usually you only need one or two of these
#include <osmium/index/map/dummy.hpp> #include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/sparse_table.hpp> #include <osmium/index/map/sparse_mem_table.hpp>
#include <osmium/index/map/stl_map.hpp> #include <osmium/index/map/sparse_mem_map.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp> #include <osmium/index/map/sparse_mmap_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.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::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::SparseMemArray<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::SparseMmapArray<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::SparseMemTable<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::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;

View File

@ -15,24 +15,7 @@
#include <iostream> #include <iostream>
#include <getopt.h> #include <getopt.h>
#pragma GCC diagnostic push #include <osmium/index/map/sparse_mem_array.hpp>
#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/visitor.hpp> #include <osmium/visitor.hpp>
@ -43,13 +26,8 @@
#include <osmium/handler.hpp> #include <osmium/handler.hpp>
#include <osmium/experimental/flex_reader.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::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_type;
typedef osmium::handler::NodeLocationsForWays<index_type> location_handler_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;
class MyOGRHandler : public osmium::handler::Handler { class MyOGRHandler : public osmium::handler::Handler {
@ -303,10 +281,9 @@ int main(int argc, char* argv[]) {
input_filename = "-"; input_filename = "-";
} }
index_pos_type index_pos; index_type index_pos;
index_neg_type index_neg; location_handler_type location_handler(index_pos);
location_handler_type location_handler(index_pos, index_neg); osmium::experimental::FlexReader<location_handler_type> exr(input_filename, location_handler, osmium::osm_entity_bits::object);
osmium::experimental::FlexReader<location_handler_type> exr(input_filename, osmium::osm_entity_bits::object);
MyOGRHandler ogr_handler(output_format, output_filename); MyOGRHandler ogr_handler(output_format, output_filename);

View File

@ -16,15 +16,15 @@
#include <osmium/io/xml_input.hpp> #include <osmium/io/xml_input.hpp>
#include <osmium/index/map/dummy.hpp> #include <osmium/index/map/dummy.hpp>
#include <osmium/index/map/mmap_vector_anon.hpp> #include <osmium/index/map/dense_file_array.hpp>
#include <osmium/index/map/mmap_vector_file.hpp> #include <osmium/index/map/dense_mmap_array.hpp>
#include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/handler/node_locations_for_ways.hpp>
#include <osmium/visitor.hpp> #include <osmium/visitor.hpp>
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type; 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::DenseMmapArray<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::DenseFileArray<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::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;

View File

@ -44,60 +44,60 @@
static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) 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)) if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
return MAP_FAILED; return MAP_FAILED;
if (fd == -1) { if (fd == -1) {
if (!(flags & MAP_ANON) || offset) if (!(flags & MAP_ANON) || offset)
return MAP_FAILED; return MAP_FAILED;
} else if (flags & MAP_ANON) } else if (flags & MAP_ANON)
return MAP_FAILED; return MAP_FAILED;
DWORD flProtect; DWORD flProtect;
if (prot & PROT_WRITE) { if (prot & PROT_WRITE) {
if (prot & PROT_EXEC) if (prot & PROT_EXEC)
flProtect = PAGE_EXECUTE_READWRITE; flProtect = PAGE_EXECUTE_READWRITE;
else else
flProtect = PAGE_READWRITE; flProtect = PAGE_READWRITE;
} else if (prot & PROT_EXEC) { } else if (prot & PROT_EXEC) {
if (prot & PROT_READ) if (prot & PROT_READ)
flProtect = PAGE_EXECUTE_READ; flProtect = PAGE_EXECUTE_READ;
else if (prot & PROT_EXEC) else if (prot & PROT_EXEC)
flProtect = PAGE_EXECUTE; flProtect = PAGE_EXECUTE;
} else } else
flProtect = PAGE_READONLY; flProtect = PAGE_READONLY;
off_t end = length + offset; off_t end = length + offset;
HANDLE mmap_fd, h; HANDLE mmap_fd, h;
if (fd == -1) if (fd == -1)
mmap_fd = INVALID_HANDLE_VALUE; mmap_fd = INVALID_HANDLE_VALUE;
else else
mmap_fd = (HANDLE)_get_osfhandle(fd); mmap_fd = (HANDLE)_get_osfhandle(fd);
h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL); h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
if (h == NULL) if (h == NULL)
return MAP_FAILED; return MAP_FAILED;
DWORD dwDesiredAccess; DWORD dwDesiredAccess;
if (prot & PROT_WRITE) if (prot & PROT_WRITE)
dwDesiredAccess = FILE_MAP_WRITE; dwDesiredAccess = FILE_MAP_WRITE;
else else
dwDesiredAccess = FILE_MAP_READ; dwDesiredAccess = FILE_MAP_READ;
if (prot & PROT_EXEC) if (prot & PROT_EXEC)
dwDesiredAccess |= FILE_MAP_EXECUTE; dwDesiredAccess |= FILE_MAP_EXECUTE;
if (flags & MAP_PRIVATE) if (flags & MAP_PRIVATE)
dwDesiredAccess |= FILE_MAP_COPY; dwDesiredAccess |= FILE_MAP_COPY;
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length); void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
if (ret == NULL) { if (ret == NULL) {
CloseHandle(h); CloseHandle(h);
ret = MAP_FAILED; ret = MAP_FAILED;
} }
return ret; return ret;
} }
static int munmap(void *addr, size_t length) static int munmap(void *addr, size_t length)
{ {
UnmapViewOfFile(addr); UnmapViewOfFile(addr);
return 0; return 0;
/* ruh-ro, we leaked handle from CreateFileMapping() ... */ /* ruh-ro, we leaked handle from CreateFileMapping() ... */
} }
#undef DWORD_HI #undef DWORD_HI

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -33,18 +33,38 @@ DEALINGS IN THE SOFTWARE.
*/ */
#pragma GCC diagnostic push /**
#ifdef __clang__ * @file
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" *
* 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 #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 <memory>
#include <stdexcept> #include <stdexcept>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -37,7 +37,9 @@ DEALINGS IN THE SOFTWARE.
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstring>
#include <new> #include <new>
#include <string>
#include <type_traits> #include <type_traits>
#include <osmium/memory/buffer.hpp> #include <osmium/memory/buffer.hpp>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -36,6 +36,7 @@ DEALINGS IN THE SOFTWARE.
#include <cstring> #include <cstring>
#include <initializer_list> #include <initializer_list>
#include <new> #include <new>
#include <string>
#include <utility> #include <utility>
#include <osmium/builder/builder.hpp> #include <osmium/builder/builder.hpp>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -41,7 +41,7 @@ DEALINGS IN THE SOFTWARE.
namespace osmium { namespace osmium {
/** /**
* @short Experimental code that is not "officially" supported. * @brief Experimental code that is not "officially" supported.
*/ */
namespace experimental { namespace experimental {
@ -51,9 +51,7 @@ namespace osmium {
bool m_with_areas; bool m_with_areas;
osmium::osm_entity_bits::type m_entities; osmium::osm_entity_bits::type m_entities;
typename TLocationHandler::index_pos_type m_index_pos; TLocationHandler& m_location_handler;
typename TLocationHandler::index_neg_type m_index_neg;
TLocationHandler m_location_handler;
osmium::io::Reader m_reader; osmium::io::Reader m_reader;
osmium::area::Assembler::config_type m_assembler_config; osmium::area::Assembler::config_type m_assembler_config;
@ -61,12 +59,10 @@ namespace osmium {
public: public:
explicit FlexReader(const osmium::io::File& file, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : 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), 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_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_location_handler(location_handler),
m_index_neg(),
m_location_handler(m_index_pos, m_index_neg),
m_reader(file, m_entities), m_reader(file, m_entities),
m_assembler_config(), m_assembler_config(),
m_collector(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) : 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), entities) { FlexReader(osmium::io::File(filename), location_handler, entities) {
} }
explicit FlexReader(const char* filename, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) : explicit FlexReader(const char* filename, TLocationHandler& location_handler, osmium::osm_entity_bits::type entities = osmium::osm_entity_bits::nwr) :
FlexReader(osmium::io::File(filename), entities) { FlexReader(osmium::io::File(filename), location_handler, entities) {
} }
osmium::memory::Buffer read() { osmium::memory::Buffer read() {
std::vector<osmium::memory::Buffer> area_buffers;
osmium::memory::Buffer buffer = m_reader.read(); osmium::memory::Buffer buffer = m_reader.read();
if (buffer) { if (buffer) {
if (m_with_areas) { 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) { osmium::apply(buffer, m_location_handler, m_collector.handler([&area_buffers](osmium::memory::Buffer&& area_buffer) {
area_buffers.push_back(std::move(area_buffer)); area_buffers.push_back(std::move(area_buffer));
})); }));

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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 <utility>
#include <geos/geom/Coordinate.h> #include <geos/geom/Coordinate.h>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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 <cassert>
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>
#include <utility> #include <utility>
#pragma GCC diagnostic push #ifdef _MSC_VER
#ifdef __clang__ # pragma warning(push)
# pragma GCC diagnostic ignored "-Wdocumentation-unknown-command" # 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 #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/coordinates.hpp>
#include <osmium/geom/factory.hpp> #include <osmium/geom/factory.hpp>

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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 <memory>
#include <string> #include <string>
@ -77,11 +86,11 @@ namespace osmium {
} }
bool is_latlong() const { bool is_latlong() const {
return pj_is_latlong(m_crs.get()); return pj_is_latlong(m_crs.get()) != 0;
} }
bool is_geocent() const { bool is_geocent() const {
return pj_is_geocent(m_crs.get()); return pj_is_geocent(m_crs.get()) != 0;
} }
/** /**

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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/types.hpp>
#include <osmium/osm/way.hpp> #include <osmium/osm/way.hpp>
#include <osmium/index/node_locations_map.hpp>
namespace osmium { namespace osmium {
namespace handler { namespace handler {
@ -102,6 +104,9 @@ namespace osmium {
NodeLocationsForWays(const NodeLocationsForWays&) = delete; NodeLocationsForWays(const NodeLocationsForWays&) = delete;
NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete; NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete;
NodeLocationsForWays(NodeLocationsForWays&&) = default;
NodeLocationsForWays& operator=(NodeLocationsForWays&&) = default;
~NodeLocationsForWays() noexcept = default; ~NodeLocationsForWays() noexcept = default;
void ignore_errors() { void ignore_errors() {

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View 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

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP #ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP #define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -45,8 +45,8 @@ namespace osmium {
namespace detail { 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> template <typename T>
class mmap_vector_anon : public mmap_vector_base<T, mmap_vector_anon> { class mmap_vector_anon : public mmap_vector_base<T, mmap_vector_anon> {
@ -75,4 +75,4 @@ namespace osmium {
#endif // __linux__ #endif // __linux__
#endif // OSMIUM_DETAIL_MMAP_VECTOR_ANON_HPP #endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_ANON_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP #ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP #define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE.
#include <stdexcept> #include <stdexcept>
#include <osmium/index/detail/typed_mmap.hpp> #include <osmium/index/detail/typed_mmap.hpp>
#include <osmium/util/compatibility.hpp>
namespace osmium { namespace osmium {
@ -180,4 +181,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_DETAIL_MMAP_VECTOR_BASE_HPP #endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_BASE_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP #ifndef OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP
#define OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP #define OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -82,4 +82,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_DETAIL_MMAP_VECTOR_FILE_HPP #endif // OSMIUM_INDEX_DETAIL_MMAP_VECTOR_FILE_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_DETAIL_TMPFILE_HPP #ifndef OSMIUM_INDEX_DETAIL_TMPFILE_HPP
#define OSMIUM_DETAIL_TMPFILE_HPP #define OSMIUM_INDEX_DETAIL_TMPFILE_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -59,4 +59,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_DETAIL_TMPFILE #endif // OSMIUM_INDEX_DETAIL_TMPFILE_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_DETAIL_TYPED_MMAP_HPP #ifndef OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP
#define OSMIUM_DETAIL_TYPED_MMAP_HPP #define OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -226,4 +226,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_DETAIL_TYPED_MMAP_HPP #endif // OSMIUM_INDEX_DETAIL_TYPED_MMAP_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_VECTOR_HPP #ifndef OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP
#define OSMIUM_INDEX_MAP_VECTOR_HPP #define OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -38,6 +38,7 @@ DEALINGS IN THE SOFTWARE.
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <osmium/index/index.hpp>
#include <osmium/index/map.hpp> #include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp> #include <osmium/io/detail/read_write.hpp>
@ -198,7 +199,7 @@ namespace osmium {
std::sort(m_vector.begin(), m_vector.end()); 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()); osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
} }
@ -234,4 +235,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MAP_VECTOR_HPP #endif // OSMIUM_INDEX_DETAIL_VECTOR_MAP_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MULTIMAP_VECTOR_HPP #ifndef OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP
#define OSMIUM_INDEX_MULTIMAP_VECTOR_HPP #define OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -37,6 +37,7 @@ DEALINGS IN THE SOFTWARE.
#include <cstddef> #include <cstddef>
#include <utility> #include <utility>
#include <osmium/index/index.hpp>
#include <osmium/index/multimap.hpp> #include <osmium/index/multimap.hpp>
#include <osmium/io/detail/read_write.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()); osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(m_vector.data()), byte_size());
} }
@ -148,4 +149,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_VECTOR_HPP #endif // OSMIUM_INDEX_DETAIL_VECTOR_MULTIMAP_HPP

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -33,10 +33,18 @@ DEALINGS IN THE SOFTWARE.
*/ */
#include <algorithm>
#include <cstddef> #include <cstddef>
#include <functional>
#include <map>
#include <memory>
#include <stdexcept>
#include <string>
#include <type_traits> #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 { namespace osmium {
@ -140,7 +148,7 @@ namespace osmium {
// default implementation is empty // 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"); std::runtime_error("can't dump as list");
} }
@ -148,6 +156,98 @@ namespace osmium {
} // namespace map } // 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 index
} // namespace osmium } // namespace osmium

View 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

View 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

View 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

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP #ifndef OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP #define OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -35,8 +35,10 @@ DEALINGS IN THE SOFTWARE.
#ifdef __linux__ #ifdef __linux__
#include <osmium/index/map/vector.hpp>
#include <osmium/index/detail/mmap_vector_anon.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 { namespace osmium {
@ -45,10 +47,7 @@ namespace osmium {
namespace map { namespace map {
template <typename TId, typename TValue> template <typename TId, typename TValue>
using DenseMapMmap = VectorBasedDenseMap<osmium::detail::mmap_vector_anon<TValue>, TId, TValue>; using DenseMmapArray = VectorBasedDenseMap<osmium::detail::mmap_vector_anon<TValue>, TId, TValue>;
template <typename TId, typename TValue>
using SparseMapMmap = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_anon>;
} // namespace map } // namespace map
@ -58,4 +57,4 @@ namespace osmium {
#endif // __linux__ #endif // __linux__
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_ANON_HPP #endif // OSMIUM_INDEX_MAP_DENSE_MMAP_ARRAY_HPP

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -35,6 +35,7 @@ DEALINGS IN THE SOFTWARE.
#include <cstddef> #include <cstddef>
#include <osmium/index/index.hpp>
#include <osmium/index/map.hpp> #include <osmium/index/map.hpp>
namespace osmium { namespace osmium {

View 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

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_STL_VECTOR_HPP #ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP
#define OSMIUM_INDEX_MAP_STL_VECTOR_HPP #define OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -35,7 +35,9 @@ DEALINGS IN THE SOFTWARE.
#include <vector> #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 { namespace osmium {
@ -43,14 +45,11 @@ namespace osmium {
namespace map { namespace map {
template <typename TId, typename TValue>
using DenseMapMem = VectorBasedDenseMap<std::vector<TValue>, TId, TValue>;
template <typename T> template <typename T>
using StdVectorWrap = std::vector<T>; using StdVectorWrap = std::vector<T>;
template <typename TId, typename TValue> template <typename TId, typename TValue>
using SparseMapMem = VectorBasedSparseMap<TId, TValue, StdVectorWrap>; using SparseMemArray = VectorBasedSparseMap<TId, TValue, StdVectorWrap>;
} // namespace map } // namespace map
@ -58,4 +57,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MAP_STL_VECTOR_HPP #endif // OSMIUM_INDEX_MAP_SPARSE_MEM_ARRAY_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_STL_MAP_HPP #ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP
#define OSMIUM_INDEX_MAP_STL_MAP_HPP #define OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -41,8 +41,11 @@ DEALINGS IN THE SOFTWARE.
#include <vector> #include <vector>
#include <osmium/index/map.hpp> #include <osmium/index/map.hpp>
#include <osmium/index/index.hpp>
#include <osmium/io/detail/read_write.hpp> #include <osmium/io/detail/read_write.hpp>
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP
namespace osmium { namespace osmium {
namespace index { namespace index {
@ -54,7 +57,7 @@ namespace osmium {
* lot of memory, but might make sense for small maps. * lot of memory, but might make sense for small maps.
*/ */
template <typename TId, typename TValue> 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 // This is a rough estimate for the memory needed for each
// element in the map (id + value + pointers to left, right, // element in the map (id + value + pointers to left, right,
@ -66,9 +69,9 @@ namespace osmium {
public: public:
StlMap() = default; SparseMemMap() = default;
~StlMap() override final = default; ~SparseMemMap() override final = default;
void set(const TId id, const TValue value) override final { void set(const TId id, const TValue value) override final {
m_elements[id] = value; m_elements[id] = value;
@ -94,14 +97,14 @@ namespace osmium {
m_elements.clear(); 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; typedef typename std::map<TId, TValue>::value_type t;
std::vector<t> v; std::vector<t> v;
std::copy(m_elements.begin(), m_elements.end(), std::back_inserter(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()); osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(t) * v.size());
} }
}; // class StlMap }; // class SparseMemMap
} // namespace map } // namespace map
@ -109,4 +112,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MAP_STL_MAP_HPP #endif // OSMIUM_INDEX_MAP_SPARSE_MEM_MAP_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP #ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP
#define OSMIUM_INDEX_MAP_SPARSE_TABLE_HPP #define OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -34,15 +34,17 @@ DEALINGS IN THE SOFTWARE.
*/ */
#include <cstddef> #include <cstddef>
#include <stdexcept>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <google/sparsetable> #include <google/sparsetable>
#include <osmium/index/index.hpp>
#include <osmium/index/map.hpp> #include <osmium/index/map.hpp>
#include <osmium/io/detail/read_write.hpp> #include <osmium/io/detail/read_write.hpp>
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE
namespace osmium { namespace osmium {
namespace index { namespace index {
@ -50,9 +52,9 @@ namespace osmium {
namespace map { 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 * 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 * Use this index if the ID space is only sparsly
* populated, such as when working with smaller OSM files (like * populated, such as when working with smaller OSM files (like
@ -61,7 +63,7 @@ namespace osmium {
* This will only work on 64 bit machines. * This will only work on 64 bit machines.
*/ */
template <typename TId, typename TValue> 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; TId m_grow_size;
@ -79,12 +81,12 @@ namespace osmium {
* The storage will grow by at least this size * The storage will grow by at least this size
* every time it runs out of space. * 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_grow_size(grow_size),
m_elements(grow_size) { m_elements(grow_size) {
} }
~SparseTable() override final = default; ~SparseMemTable() override final = default;
void set(const TId id, const TValue value) override final { void set(const TId id, const TValue value) override final {
if (id >= m_elements.size()) { if (id >= m_elements.size()) {
@ -117,7 +119,7 @@ namespace osmium {
m_elements.clear(); 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; std::vector<std::pair<TId, TValue>> v;
int n=0; int n=0;
for (const TValue value : m_elements) { 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()); 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 } // namespace map
@ -137,4 +139,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_BYID_SPARSE_TABLE_HPP #endif // OSMIUM_INDEX_BYID_SPARSE_MEM_TABLE_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP #ifndef OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP
#define OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP #define OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -33,8 +33,12 @@ DEALINGS IN THE SOFTWARE.
*/ */
#include <osmium/index/map/vector.hpp> #ifdef __linux__
#include <osmium/index/detail/mmap_vector_file.hpp>
#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 { namespace osmium {
@ -43,10 +47,7 @@ namespace osmium {
namespace map { namespace map {
template <typename TId, typename TValue> template <typename TId, typename TValue>
using DenseMapFile = VectorBasedDenseMap<osmium::detail::mmap_vector_file<TValue>, TId, TValue>; using SparseMmapArray = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_anon>;
template <typename TId, typename TValue>
using SparseMapFile = VectorBasedSparseMap<TId, TValue, osmium::detail::mmap_vector_file>;
} // namespace map } // namespace map
@ -54,4 +55,6 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MAP_MMAP_VECTOR_FILE_HPP #endif // __linux__
#endif // OSMIUM_INDEX_MAP_SPARSE_MMAP_ARRAY_HPP

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -34,11 +34,10 @@ DEALINGS IN THE SOFTWARE.
*/ */
#include <cstddef> #include <cstddef>
#include <stdexcept>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <osmium/index/index.hpp> // IWYU pragma: export
namespace osmium { namespace osmium {
namespace index { namespace index {
@ -114,7 +113,7 @@ namespace osmium {
// default implementation is empty // 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"); std::runtime_error("can't dump as list");
} }

View 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

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -36,9 +36,10 @@ DEALINGS IN THE SOFTWARE.
#include <cstddef> #include <cstddef>
#include <utility> #include <utility>
#include <osmium/index/index.hpp>
#include <osmium/index/multimap.hpp> #include <osmium/index/multimap.hpp>
#include <osmium/index/multimap/stl_vector.hpp> #include <osmium/index/multimap/sparse_mem_array.hpp>
#include <osmium/index/multimap/stl_multimap.hpp> #include <osmium/index/multimap/sparse_mem_multimap.hpp>
namespace osmium { namespace osmium {
@ -49,8 +50,8 @@ namespace osmium {
template <typename TId, typename TValue> template <typename TId, typename TValue>
class HybridIterator { class HybridIterator {
typedef SparseMultimapMem<TId, TValue> main_map_type; typedef SparseMemArray<TId, TValue> main_map_type;
typedef StlMultimap<TId, TValue> extra_map_type; typedef SparseMemMultimap<TId, TValue> extra_map_type;
typedef typename std::pair<TId, TValue> element_type; typedef typename std::pair<TId, TValue> element_type;
@ -117,8 +118,8 @@ namespace osmium {
template <typename TId, typename TValue> template <typename TId, typename TValue>
class Hybrid : public Multimap<TId, TValue> { class Hybrid : public Multimap<TId, TValue> {
typedef SparseMultimapMem<TId, TValue> main_map_type; typedef SparseMemArray<TId, TValue> main_map_type;
typedef StlMultimap<TId, TValue> extra_map_type; typedef SparseMemMultimap<TId, TValue> extra_map_type;
main_map_type m_main; main_map_type m_main;
extra_map_type m_extra; extra_map_type m_extra;
@ -174,7 +175,7 @@ namespace osmium {
m_main.sort(); m_main.sort();
} }
void dump_as_list(int fd) override final { void dump_as_list(const int fd) override final {
consolidate(); consolidate();
m_main.dump_as_list(fd); m_main.dump_as_list(fd);
} }

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP #ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP #define OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 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/mmap_vector_file.hpp>
#include <osmium/index/detail/vector_multimap.hpp>
namespace osmium { namespace osmium {
@ -43,7 +43,7 @@ namespace osmium {
namespace multimap { namespace multimap {
template <typename TId, typename TValue> 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 } // namespace multimap
@ -51,4 +51,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_FILE_HPP #endif // OSMIUM_INDEX_MULTIMAP_SPARSE_FILE_ARRAY_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP #ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP
#define OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP #define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE.
#include <vector> #include <vector>
#include <osmium/index/multimap/vector.hpp> #include <osmium/index/detail/vector_multimap.hpp>
namespace osmium { namespace osmium {
@ -47,7 +47,7 @@ namespace osmium {
using StdVectorWrap = std::vector<T>; using StdVectorWrap = std::vector<T>;
template <typename TId, typename TValue> template <typename TId, typename TValue>
using SparseMultimapMem = VectorBasedSparseMultimap<TId, TValue, StdVectorWrap>; using SparseMemArray = VectorBasedSparseMultimap<TId, TValue, StdVectorWrap>;
} // namespace multimap } // namespace multimap
@ -55,4 +55,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_STL_VECTOR_HPP #endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_ARRAY_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP #ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
#define OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP #define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 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. * lot of memory, but might make sense for small maps.
*/ */
template <typename TId, typename TValue> 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 // This is a rough estimate for the memory needed for each
// element in the map (id + value + pointers to left, right, // element in the map (id + value + pointers to left, right,
@ -76,9 +76,9 @@ namespace osmium {
public: public:
StlMultimap() = default; SparseMemMultimap() = default;
~StlMultimap() noexcept override final = default; ~SparseMemMultimap() noexcept override final = default;
void unsorted_set(const TId id, const TValue value) { void unsorted_set(const TId id, const TValue value) {
m_elements.emplace(id, value); m_elements.emplace(id, value);
@ -130,7 +130,7 @@ namespace osmium {
// intentionally left blank // 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; std::vector<element_type> v;
for (const auto& element : m_elements) { for (const auto& element : m_elements) {
v.emplace_back(element.first, element.second); 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()); osmium::io::detail::reliable_write(fd, reinterpret_cast<const char*>(v.data()), sizeof(element_type) * v.size());
} }
}; // class StlMultimap }; // class SparseMemMultimap
} // namespace multimap } // namespace multimap
@ -148,4 +148,4 @@ namespace osmium {
} // namespace osmium } // namespace osmium
#endif // OSMIUM_INDEX_MULTIMAP_STL_MULTIMAP_HPP #endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP

View File

@ -1,11 +1,11 @@
#ifndef OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP #ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP
#define OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP #define OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP
/* /*
This file is part of Osmium (http://osmcode.org/libosmium). 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 Boost Software License - Version 1.0 - August 17th, 2003
@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
#ifdef __linux__ #ifdef __linux__
#include <osmium/index/multimap/vector.hpp>
#include <osmium/index/detail/mmap_vector_anon.hpp> #include <osmium/index/detail/mmap_vector_anon.hpp>
#include <osmium/index/detail/vector_multimap.hpp>
namespace osmium { namespace osmium {
@ -45,7 +45,7 @@ namespace osmium {
namespace multimap { namespace multimap {
template <typename TId, typename TValue> 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 } // namespace multimap
@ -55,4 +55,4 @@ namespace osmium {
#endif // __linux__ #endif // __linux__
#endif // OSMIUM_INDEX_MULTIMAP_MMAP_VECTOR_ANON_HPP #endif // OSMIUM_INDEX_MULTIMAP_SPARSE_MMAP_ARRAY_HPP

View 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

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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/bzip2_compression.hpp> // IWYU pragma: export
#include <osmium/io/gzip_compression.hpp> // IWYU pragma: export #include <osmium/io/gzip_compression.hpp> // IWYU pragma: export

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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/any_compression.hpp> // IWYU pragma: export
#include <osmium/io/pbf_input.hpp> // IWYU pragma: export #include <osmium/io/pbf_input.hpp> // IWYU pragma: export

View File

@ -5,7 +5,7 @@
This file is part of Osmium (http://osmcode.org/libosmium). 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 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/any_compression.hpp> // IWYU pragma: export
#include <osmium/io/opl_output.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