upgrade libosmium dependency
This commit is contained in:
commit
68e66dad06
6
third_party/libosmium/.travis.yml
vendored
6
third_party/libosmium/.travis.yml
vendored
@ -20,6 +20,7 @@ before_install:
|
||||
- sudo apt-get update --yes --quiet
|
||||
|
||||
install:
|
||||
- cd ..
|
||||
# upgrade compilers
|
||||
- sudo apt-get install --yes gcc-4.8 g++-4.8
|
||||
# make sure 'cpp' is the just installed current one
|
||||
@ -35,6 +36,7 @@ install:
|
||||
- make
|
||||
- sudo make install
|
||||
- cd ../..
|
||||
- cd libosmium
|
||||
|
||||
before_script:
|
||||
- true
|
||||
@ -45,7 +47,5 @@ script:
|
||||
- cd build
|
||||
- cmake -LA -DCMAKE_BUILD_TYPE=${CONFIGURATION} ..
|
||||
- make VERBOSE=1
|
||||
# Disable multipolygon test because it needs ruby and the 'json' gem, but the
|
||||
# travis ruby installation doesn't find the gem it did install itself.
|
||||
- ctest -V -E testdata-multipolygon
|
||||
- ctest --output-on-failure
|
||||
|
||||
|
15
third_party/libosmium/CMakeLists.txt
vendored
15
third_party/libosmium/CMakeLists.txt
vendored
@ -16,6 +16,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel;Dev"
|
||||
CACHE STRING
|
||||
"List of available configuration types"
|
||||
FORCE)
|
||||
|
||||
project(libosmium)
|
||||
|
||||
set(LIBOSMIUM_VERSION_MAJOR 0)
|
||||
@ -137,8 +142,6 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${USUAL_COMPILE_OPTIONS}"
|
||||
# Build Type
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_CONFIGURATION_TYPES "Debug Release RelWithDebInfo MinSizeRel Dev")
|
||||
|
||||
# In 'Dev' mode: compile with very strict warnings and turn them into errors.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Dev")
|
||||
if(NOT MSVC)
|
||||
@ -279,14 +282,6 @@ if(BUILD_HEADERS)
|
||||
# so we pretend to build a library here.
|
||||
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})
|
||||
|
||||
|
39
third_party/libosmium/appveyor.yml
vendored
39
third_party/libosmium/appveyor.yml
vendored
@ -7,7 +7,7 @@
|
||||
environment:
|
||||
matrix:
|
||||
- config: Dev
|
||||
- config: Release
|
||||
- config: RelWithDebInfo
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
@ -28,35 +28,35 @@ platform: x64
|
||||
|
||||
install:
|
||||
# show all availble env vars
|
||||
- SET
|
||||
- ECHO cmake on AppVeyor
|
||||
- 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
|
||||
- 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%
|
||||
- set PATH=%LODEPSDIR%\geos\lib;%PATH%
|
||||
#gdal.dll
|
||||
- SET PATH=%LODEPSDIR%\gdal\lib;%PATH%
|
||||
- set PATH=%LODEPSDIR%\gdal\lib;%PATH%
|
||||
#libexpat.dll
|
||||
- SET PATH=%LODEPSDIR%\expat\lib;%PATH%
|
||||
- set PATH=%LODEPSDIR%\expat\lib;%PATH%
|
||||
#libtiff.dll
|
||||
- SET PATH=%LODEPSDIR%\libtiff\lib;%PATH%
|
||||
- set PATH=%LODEPSDIR%\libtiff\lib;%PATH%
|
||||
#zlibwapi.dll
|
||||
- SET PATH=%LODEPSDIR%\zlib\lib;%PATH%
|
||||
- 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:\=/%
|
||||
- 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
|
||||
- 7z x cm.7z | %windir%\system32\find "ing archive"
|
||||
- 7z x lodeps.7z | %windir%\system32\find "ing archive"
|
||||
- echo %LODEPSDIR%
|
||||
- dir %LODEPSDIR%
|
||||
- ECHO our own cmake
|
||||
- echo our own cmake
|
||||
- cmake -version
|
||||
- cd c:\projects
|
||||
- git clone https://github.com/osmcode/osm-testdata.git
|
||||
@ -67,11 +67,10 @@ build_script:
|
||||
- cd build
|
||||
- echo %config%
|
||||
- cmake .. -LA -G "Visual Studio 14 Win64" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include
|
||||
- msbuild libosmium.sln /p:Configuration=Release /toolsversion:14.0 /p:Platform=x64 /p:PlatformToolset=v140
|
||||
- msbuild libosmium.sln /p:Configuration=%config% /toolsversion:14.0 /p:Platform=x64 /p:PlatformToolset=v140
|
||||
#- cmake .. -LA -G "NMake Makefiles" -DOsmium_DEBUG=TRUE -DCMAKE_BUILD_TYPE=%config% -DBOOST_ROOT=%LODEPSDIR%\boost -DBoost_PROGRAM_OPTIONS_LIBRARY=%LODEPSDIR%\boost\lib\libboost_program_options-vc140-mt-1_57.lib -DOSMPBF_LIBRARY=%LODEPSDIR%\osmpbf\lib\osmpbf.lib -DOSMPBF_INCLUDE_DIR=%LODEPSDIR%\osmpbf\include -DPROTOBUF_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf.lib -DPROTOBUF_LITE_LIBRARY=%LODEPSDIR%\protobuf\lib\libprotobuf-lite.lib -DPROTOBUF_INCLUDE_DIR=%LODEPSDIR%\protobuf\include -DZLIB_LIBRARY=%LODEPSDIR%\zlib\lib\zlibwapi.lib -DZLIB_INCLUDE_DIR=%LODEPSDIR%\zlib\include -DEXPAT_LIBRARY=%LODEPSDIR%\expat\lib\libexpat.lib -DEXPAT_INCLUDE_DIR=%LODEPSDIR%\expat\include -DBZIP2_LIBRARIES=%LIBBZIP2% -DBZIP2_INCLUDE_DIR=%LODEPSDIR%\bzip2\include -DGDAL_LIBRARY=%LODEPSDIR%\gdal\lib\gdal_i.lib -DGDAL_INCLUDE_DIR=%LODEPSDIR%\gdal\include -DGEOS_LIBRARY=%LODEPSDIR%\geos\lib\geos.lib -DGEOS_INCLUDE_DIR=%LODEPSDIR%\geos\include -DPROJ_LIBRARY=%LODEPSDIR%\proj\lib\proj.lib -DPROJ_INCLUDE_DIR=%LODEPSDIR%\proj\include -DSPARSEHASH_INCLUDE_DIR=%LODEPSDIR%\sparsehash\include -DGETOPT_LIBRARY=%LODEPSDIR%\wingetopt\lib\wingetopt.lib -DGETOPT_INCLUDE_DIR=%LODEPSDIR%\wingetopt\include
|
||||
#- nmake
|
||||
|
||||
test_script:
|
||||
# Disable multipolygon test because it needs ruby and the 'json' gem
|
||||
- ctest -V -C %config% -E testdata-multipolygon
|
||||
- ctest --output-on-failure -C %config%
|
||||
|
||||
|
153
third_party/libosmium/cmake/FindGem.cmake
vendored
Normal file
153
third_party/libosmium/cmake/FindGem.cmake
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
# Author thomas.roehr@dfki.de
|
||||
#
|
||||
# Version 0.3 2013-07-02
|
||||
# - rely on `gem content` to find library and header
|
||||
# - introduce GEM_OS_PKG to allow search via pkgconfig
|
||||
# Version 0.2 2010-01-14
|
||||
# - add support for searching for multiple gems
|
||||
# Version 0.1 2010-12-15
|
||||
# - support basic search functionality
|
||||
# - tested to find rice
|
||||
#
|
||||
# OUTPUT:
|
||||
#
|
||||
# GEM_INCLUDE_DIRS After successful search contains the include directores
|
||||
#
|
||||
# GEM_LIBRARIES After successful search contains the full path of each found library
|
||||
#
|
||||
#
|
||||
# Usage:
|
||||
# set(GEM_DEBUG TRUE)
|
||||
# find_package(Gem COMPONENTS rice hoe)
|
||||
# include_directories(${GEM_INCLUDE_DIRS})
|
||||
# target_link_libraries(${GEM_LIBRARIES}
|
||||
#
|
||||
# in case pkg-config should be used to search for the os pkg, set GEM_OS_PKG, i.e.
|
||||
# set(GEM_OS_PKG TRUE)
|
||||
#
|
||||
# Check for how 'gem' should be called
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_program(GEM_EXECUTABLE
|
||||
NAMES "gem${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}"
|
||||
"gem${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}"
|
||||
"gem-${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}"
|
||||
"gem-${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}"
|
||||
"gem${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}"
|
||||
"gem${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}"
|
||||
"gem-${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}"
|
||||
"gem-${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}"
|
||||
"gem")
|
||||
|
||||
# Making backward compatible
|
||||
if(Gem_DEBUG)
|
||||
set(GEM_DEBUG TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT GEM_EXECUTABLE)
|
||||
MESSAGE(FATAL_ERROR "Could not find the gem executable - install 'gem' first")
|
||||
endif()
|
||||
|
||||
if(NOT Gem_FIND_COMPONENTS)
|
||||
MESSAGE(FATAL_ERROR "If searching for a Gem you have to provide COMPONENTS with the name of the gem")
|
||||
endif()
|
||||
|
||||
foreach(Gem_NAME ${Gem_FIND_COMPONENTS})
|
||||
set(GEM_${Gem_NAME}_FOUND TRUE)
|
||||
list(APPEND components_found_vars GEM_${Gem_NAME}_FOUND)
|
||||
# If the gem is installed as a gem
|
||||
if(NOT GEM_OS_PKG)
|
||||
set(GEM_HOME ENV{GEM_HOME})
|
||||
|
||||
# Use `gem content <gem-name>` to extract current information about installed gems
|
||||
# Store the information into ${GEM_LOCAL_INFO}
|
||||
EXECUTE_PROCESS(COMMAND ${GEM_EXECUTABLE} content ${Gem_NAME}
|
||||
RESULT_VARIABLE GEM_RUN_RESULT
|
||||
OUTPUT_VARIABLE GEM_LOCAL_INFO)
|
||||
|
||||
if(GEM_RUN_RESULT STREQUAL "0")
|
||||
list(APPEND FOUND_GEMS ${Gem_NAME})
|
||||
set(_library_NAME_PATTERN lib${Gem_NAME}.a
|
||||
lib${Gem_NAME}.so
|
||||
lib${Gem_NAME}.dylib
|
||||
${Gem_NAME}.a
|
||||
${Gem_NAME}.so
|
||||
${Gem_NAME}.dylib
|
||||
.*.a
|
||||
.*.so
|
||||
.*.dylib
|
||||
)
|
||||
|
||||
set(_header_SUFFIX_PATTERN
|
||||
.h
|
||||
.hh
|
||||
.hpp
|
||||
)
|
||||
|
||||
# Create a list from the output results of the gem command
|
||||
string(REPLACE "\n" ";" GEM_CONTENT_LIST "${GEM_LOCAL_INFO}")
|
||||
foreach(_gem_CONTENT_PATH ${GEM_CONTENT_LIST})
|
||||
|
||||
# Convert so that only '/' Unix path separator are being using
|
||||
# needed to do proper regex matching
|
||||
FILE(TO_CMAKE_PATH ${_gem_CONTENT_PATH} gem_CONTENT_PATH)
|
||||
|
||||
# Identify library -- checking for a library in the gems 'lib' (sub)directory
|
||||
# Search for an existing library, but only within the gems folder
|
||||
foreach(_library_NAME ${_library_NAME_PATTERN})
|
||||
STRING(REGEX MATCH ".*${Gem_NAME}.*/lib/.*${_library_NAME}$" GEM_PATH_INFO "${gem_CONTENT_PATH}")
|
||||
if(NOT "${GEM_PATH_INFO}" STREQUAL "")
|
||||
list(APPEND GEM_LIBRARIES ${GEM_PATH_INFO})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Identify headers
|
||||
# Checking for available headers in an include directory
|
||||
foreach(_header_PATTERN ${_header_SUFFIX_PATTERN})
|
||||
STRING(REGEX MATCH ".*${Gem_NAME}.*/include/.*${_header_PATTERN}$" GEM_PATH_INFO "${gem_CONTENT_PATH}")
|
||||
if(NOT "${GEM_PATH_INFO}" STREQUAL "")
|
||||
STRING(REGEX REPLACE "(.*${Gem_NAME}.*/include/).*${_header_PATTERN}$" "\\1" GEM_PATH_INFO "${gem_CONTENT_PATH}")
|
||||
list(APPEND GEM_INCLUDE_DIRS ${GEM_PATH_INFO})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
else()
|
||||
set(GEM_${Gem_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
else(NOT GEM_OS_PKG)
|
||||
pkg_check_modules(GEM_PKG ${Gem_NAME})
|
||||
set(GEM_${GEM_NAME}_FOUND GEM_PKG_FOUND)
|
||||
set(GEM_INCLUDE_DIRS ${GEM_PKG_INCLUDE_DIRS})
|
||||
set(GEM_LIBRARIES ${GEM_PKG_LIBRARIES} ${GEM_PKG_STATIC_LIBRARIES})
|
||||
list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS} ${GEM_PKG_STATIC_LDFLAGS})
|
||||
list(APPEND GEM_LIBRARIES ${GEM_PKG_LDFLAGS_OTHER} ${GEM_PKG_STATIC_LDFLAGS_OTHER})
|
||||
|
||||
if(GEM_DEBUG)
|
||||
message(STATUS "GEM_OS_PKG is defined")
|
||||
message(STATUS "GEM_INCLUDE_DIRS ${GEM_INCLUDE_DIRS}")
|
||||
message(STATUS "GEM_STATIC_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
|
||||
message(STATUS "GEM_LIBRARY_DIRS ${GEM_PKG_STATIC_LIBRARY_DIRS}")
|
||||
message(STATUS "GEM_STATIC_LIBRARIES ${GEM_PKG_STATIC_LIBRARIES}")
|
||||
message(STATUS "GEM_LIBRARIES ${GEM_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GEM_DEBUG)
|
||||
message(STATUS "${Gem_NAME} library dir: ${GEM_LIBRARIES}")
|
||||
message(STATUS "${Gem_NAME} include dir: ${GEM_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Compact the lists
|
||||
if(DEFINED GEM_LIBRARIES)
|
||||
LIST(REMOVE_DUPLICATES GEM_LIBRARIES)
|
||||
endif()
|
||||
if(DEFINED GEM_INCLUDE_DIRS)
|
||||
LIST(REMOVE_DUPLICATES GEM_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(GEM
|
||||
REQUIRED_VARS ${components_found_vars}
|
||||
FAIL_MESSAGE "Could not find all required gems")
|
||||
|
27
third_party/libosmium/cmake/FindOsmium.cmake
vendored
27
third_party/libosmium/cmake/FindOsmium.cmake
vendored
@ -224,8 +224,27 @@ if(Osmium_USE_SPARSEHASH)
|
||||
find_path(SPARSEHASH_INCLUDE_DIR google/sparsetable)
|
||||
|
||||
if(SPARSEHASH_INCLUDE_DIR)
|
||||
# Find size of sparsetable::size_type. This does not work on older
|
||||
# CMake versions because they can do this check only in C, not in C++.
|
||||
# Until we find a better way, we'll live with that.
|
||||
include(CheckTypeSize)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${SPARSEHASH_INCLUDE_DIR})
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES "google/sparsetable")
|
||||
check_type_size("google::sparsetable<int>::size_type" SPARSETABLE_SIZE_TYPE LANGUAGE CXX)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
# Sparsetable::size_type must be at least 8 bytes (64bit), otherwise
|
||||
# OSM object IDs will not fit.
|
||||
if(SPARSETABLE_SIZE_TYPE GREATER 7)
|
||||
set(SPARSEHASH_FOUND 1)
|
||||
add_definitions(-DOSMIUM_WITH_SPARSEHASH=${SPARSEHASH_FOUND})
|
||||
list(APPEND OSMIUM_INCLUDE_DIRS ${SPARSEHASH_INCLUDE_DIR})
|
||||
elseif(SPARSETABLE_SIZE_TYPE STREQUAL "")
|
||||
message(WARNING "Osmium: Disabled Google SparseHash library because we can't detect whether we are on a 64bit system.")
|
||||
else()
|
||||
message(WARNING "Osmium: Disabled Google SparseHash library on 32bit system (size_type=${SPARSETABLE_SIZE_TYPE}).")
|
||||
endif()
|
||||
else()
|
||||
set(_missing_libraries 1)
|
||||
message(WARNING "Osmium: Google SparseHash library is required but not found, please install it or configure the paths.")
|
||||
@ -270,12 +289,20 @@ add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-wd4996)
|
||||
|
||||
# Disable warning C4068: "unknown pragma" because we want it to ignore
|
||||
# pragmas for other compilers.
|
||||
add_definitions(-wd4068)
|
||||
|
||||
# Disable warning C4715: "not all control paths return a value" because
|
||||
# it generates too many false positives.
|
||||
add_definitions(-wd4715)
|
||||
|
||||
# Disable warning C4351: new behavior: elements of array '...' will be
|
||||
# default initialized. The new behaviour is correct and we don't support
|
||||
# old compilers anyway.
|
||||
add_definitions(-wd4351)
|
||||
|
||||
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
|
3
third_party/libosmium/cmake/README
vendored
Normal file
3
third_party/libosmium/cmake/README
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
FindGem.cmake from https://github.com/rock-core/base-cmake
|
||||
|
1
third_party/libosmium/doc/CMakeLists.txt
vendored
1
third_party/libosmium/doc/CMakeLists.txt
vendored
@ -13,6 +13,7 @@ find_package(Doxygen)
|
||||
|
||||
if(DOXYGEN_FOUND)
|
||||
message(STATUS "Looking for doxygen - found")
|
||||
configure_file(header.html ${CMAKE_CURRENT_BINARY_DIR}/header.html @ONLY)
|
||||
configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE}
|
||||
|
4
third_party/libosmium/doc/Doxyfile.in
vendored
4
third_party/libosmium/doc/Doxyfile.in
vendored
@ -152,7 +152,7 @@ FULL_PATH_NAMES = YES
|
||||
# will be relative from the directory where doxygen is started.
|
||||
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/include
|
||||
|
||||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
|
||||
# path mentioned in the documentation of a class, which tells the reader which
|
||||
@ -1047,7 +1047,7 @@ HTML_FILE_EXTENSION = .html
|
||||
# of the possible markers and block names see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_HEADER =
|
||||
HTML_HEADER = header.html
|
||||
|
||||
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
||||
# generated HTML page. If the tag is left blank doxygen will generate a standard
|
||||
|
8
third_party/libosmium/doc/README.md
vendored
Normal file
8
third_party/libosmium/doc/README.md
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
The `header.html` is created with:
|
||||
|
||||
`doxygen -w html header.html footer.html stylesheet.css`
|
||||
|
||||
This might have to be rn again for newer Doxygen versions. After that add
|
||||
changes back in.
|
||||
|
56
third_party/libosmium/doc/header.html
vendored
Normal file
56
third_party/libosmium/doc/header.html
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<!-- HTML header for doxygen 1.8.8-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
@ -18,12 +18,12 @@
|
||||
#include <osmium/handler/dump.hpp>
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_mem_table.hpp>
|
||||
#include <osmium/index/map/sparse_mem_array.hpp>
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
typedef osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location> index_neg_type;
|
||||
typedef osmium::index::map::SparseMemTable<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::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
class WKTDump : public osmium::handler::Handler {
|
||||
|
@ -15,9 +15,7 @@
|
||||
|
||||
// usually you only need one or two of these
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/map/sparse_mem_table.hpp>
|
||||
#include <osmium/index/map/sparse_mem_map.hpp>
|
||||
#include <osmium/index/map/sparse_mmap_array.hpp>
|
||||
#include <osmium/index/map/sparse_mem_array.hpp>
|
||||
|
||||
#include <osmium/handler/node_locations_for_ways.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
@ -32,9 +30,7 @@
|
||||
|
||||
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_pos_type;
|
||||
//typedef osmium::index::map::SparseMmapArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
typedef osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location> index_pos_type;
|
||||
|
||||
typedef osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type> location_handler_type;
|
||||
|
||||
|
@ -34,13 +34,13 @@
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
#define MAP_FAILED ((void *) -1)
|
||||
|
||||
#ifdef __USE_FILE_OFFSET64
|
||||
# define DWORD_HI(x) (x >> 32)
|
||||
# define DWORD_LO(x) ((x) & 0xffffffff)
|
||||
#else
|
||||
# define DWORD_HI(x) (0)
|
||||
# define DWORD_LO(x) (x)
|
||||
#endif
|
||||
static DWORD dword_hi(uint64_t x) {
|
||||
return static_cast<DWORD>(x >> 32);
|
||||
}
|
||||
|
||||
static DWORD dword_lo(uint64_t x) {
|
||||
return static_cast<DWORD>(x & 0xffffffff);
|
||||
}
|
||||
|
||||
static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
@ -66,13 +66,14 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t
|
||||
} else
|
||||
flProtect = PAGE_READONLY;
|
||||
|
||||
off_t end = length + offset;
|
||||
HANDLE mmap_fd, h;
|
||||
uint64_t end = static_cast<uint64_t>(length) + offset;
|
||||
HANDLE mmap_fd;
|
||||
if (fd == -1)
|
||||
mmap_fd = INVALID_HANDLE_VALUE;
|
||||
else
|
||||
mmap_fd = (HANDLE)_get_osfhandle(fd);
|
||||
h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
|
||||
|
||||
HANDLE h = CreateFileMapping(mmap_fd, NULL, flProtect, dword_hi(end), dword_lo(end), NULL);
|
||||
if (h == NULL)
|
||||
return MAP_FAILED;
|
||||
|
||||
@ -85,7 +86,7 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t
|
||||
dwDesiredAccess |= FILE_MAP_EXECUTE;
|
||||
if (flags & MAP_PRIVATE)
|
||||
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) {
|
||||
CloseHandle(h);
|
||||
ret = MAP_FAILED;
|
||||
@ -95,12 +96,8 @@ static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t
|
||||
|
||||
static int munmap(void *addr, size_t length)
|
||||
{
|
||||
UnmapViewOfFile(addr);
|
||||
return 0;
|
||||
return UnmapViewOfFile(addr) ? 0 : -1;
|
||||
/* ruh-ro, we leaked handle from CreateFileMapping() ... */
|
||||
}
|
||||
|
||||
#undef DWORD_HI
|
||||
#undef DWORD_LO
|
||||
|
||||
#endif
|
||||
|
@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef OSMIUM_WITH_SPARSEHASH
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -139,4 +141,6 @@ namespace osmium {
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_WITH_SPARSEHASH
|
||||
|
||||
#endif // OSMIUM_INDEX_BYID_SPARSE_MEM_TABLE_HPP
|
||||
|
@ -75,7 +75,7 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
static constexpr size_t input_buffer_size = 256 * 1024;
|
||||
static constexpr unsigned int input_buffer_size = 1024 * 1024;
|
||||
|
||||
Decompressor() = default;
|
||||
|
||||
@ -245,11 +245,11 @@ namespace osmium {
|
||||
}
|
||||
} else {
|
||||
buffer.resize(osmium::io::Decompressor::input_buffer_size);
|
||||
ssize_t nread = ::read(m_fd, const_cast<char*>(buffer.data()), buffer.size());
|
||||
auto nread = ::read(m_fd, const_cast<char*>(buffer.data()), osmium::io::Decompressor::input_buffer_size);
|
||||
if (nread < 0) {
|
||||
throw std::system_error(errno, std::system_category(), "Read failed");
|
||||
}
|
||||
buffer.resize(static_cast<size_t>(nread));
|
||||
buffer.resize(nread);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
@ -214,7 +214,12 @@ namespace osmium {
|
||||
if (!m_done || !m_queue.empty()) {
|
||||
std::future<osmium::memory::Buffer> buffer_future;
|
||||
m_queue.wait_and_pop(buffer_future);
|
||||
try {
|
||||
return buffer_future.get();
|
||||
} catch (...) {
|
||||
m_done = true;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return osmium::memory::Buffer();
|
||||
|
@ -43,7 +43,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# include <io.h>
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
|
||||
#include <osmium/io/overwrite.hpp>
|
||||
@ -123,9 +122,14 @@ namespace osmium {
|
||||
* @throws std::system_error On error.
|
||||
*/
|
||||
inline void reliable_write(const int fd, const unsigned char* output_buffer, const size_t size) {
|
||||
constexpr size_t max_write = 100 * 1024 * 1024; // Max 100 MByte per write
|
||||
size_t offset = 0;
|
||||
do {
|
||||
ssize_t length = ::write(fd, output_buffer + offset, size - offset);
|
||||
auto write_count = size - offset;
|
||||
if (write_count > max_write) {
|
||||
write_count = max_write;
|
||||
}
|
||||
auto length = ::write(fd, output_buffer + offset, static_cast<unsigned int>(write_count));
|
||||
if (length < 0) {
|
||||
throw std::system_error(errno, std::system_category(), "Write failed");
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <osmium/util/cast.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@ -48,19 +50,26 @@ namespace osmium {
|
||||
/**
|
||||
* Compress data using zlib.
|
||||
*
|
||||
* Note that this function can not compress data larger than
|
||||
* what fits in an unsigned long, on Windows this is usually 32bit.
|
||||
*
|
||||
* @param input Data to compress.
|
||||
* @returns Compressed data.
|
||||
*/
|
||||
inline std::string zlib_compress(const std::string& input) {
|
||||
unsigned long output_size = ::compressBound(input.size());
|
||||
unsigned long output_size = ::compressBound(osmium::static_cast_with_assert<unsigned long>(input.size()));
|
||||
|
||||
std::string output(output_size, '\0');
|
||||
|
||||
if (::compress(reinterpret_cast<unsigned char*>(const_cast<char *>(output.data())),
|
||||
auto result = ::compress(
|
||||
reinterpret_cast<unsigned char*>(const_cast<char *>(output.data())),
|
||||
&output_size,
|
||||
reinterpret_cast<const unsigned char*>(input.data()),
|
||||
input.size()) != Z_OK) {
|
||||
throw std::runtime_error("failed to compress data");
|
||||
osmium::static_cast_with_assert<unsigned long>(input.size())
|
||||
);
|
||||
|
||||
if (result != Z_OK) {
|
||||
throw std::runtime_error(std::string("failed to compress data: ") + zError(result));
|
||||
}
|
||||
|
||||
output.resize(output_size);
|
||||
@ -71,6 +80,9 @@ namespace osmium {
|
||||
/**
|
||||
* Uncompress data using zlib.
|
||||
*
|
||||
* Note that this function can not uncompress data larger than
|
||||
* what fits in an unsigned long, on Windows this is usually 32bit.
|
||||
*
|
||||
* @param input Compressed input data.
|
||||
* @param raw_size Size of uncompressed data.
|
||||
* @returns Uncompressed data.
|
||||
@ -78,11 +90,15 @@ namespace osmium {
|
||||
inline std::unique_ptr<std::string> zlib_uncompress(const std::string& input, unsigned long raw_size) {
|
||||
auto output = std::unique_ptr<std::string>(new std::string(raw_size, '\0'));
|
||||
|
||||
if (::uncompress(reinterpret_cast<unsigned char*>(const_cast<char *>(output->data())),
|
||||
auto result = ::uncompress(
|
||||
reinterpret_cast<unsigned char*>(const_cast<char *>(output->data())),
|
||||
&raw_size,
|
||||
reinterpret_cast<const unsigned char*>(input.data()),
|
||||
input.size()) != Z_OK) {
|
||||
throw std::runtime_error("failed to uncompress data");
|
||||
osmium::static_cast_with_assert<unsigned long>(input.size())
|
||||
);
|
||||
|
||||
if (result != Z_OK) {
|
||||
throw std::runtime_error(std::string("failed to uncompress data: ") + zError(result));
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -43,11 +43,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace thread {
|
||||
|
||||
constexpr std::chrono::milliseconds full_queue_sleep_duration { 10 }; // XXX
|
||||
OSMIUM_CONSTEXPR std::chrono::milliseconds full_queue_sleep_duration { 10 }; // XXX
|
||||
|
||||
/**
|
||||
* A thread-safe queue.
|
||||
|
@ -33,36 +33,66 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#ifndef assert
|
||||
# include <cassert>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<std::is_integral<T>::value && std::is_integral<F>::value && std::is_signed<T>::value && std::is_signed<F>::value, int>::type = 0>
|
||||
// These functions are wrappers around static_cast<>() that call assert()
|
||||
// to check that there is no integer overflow happening before doing the
|
||||
// cast. There are several versions of this templated function here
|
||||
// depending on the types of the input and output. In any case, both input
|
||||
// and output have to be integral types. If the cast can't overflow, no
|
||||
// check is done.
|
||||
|
||||
template <typename A, typename B>
|
||||
struct are_real_integers :
|
||||
std::integral_constant<bool,
|
||||
std::is_integral<A>::value &&
|
||||
std::is_integral<B>::value &&
|
||||
!std::is_same<A, bool>::value &&
|
||||
!std::is_same<B, bool>::value> {
|
||||
};
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && std::is_same<T, F>::value, int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && (sizeof(T) > sizeof(F)), int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && std::is_signed<T>::value == std::is_signed<F>::value && (sizeof(T) == sizeof(F)), int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && (sizeof(T) < sizeof(F)) && std::is_signed<T>::value && std::is_signed<F>::value, int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
static_assert(sizeof(T) < sizeof(F), "unnecessary static_cast_with_assert when casting into type of equal or larger size");
|
||||
assert(value >= std::numeric_limits<T>::min() && value <= std::numeric_limits<T>::max());
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<std::is_integral<T>::value && std::is_integral<F>::value && std::is_unsigned<T>::value && std::is_signed<F>::value, int>::type = 0>
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && (sizeof(T) <= sizeof(F)) && std::is_unsigned<T>::value && std::is_signed<F>::value, int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
static_assert(sizeof(T) <= sizeof(F), "unnecessary static_cast_with_assert when casting into type of larger size");
|
||||
assert(value >= 0 && static_cast<typename std::make_unsigned<F>::type>(value) <= std::numeric_limits<T>::max());
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<std::is_integral<T>::value && std::is_integral<F>::value && std::is_unsigned<T>::value && std::is_unsigned<F>::value, int>::type = 0>
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && (sizeof(T) < sizeof(F)) && std::is_unsigned<T>::value && std::is_unsigned<F>::value, int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
static_assert(sizeof(T) < sizeof(F), "unnecessary static_cast_with_assert when casting into type of equal or larger size");
|
||||
assert(value <= std::numeric_limits<T>::max());
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
template <typename T, typename F, typename std::enable_if<std::is_integral<T>::value && std::is_integral<F>::value && std::is_signed<T>::value && std::is_unsigned<F>::value, int>::type = 0>
|
||||
template <typename T, typename F, typename std::enable_if<are_real_integers<T, F>::value && !std::is_same<T, F>::value && (sizeof(T) <= sizeof(F)) && std::is_signed<T>::value && std::is_unsigned<F>::value, int>::type = 0>
|
||||
inline T static_cast_with_assert(const F value) {
|
||||
static_assert(sizeof(T) <= sizeof(F), "unnecessary static_cast_with_assert when casting into type of larger size");
|
||||
assert(value <= std::numeric_limits<T>::max());
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
|
3
third_party/libosmium/test/CMakeLists.txt
vendored
3
third_party/libosmium/test/CMakeLists.txt
vendored
@ -109,6 +109,9 @@ add_unit_test(tags test_filter)
|
||||
add_unit_test(tags test_operators)
|
||||
add_unit_test(tags test_tag_list)
|
||||
|
||||
add_unit_test(thread test_pool ${Threads_FOUND} ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
add_unit_test(util test_cast_with_assert)
|
||||
add_unit_test(util test_double)
|
||||
add_unit_test(util test_options)
|
||||
add_unit_test(util test_string)
|
||||
|
@ -87,32 +87,29 @@ set_tests_properties(testdata-overview PROPERTIES
|
||||
# multipolygon
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
add_executable(testdata-multipolygon testdata-multipolygon.cpp)
|
||||
target_link_libraries(testdata-multipolygon
|
||||
|
||||
find_package(Ruby 1.9)
|
||||
find_package(Gem COMPONENTS json)
|
||||
find_program(SPATIALITE spatialite)
|
||||
|
||||
if(RUBY_FOUND AND GEM_json_FOUND AND SPATIALITE)
|
||||
add_executable(testdata-multipolygon testdata-multipolygon.cpp)
|
||||
target_link_libraries(testdata-multipolygon
|
||||
${OSMIUM_XML_LIBRARIES}
|
||||
${GDAL_LIBRARIES}
|
||||
)
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.bat")
|
||||
add_test(NAME testdata-multipolygon
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D OSM_TESTDATA=${OSM_TESTDATA}
|
||||
-D RUBY=${RUBY_EXECUTABLE}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/run-testdata-multipolygon.cmake)
|
||||
|
||||
set_tests_properties(testdata-multipolygon PROPERTIES LABELS "data;slow")
|
||||
else()
|
||||
set(MULTIPOLYGON_TEST_SCRIPT "run-testdata-multipolygon.sh")
|
||||
message(WARNING "Disabled testdata-multipolygon test because 'ruby' and/or 'json' ruby gem and/or 'spatialite' was not found")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(EXE_DIR ${CMAKE_BUILD_TYPE})
|
||||
else()
|
||||
set(EXE_DIR .)
|
||||
endif()
|
||||
|
||||
add_test(NAME testdata-multipolygon
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/test/data-tests/${MULTIPOLYGON_TEST_SCRIPT}
|
||||
${OSM_TESTDATA}
|
||||
${EXE_DIR}
|
||||
)
|
||||
set_tests_properties(testdata-multipolygon PROPERTIES
|
||||
LABELS "data;slow")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
message(STATUS "Configuring data tests - done")
|
||||
|
17
third_party/libosmium/test/data-tests/README.md
vendored
17
third_party/libosmium/test/data-tests/README.md
vendored
@ -5,19 +5,6 @@ repository at https://github.com/osmcode/osm-testdata . To use it, clone
|
||||
the `osm-testdata` repository in the same directory where you cloned the
|
||||
`libosmium` repository.
|
||||
|
||||
## Overview
|
||||
|
||||
The `testdata-overview` program can be used to create a Spatialite file
|
||||
containing all the nodes and ways from the test data files.
|
||||
|
||||
Compile it by running `make testdata-overview`, run it my calling
|
||||
`make overview`.
|
||||
|
||||
## Running the Tests
|
||||
|
||||
Actual tests are in `testcases` subdirectory, one per test from the
|
||||
osm-testdata repository.
|
||||
|
||||
To compile the tests, call `make runtests`, to run them call
|
||||
`make test`.
|
||||
Tests will be built if the CMake option `BUILD_DATA_TESTS` is set and run as
|
||||
part of the `ctest` run.
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
set TESTDATA_DIR=%1
|
||||
|
||||
del multipolygon.db multipolygon-tests.json
|
||||
%2\testdata-multipolygon %TESTDATA_DIR%\grid\data\all.osm >multipolygon.log 2>&1
|
||||
if ERRORLEVEL 1 (exit /b 1)
|
||||
ruby %TESTDATA_DIR%\bin\compare-areas.rb %TESTDATA_DIR%\grid\data\tests.json multipolygon-tests.json
|
||||
if ERRORLEVEL 1 (exit /b 1)
|
46
third_party/libosmium/test/data-tests/run-testdata-multipolygon.cmake
vendored
Normal file
46
third_party/libosmium/test/data-tests/run-testdata-multipolygon.cmake
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Helper script that runs the 'multipolygon' test.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Remove files that might be left over from previous run
|
||||
file(REMOVE multipolygon.db multipolygon-tests.json)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Create multipolygons from test data.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testdata-multipolygon
|
||||
${OSM_TESTDATA}/grid/data/all.osm
|
||||
RESULT_VARIABLE _result
|
||||
OUTPUT_FILE multipolygon.log
|
||||
ERROR_FILE multipolygon.log
|
||||
)
|
||||
|
||||
if(_result)
|
||||
message(FATAL_ERROR "Error running testdata-multipolygon command")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Compare created multipolygons with reference data.
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
execute_process(
|
||||
COMMAND ${RUBY} ${OSM_TESTDATA}/bin/compare-areas.rb
|
||||
${OSM_TESTDATA}/grid/data/tests.json
|
||||
multipolygon-tests.json
|
||||
RESULT_VARIABLE _result
|
||||
)
|
||||
|
||||
if(_result)
|
||||
message(FATAL_ERROR "Error running compare-areas command")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# helper script needed by cmake to run test
|
||||
|
||||
TESTDATA_DIR=$1
|
||||
|
||||
rm -f multipolygon.db multipolygon-tests.json
|
||||
./testdata-multipolygon ${TESTDATA_DIR}/grid/data/all.osm >multipolygon.log 2>&1 &&
|
||||
${TESTDATA_DIR}/bin/compare-areas.rb ${TESTDATA_DIR}/grid/data/tests.json multipolygon-tests.json
|
||||
|
@ -46,7 +46,7 @@ std::string read_file(const char* test_id) {
|
||||
assert(fd >= 0);
|
||||
|
||||
std::string input(10000, '\0');
|
||||
ssize_t n = ::read(fd, reinterpret_cast<unsigned char*>(const_cast<char*>(input.data())), 10000);
|
||||
auto n = ::read(fd, reinterpret_cast<unsigned char*>(const_cast<char*>(input.data())), 10000);
|
||||
assert(n >= 0);
|
||||
input.resize(static_cast<std::string::size_type>(n));
|
||||
|
||||
|
@ -108,6 +108,8 @@ SECTION("DenseFileArray") {
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
#ifdef OSMIUM_WITH_SPARSEHASH
|
||||
|
||||
SECTION("SparseMemTable") {
|
||||
typedef osmium::index::map::SparseMemTable<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
@ -118,6 +120,8 @@ SECTION("SparseMemTable") {
|
||||
test_func_real<index_type>(index2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SECTION("SparseMemMap") {
|
||||
typedef osmium::index::map::SparseMemMap<osmium::unsigned_object_id_type, osmium::Location> index_type;
|
||||
|
||||
|
@ -53,10 +53,9 @@ SECTION("Remap") {
|
||||
|
||||
SECTION("FileSize") {
|
||||
const int size = 100;
|
||||
char filename[] = "/tmp/osmium_unit_test_XXXXXX";
|
||||
char filename[] = "test_mmap_file_size_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
REQUIRE(0 == unlink(filename));
|
||||
REQUIRE(0 == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
REQUIRE(0 == ftruncate(fd, size * sizeof(uint64_t)));
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
@ -69,14 +68,16 @@ SECTION("FileSize") {
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::grow_file(size * 2, fd);
|
||||
REQUIRE((size * 2) == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
|
||||
SECTION("GrowAndMap") {
|
||||
const int size = 100;
|
||||
char filename[] = "/tmp/osmium_unit_test_XXXXXX";
|
||||
char filename[] = "test_mmap_grow_and_map_XXXXXX";
|
||||
const int fd = mkstemp(filename);
|
||||
REQUIRE(fd > 0);
|
||||
REQUIRE(0 == unlink(filename));
|
||||
|
||||
uint64_t* data = osmium::detail::typed_mmap<uint64_t>::grow_and_map(size, fd);
|
||||
REQUIRE(size == osmium::detail::typed_mmap<uint64_t>::file_size(fd));
|
||||
@ -90,6 +91,9 @@ SECTION("GrowAndMap") {
|
||||
REQUIRE(27ul == data[99]);
|
||||
|
||||
osmium::detail::typed_mmap<uint64_t>::unmap(data, size);
|
||||
|
||||
REQUIRE(0 == close(fd));
|
||||
REQUIRE(0 == unlink(filename));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ TEST_CASE("Reader") {
|
||||
|
||||
const size_t buffer_size = 1000;
|
||||
char buffer[buffer_size];
|
||||
ssize_t length = ::read(fd, buffer, buffer_size);
|
||||
auto length = ::read(fd, buffer, buffer_size);
|
||||
REQUIRE(length > 0);
|
||||
|
||||
osmium::io::File file(buffer, static_cast<size_t>(length), "osm");
|
||||
@ -83,7 +83,7 @@ TEST_CASE("Reader") {
|
||||
|
||||
const size_t buffer_size = 1000;
|
||||
char buffer[buffer_size];
|
||||
ssize_t length = ::read(fd, buffer, buffer_size);
|
||||
auto length = ::read(fd, buffer, buffer_size);
|
||||
REQUIRE(length > 0);
|
||||
|
||||
osmium::io::File file(buffer, static_cast<size_t>(length), "osm.gz");
|
||||
@ -101,7 +101,7 @@ TEST_CASE("Reader") {
|
||||
|
||||
const size_t buffer_size = 1000;
|
||||
char buffer[buffer_size];
|
||||
ssize_t length = ::read(fd, buffer, buffer_size);
|
||||
auto length = ::read(fd, buffer, buffer_size);
|
||||
REQUIRE(length > 0);
|
||||
|
||||
osmium::io::File file(buffer, static_cast<size_t>(length), "osm.bz2");
|
||||
|
69
third_party/libosmium/test/t/thread/test_pool.cpp
vendored
Normal file
69
third_party/libosmium/test/t/thread/test_pool.cpp
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <stdexcept>
|
||||
#include <thread>
|
||||
|
||||
#include <osmium/thread/pool.hpp>
|
||||
|
||||
static std::atomic<int> result;
|
||||
|
||||
struct test_job_ok {
|
||||
void operator()() const {
|
||||
result = 1;
|
||||
}
|
||||
};
|
||||
|
||||
struct test_job_with_result {
|
||||
int operator()() const {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
|
||||
struct test_job_throw {
|
||||
void operator()() const {
|
||||
throw std::runtime_error("exception in pool thread");
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("thread") {
|
||||
|
||||
SECTION("can get access to thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
REQUIRE(pool.queue_empty());
|
||||
}
|
||||
|
||||
SECTION("can send job to thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
result = 0;
|
||||
auto future = pool.submit(test_job_ok{});
|
||||
|
||||
// wait a bit for the other thread to get a chance to run
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
REQUIRE(result == 1);
|
||||
|
||||
future.get();
|
||||
|
||||
REQUIRE(true);
|
||||
}
|
||||
|
||||
SECTION("can send job to thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
auto future = pool.submit(test_job_with_result{});
|
||||
|
||||
REQUIRE(future.get() == 42);
|
||||
}
|
||||
|
||||
SECTION("can throw from job in thread pool") {
|
||||
auto& pool = osmium::thread::Pool::instance();
|
||||
result = 0;
|
||||
|
||||
bool got_exception = false;
|
||||
auto future = pool.submit(test_job_throw{});
|
||||
|
||||
REQUIRE_THROWS_AS(future.get(), std::runtime_error);
|
||||
}
|
||||
|
||||
}
|
||||
|
89
third_party/libosmium/test/t/util/test_cast_with_assert.cpp
vendored
Normal file
89
third_party/libosmium/test/t/util/test_cast_with_assert.cpp
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
// Define assert() to throw this error. This enables the tests to check that
|
||||
// the assert() fails.
|
||||
struct assert_error : public std::runtime_error {
|
||||
assert_error(const char* what_arg) : std::runtime_error(what_arg) {
|
||||
}
|
||||
};
|
||||
#define assert(x) if (!(x)) { throw(assert_error(#x)); }
|
||||
|
||||
#include <osmium/util/cast.hpp>
|
||||
|
||||
TEST_CASE("static_cast_with_assert") {
|
||||
|
||||
SECTION("same types is always okay") {
|
||||
int f = 10;
|
||||
auto t = osmium::static_cast_with_assert<int>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("casting to larger type is always okay") {
|
||||
int16_t f = 10;
|
||||
auto t = osmium::static_cast_with_assert<int32_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
|
||||
SECTION("cast int32_t -> int_16t should not trigger assert for small int") {
|
||||
int32_t f = 100;
|
||||
auto t = osmium::static_cast_with_assert<int16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast int32_t -> int_16t should trigger assert for large int") {
|
||||
int32_t f = 100000;
|
||||
REQUIRE_THROWS_AS(osmium::static_cast_with_assert<int16_t>(f), assert_error);
|
||||
}
|
||||
|
||||
|
||||
SECTION("cast int16_t -> uint16_t should not trigger assert for zero") {
|
||||
int16_t f = 0;
|
||||
auto t = osmium::static_cast_with_assert<uint16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast int16_t -> uint16_t should not trigger assert for positive int") {
|
||||
int16_t f = 1;
|
||||
auto t = osmium::static_cast_with_assert<uint16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast int16_t -> uint16_t should trigger assert for negative int") {
|
||||
int16_t f = -1;
|
||||
REQUIRE_THROWS_AS(osmium::static_cast_with_assert<uint16_t>(f), assert_error);
|
||||
}
|
||||
|
||||
|
||||
SECTION("cast uint32_t -> uint_16t should not trigger assert for zero") {
|
||||
uint32_t f = 0;
|
||||
auto t = osmium::static_cast_with_assert<uint16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast uint32_t -> uint_16t should not trigger assert for small int") {
|
||||
uint32_t f = 100;
|
||||
auto t = osmium::static_cast_with_assert<uint16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast int32_t -> int_16t should trigger assert for large int") {
|
||||
uint32_t f = 100000;
|
||||
REQUIRE_THROWS_AS(osmium::static_cast_with_assert<uint16_t>(f), assert_error);
|
||||
}
|
||||
|
||||
|
||||
SECTION("cast uint16_t -> int16_t should not trigger assert for small int") {
|
||||
uint16_t f = 1;
|
||||
auto t = osmium::static_cast_with_assert<int16_t>(f);
|
||||
REQUIRE(t == f);
|
||||
}
|
||||
|
||||
SECTION("cast uint16_t -> int16_t should trigger assert for large int") {
|
||||
uint16_t f = 65000;
|
||||
REQUIRE_THROWS_AS(osmium::static_cast_with_assert<int16_t>(f), assert_error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user