Merge branch 'master' of github.com:Project-OSRM/osrm-backend

This commit is contained in:
Leigh Hunt 2020-09-02 09:52:01 +12:00
commit 3116734bec
66 changed files with 1191 additions and 607 deletions

8
.gitignore vendored
View File

@ -49,7 +49,7 @@ Thumbs.db
/_build* /_build*
/build/ /build/
/example/build/ /example/build/
/test/data/monaco* /test/data/monaco.osrm*
/test/data/ch /test/data/ch
/test/data/corech /test/data/corech
/test/data/mld /test/data/mld
@ -72,12 +72,6 @@ Thumbs.db
########################### ###########################
.idea/ .idea/
# stxxl related files #
#######################
.stxxl
stxxl.log
stxxl.errlog
# Compiled Binary Files # # Compiled Binary Files #
#################################### ####################################
/osrm-extract /osrm-extract

View File

@ -121,6 +121,14 @@ matrix:
packages: ['libstdc++-4.9-dev'] packages: ['libstdc++-4.9-dev']
env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON RUN_CLANG_FORMAT=ON ENABLE_LTO=ON env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON RUN_CLANG_FORMAT=ON ENABLE_LTO=ON
- os: linux
compiler: "gcc-9-release"
addons: &gcc9
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
env: CCOMPILER='gcc-9' CXXCOMPILER='g++-9' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type'
- os: linux - os: linux
compiler: "gcc-8-release" compiler: "gcc-8-release"
addons: &gcc8 addons: &gcc8
@ -143,14 +151,6 @@ matrix:
TARGET_ARCH='i686' CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' TARGET_ARCH='i686' CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release'
CFLAGS='-m32 -msse2 -mfpmath=sse' CXXFLAGS='-m32 -msse2 -mfpmath=sse' CFLAGS='-m32 -msse2 -mfpmath=sse' CXXFLAGS='-m32 -msse2 -mfpmath=sse'
- os: linux
compiler: "gcc-7-stxxl"
addons: &gcc7
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7', 'libbz2-dev', 'libstxxl-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' ENABLE_STXXL=On
- os: linux - os: linux
compiler: "gcc-5-release" compiler: "gcc-5-release"
addons: &gcc49 addons: &gcc49
@ -475,7 +475,6 @@ install:
-DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \ -DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
-DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \ -DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \
-DENABLE_STXXL=${ENABLE_STXXL:-OFF} \
-DBUILD_TOOLS=ON \ -DBUILD_TOOLS=ON \
-DENABLE_CCACHE=ON \ -DENABLE_CCACHE=ON \
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \

View File

@ -2,18 +2,27 @@
- Changes from 5.21.0 - Changes from 5.21.0
- Build: - Build:
- ADDED: optionally build Node `lts` and `latest` bindings [#5347](https://github.com/Project-OSRM/osrm-backend/pull/5347) - ADDED: optionally build Node `lts` and `latest` bindings [#5347](https://github.com/Project-OSRM/osrm-backend/pull/5347)
- FIXED: pessimistic calls to std::move [#5560](https://github.com/Project-OSRM/osrm-backend/pull/5561)
- Features: - Features:
- ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345) - ADDED: new waypoints parameter to the `route` plugin, enabling silent waypoints [#5345](https://github.com/Project-OSRM/osrm-backend/pull/5345)
- ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115) - ADDED: data timestamp information in the response (saved in new file `.osrm.timestamp`). [#5115](https://github.com/Project-OSRM/osrm-backend/issues/5115)
- ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361) - ADDED: new API parameter - `snapping=any|default` to allow snapping to previously unsnappable edges [#5361](https://github.com/Project-OSRM/osrm-backend/pull/5361)
- ADDED: keepalive support to the osrm-routed HTTP server [#5518](https://github.com/Project-OSRM/osrm-backend/pull/5518) - ADDED: keepalive support to the osrm-routed HTTP server [#5518](https://github.com/Project-OSRM/osrm-backend/pull/5518)
- ADDED: flatbuffers output format support [#5513](https://github.com/Project-OSRM/osrm-backend/pull/5513) - ADDED: flatbuffers output format support [#5513](https://github.com/Project-OSRM/osrm-backend/pull/5513)
- ADDED: Global 'skip_waypoints' option [#5556](https://github.com/Project-OSRM/osrm-backend/pull/5556)
- FIXED: Install the libosrm_guidance library correctly [#5604](https://github.com/Project-OSRM/osrm-backend/pull/5604)
- FIXED: Http Handler can now deal witch optional whitespace between header-key and -value [#5606](https://github.com/Project-OSRM/osrm-backend/issues/5606)
- Routing: - Routing:
- CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352) - CHANGED: allow routing past `barrier=arch` [#5352](https://github.com/Project-OSRM/osrm-backend/pull/5352)
- CHANGED: default car weight was reduced to 2000 kg. [#5371](https://github.com/Project-OSRM/osrm-backend/pull/5371) - CHANGED: default car weight was reduced to 2000 kg. [#5371](https://github.com/Project-OSRM/osrm-backend/pull/5371)
- CHANGED: default car height was reduced to 2 meters. [#5389](https://github.com/Project-OSRM/osrm-backend/pull/5389) - CHANGED: default car height was reduced to 2 meters. [#5389](https://github.com/Project-OSRM/osrm-backend/pull/5389)
- FIXED: treat `bicycle=use_sidepath` as no access on the tagged way. [#5622](https://github.com/Project-OSRM/osrm-backend/pull/5622)
- Misc:
- CHANGED: Reduce memory usage for raster source handling. [#5572](https://github.com/Project-OSRM/osrm-backend/pull/5572)
- CHANGED: Add cmake option `ENABLE_DEBUG_LOGGING` to control whether output debug logging. [#3427](https://github.com/Project-OSRM/osrm-backend/issues/3427)
- CHANGED: updated extent of Hong Kong as left hand drive country. [#5535](https://github.com/Project-OSRM/osrm-backend/issues/5535) - CHANGED: updated extent of Hong Kong as left hand drive country. [#5535](https://github.com/Project-OSRM/osrm-backend/issues/5535)
- Infrastructure
- REMOVED: STXXL support removed as STXXL became abandonware. [#5760](https://github.com/Project-OSRM/osrm-backend/pull/5760)
# 5.21.0 # 5.21.0
- Changes from 5.20.0 - Changes from 5.20.0
- Features: - Features:

View File

@ -23,9 +23,9 @@ option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON)
option(BUILD_TOOLS "Build OSRM tools" OFF) option(BUILD_TOOLS "Build OSRM tools" OFF)
option(BUILD_PACKAGE "Build OSRM package" OFF) option(BUILD_PACKAGE "Build OSRM package" OFF)
option(ENABLE_ASSERTIONS "Use assertions in release mode" OFF) option(ENABLE_ASSERTIONS "Use assertions in release mode" OFF)
option(ENABLE_DEBUG_LOGGING "Use debug logging in release mode" OFF)
option(ENABLE_COVERAGE "Build with coverage instrumentalisation" OFF) option(ENABLE_COVERAGE "Build with coverage instrumentalisation" OFF)
option(ENABLE_SANITIZER "Use memory sanitizer for Debug build" OFF) option(ENABLE_SANITIZER "Use memory sanitizer for Debug build" OFF)
option(ENABLE_STXXL "Use STXXL library" OFF)
option(ENABLE_LTO "Use LTO if available" OFF) option(ENABLE_LTO "Use LTO if available" OFF)
option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF) option(ENABLE_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF)
option(ENABLE_GOLD_LINKER "Use GNU gold linker if available" ON) option(ENABLE_GOLD_LINKER "Use GNU gold linker if available" ON)
@ -37,7 +37,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(ENABLE_MASON) if(ENABLE_MASON)
# versions in use # versions in use
set(MASON_BOOST_VERSION "1.65.1") set(MASON_BOOST_VERSION "1.65.1")
set(MASON_STXXL_VERSION "1.4.1-1")
set(MASON_EXPAT_VERSION "2.2.0") set(MASON_EXPAT_VERSION "2.2.0")
set(MASON_LUA_VERSION "5.2.4") set(MASON_LUA_VERSION "5.2.4")
set(MASON_BZIP2_VERSION "1.0.6") set(MASON_BZIP2_VERSION "1.0.6")
@ -57,6 +56,12 @@ endif()
if (POLICY CMP0048) if (POLICY CMP0048)
cmake_policy(SET CMP0048 OLD) cmake_policy(SET CMP0048 OLD)
endif() endif()
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
project(OSRM C CXX) project(OSRM C CXX)
include(JSONParser) include(JSONParser)
@ -227,6 +232,7 @@ endif()
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message(STATUS "Configuring debug mode flags") message(STATUS "Configuring debug mode flags")
set(ENABLE_ASSERTIONS ON) set(ENABLE_ASSERTIONS ON)
set(ENABLE_DEBUG_LOGGING ON)
endif() endif()
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@ -472,13 +478,6 @@ if(ENABLE_MASON)
mason_use(boost_libsystem VERSION ${MASON_BOOST_VERSION}) mason_use(boost_libsystem VERSION ${MASON_BOOST_VERSION})
set(Boost_SYSTEM_LIBRARY ${MASON_PACKAGE_boost_libsystem_STATIC_LIBS}) set(Boost_SYSTEM_LIBRARY ${MASON_PACKAGE_boost_libsystem_STATIC_LIBS})
if (ENABLE_STXXL)
mason_use(stxxl VERSION ${MASON_STXXL_VERSION})
add_dependency_includes(${MASON_PACKAGE_stxxl_INCLUDE_DIRS})
set(MAYBE_STXXL_LIBRARY ${MASON_PACKAGE_stxxl_STATIC_LIBS})
add_definitions(-DUSE_STXXL_LIBRARY)
endif()
mason_use(expat VERSION ${MASON_EXPAT_VERSION}) mason_use(expat VERSION ${MASON_EXPAT_VERSION})
add_dependency_includes(${MASON_PACKAGE_expat_INCLUDE_DIRS}) add_dependency_includes(${MASON_PACKAGE_expat_INCLUDE_DIRS})
set(EXPAT_LIBRARIES ${MASON_PACKAGE_expat_STATIC_LIBS}) set(EXPAT_LIBRARIES ${MASON_PACKAGE_expat_STATIC_LIBS})
@ -524,30 +523,16 @@ else()
find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS}) find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
add_dependency_includes(${Boost_INCLUDE_DIRS}) add_dependency_includes(${Boost_INCLUDE_DIRS})
if(WIN32 AND Boost_VERSION VERSION_LESS 106200)
message(FATAL_ERROR "Building with MSVC needs Boost 1.62 with CXX11_CONSTEXPR support")
endif()
find_package(TBB REQUIRED) find_package(TBB REQUIRED)
add_dependency_includes(${TBB_INCLUDE_DIR}) add_dependency_includes(${TBB_INCLUDE_DIR})
if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug) if(WIN32)
set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES}) set(TBB_LIBRARIES optimized ${TBB_LIBRARY} optimized ${TBB_MALLOC_LIBRARY} debug ${TBB_LIBRARY_DEBUG} debug ${TBB_MALLOC_LIBRARY_DEBUG})
endif() endif()
find_package(EXPAT REQUIRED) find_package(EXPAT REQUIRED)
add_dependency_includes(${EXPAT_INCLUDE_DIRS}) add_dependency_includes(${EXPAT_INCLUDE_DIRS})
if (ENABLE_STXXL)
find_package(STXXL)
if (STXXL_FOUND)
add_dependency_includes(${STXXL_INCLUDE_DIR})
set(MAYBE_STXXL_LIBRARY ${STXXL_LIBRARY})
add_definitions(-DUSE_STXXL_LIBRARY)
else()
MESSAGE(STATUS "STXXL was requested but not found, default STL will be used")
endif()
endif()
find_package(BZip2 REQUIRED) find_package(BZip2 REQUIRED)
add_dependency_includes(${BZIP2_INCLUDE_DIR}) add_dependency_includes(${BZIP2_INCLUDE_DIR})
@ -607,15 +592,6 @@ add_dependency_defines(-DBOOST_SPIRIT_USE_PHOENIX_V3)
add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE) add_dependency_defines(-DBOOST_RESULT_OF_USE_DECLTYPE)
add_dependency_defines(-DBOOST_FILESYSTEM_NO_DEPRECATED) add_dependency_defines(-DBOOST_FILESYSTEM_NO_DEPRECATED)
if (ENABLE_STXXL)
set(OpenMP_FIND_QUIETLY ON)
find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "OpenMP support found. Linking just in case for stxxl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
endif()
add_definitions(${OSRM_DEFINES}) add_definitions(${OSRM_DEFINES})
include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS}) include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS})
@ -648,7 +624,6 @@ set(EXTRACTOR_LIBRARIES
${EXPAT_LIBRARIES} ${EXPAT_LIBRARIES}
${USED_LUA_LIBRARIES} ${USED_LUA_LIBRARIES}
${OSMIUM_LIBRARIES} ${OSMIUM_LIBRARIES}
${MAYBE_STXXL_LIBRARY}
${TBB_LIBRARIES} ${TBB_LIBRARIES}
${ZLIB_LIBRARY} ${ZLIB_LIBRARY}
${MAYBE_COVERAGE_LIBRARIES}) ${MAYBE_COVERAGE_LIBRARIES})
@ -682,7 +657,6 @@ set(CONTRACTOR_LIBRARIES
${BOOST_BASE_LIBRARIES} ${BOOST_BASE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${USED_LUA_LIBRARIES} ${USED_LUA_LIBRARIES}
${MAYBE_STXXL_LIBRARY}
${TBB_LIBRARIES} ${TBB_LIBRARIES}
${MAYBE_RT_LIBRARY} ${MAYBE_RT_LIBRARY}
${MAYBE_COVERAGE_LIBRARIES}) ${MAYBE_COVERAGE_LIBRARIES})
@ -702,7 +676,6 @@ set(STORAGE_LIBRARIES
set(UTIL_LIBRARIES set(UTIL_LIBRARIES
${BOOST_BASE_LIBRARIES} ${BOOST_BASE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${MAYBE_STXXL_LIBRARY}
${TBB_LIBRARIES} ${TBB_LIBRARIES}
${MAYBE_COVERAGE_LIBRARIES} ${MAYBE_COVERAGE_LIBRARIES}
${ZLIB_LIBRARY}) ${ZLIB_LIBRARY})
@ -734,6 +707,11 @@ if (ENABLE_ASSERTIONS)
add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER) add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER)
endif() endif()
if (ENABLE_DEBUG_LOGGING)
message(STATUS "Enabling debug logging")
add_definitions(-DENABLE_DEBUG_LOGGING)
endif()
# Add RPATH info to executables so that when they are run after being installed # Add RPATH info to executables so that when they are run after being installed
# (i.e., from /usr/local/bin/) the linker can find library dependencies. For # (i.e., from /usr/local/bin/) the linker can find library dependencies. For
# more info see http://www.cmake.org/Wiki/CMake_RPATH_handling # more info see http://www.cmake.org/Wiki/CMake_RPATH_handling
@ -778,6 +756,7 @@ install(TARGETS osrm_customize DESTINATION lib)
install(TARGETS osrm_update DESTINATION lib) install(TARGETS osrm_update DESTINATION lib)
install(TARGETS osrm_contract DESTINATION lib) install(TARGETS osrm_contract DESTINATION lib)
install(TARGETS osrm_store DESTINATION lib) install(TARGETS osrm_store DESTINATION lib)
install(TARGETS osrm_guidance DESTINATION lib)
# Install profiles and support library to /usr/local/share/osrm/profiles by default # Install profiles and support library to /usr/local/share/osrm/profiles by default

View File

@ -10,7 +10,7 @@ ECHO NUMBER_OF_PROCESSORS^: %NUMBER_OF_PROCESSORS%
:: Check CMake version :: Check CMake version
SET CMAKE_VERSION=3.9.2 SET CMAKE_VERSION=3.16.3
SET PATH=%PROJECT_DIR%\cmake-%CMAKE_VERSION%-win32-x86\bin;%PATH% SET PATH=%PROJECT_DIR%\cmake-%CMAKE_VERSION%-win32-x86\bin;%PATH%
ECHO cmake^: && cmake --version ECHO cmake^: && cmake --version
IF %ERRORLEVEL% NEQ 0 ECHO CMAKE not found && GOTO CMAKE_NOT_OK IF %ERRORLEVEL% NEQ 0 ECHO CMAKE not found && GOTO CMAKE_NOT_OK
@ -19,7 +19,7 @@ cmake --version | findstr /C:%CMAKE_VERSION% && GOTO CMAKE_OK
:CMAKE_NOT_OK :CMAKE_NOT_OK
ECHO CMAKE NOT OK - downloading new CMake %CMAKE_VERSION% ECHO CMAKE NOT OK - downloading new CMake %CMAKE_VERSION%
powershell Invoke-WebRequest https://cmake.org/files/v3.9/cmake-%CMAKE_VERSION%-win32-x86.zip -OutFile $env:PROJECT_DIR\cm.zip powershell Invoke-WebRequest https://cmake.org/files/v3.16/cmake-%CMAKE_VERSION%-win32-x86.zip -OutFile $env:PROJECT_DIR\cm.zip
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
IF NOT EXIST cmake-%CMAKE_VERSION%-win32-x86 7z -y x cm.zip | %windir%\system32\FIND "ing archive" IF NOT EXIST cmake-%CMAKE_VERSION%-win32-x86 7z -y x cm.zip | %windir%\system32\FIND "ing archive"
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
@ -29,8 +29,8 @@ ECHO CMAKE_OK
cmake --version cmake --version
ECHO activating VS command prompt ... ECHO activating VS command prompt ...
SET PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% SET PATH=C:\Program Files (x86)\MSBuild\15.0\Bin;%PATH%
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
ECHO platform^: %platform% ECHO platform^: %platform%
@ -40,7 +40,7 @@ ECHO msbuild version
msbuild /version msbuild /version
:: HARDCODE "x64" as it is uppercase on AppVeyor and download from S3 is case sensitive :: HARDCODE "x64" as it is uppercase on AppVeyor and download from S3 is case sensitive
SET DEPSPKG=osrm-deps-win-x64-14.0-2017.09.7z SET DEPSPKG=osrm-deps-win-x64-14.2-2019.01.7z
:: local development :: local development
ECHO. ECHO.
@ -52,7 +52,7 @@ IF EXIST %DEPSPKG% DEL %DEPSPKG%
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
ECHO downloading %DEPSPKG% ECHO downloading %DEPSPKG%
powershell Invoke-WebRequest https://mapbox.s3.amazonaws.com/windows-builds/windows-build-deps/$env:DEPSPKG -OutFile $env:PROJECT_DIR\$env:DEPSPKG powershell Invoke-WebRequest http://project-osrm.wolt.com/windows-build-deps/$env:DEPSPKG -OutFile $env:PROJECT_DIR\$env:DEPSPKG
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
:SKIPDL :SKIPDL
@ -74,27 +74,35 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR
SET OSRMDEPSDIR=%PROJECT_DIR%/osrm-deps SET OSRMDEPSDIR=%PROJECT_DIR%/osrm-deps
set PREFIX=%OSRMDEPSDIR%/libs set PREFIX=%OSRMDEPSDIR%/libs
set BOOST_ROOT=%OSRMDEPSDIR%/boost set BOOST_ROOT=%OSRMDEPSDIR%
set BOOST_LIBRARYDIR=%BOOST_ROOT%/lib set BOOST_LIBRARYDIR=%BOOST_ROOT%/lib
set TBB_INSTALL_DIR=%OSRMDEPSDIR%/tbb set TBB_INSTALL_DIR=%OSRMDEPSDIR%
set TBB_ARCH_PLATFORM=intel64/vc14 REM set TBB_ARCH_PLATFORM=intel64/vc17
ECHO OSRMDEPSDIR ^: %OSRMDEPSDIR% ECHO OSRMDEPSDIR ^: %OSRMDEPSDIR%
ECHO PREFIX ^: %PREFIX% ECHO PREFIX ^: %PREFIX%
ECHO BOOST_ROOT ^: %BOOST_ROOT% ECHO BOOST_ROOT ^: %BOOST_ROOT%
ECHO BOOST_LIBRARYDIR ^: %BOOST_LIBRARYDIR% ECHO BOOST_LIBRARYDIR ^: %BOOST_LIBRARYDIR%
ECHO TBB_INSTALL_DIR ^: %TBB_INSTALL_DIR% ECHO TBB_INSTALL_DIR ^: %TBB_INSTALL_DIR%
ECHO TBB_ARCH_PLATFORM ^: %TBB_ARCH_PLATFORM% REM ECHO TBB_ARCH_PLATFORM ^: %TBB_ARCH_PLATFORM%
ECHO calling cmake .... ECHO calling cmake ....
cmake .. ^ cmake .. ^
-G "Visual Studio 14 2015 Win64" ^ -G "Visual Studio 16 2019" ^
-DBOOST_ROOT=%BOOST_ROOT% ^ -DBOOST_ROOT=%BOOST_ROOT% ^
-DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^ -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^
-DBoost_ADDITIONAL_VERSIONS=1.58 ^ -DBoost_ADDITIONAL_VERSIONS=1.73.0 ^
-DBoost_USE_MULTITHREADED=ON ^ -DBoost_USE_MULTITHREADED=ON ^
-DBoost_USE_STATIC_LIBS=ON ^ -DBoost_USE_STATIC_LIBS=ON ^
-DEXPAT_INCLUDE_DIR=%OSRMDEPSDIR% ^
-DEXPAT_LIBRARY=%OSRMDEPSDIR%/lib/libexpat.lib ^
-DBZIP2_INCLUDE_DIR=%OSRMDEPSDIR% ^
-DBZIP2_LIBRARIES=%OSRMDEPSDIR%/lib/libbz2.lib ^
-DLUA_INCLUDE_DIR=%OSRMDEPSDIR% ^
-DLUA_LIBRARIES=%OSRMDEPSDIR%/lib/lua5.3.5.lib ^
-DZLIB_INCLUDE_DIR=%OSRMDEPSDIR% ^
-DZLIB_LIBRARY=%OSRMDEPSDIR%/lib/libz.lib ^
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^ -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
-DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_INSTALL_PREFIX=%PREFIX%
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
@ -106,60 +114,63 @@ msbuild OSRM.sln ^
/t:rebuild ^ /t:rebuild ^
/p:BuildInParallel=true ^ /p:BuildInParallel=true ^
/m:%NUMBER_OF_PROCESSORS% ^ /m:%NUMBER_OF_PROCESSORS% ^
/toolsversion:14.0 ^ /toolsversion:Current ^
/p:PlatformToolset=v140 ^ /p:PlatformToolset=v142 ^
/clp:Verbosity=normal ^ /clp:Verbosity=normal ^
/nologo ^ /nologo ^
/flp1:logfile=build_errors.txt;errorsonly ^ /flp1:logfile=build_errors.txt;errorsonly ^
/flp2:logfile=build_warnings.txt;warningsonly /flp2:logfile=build_warnings.txt;warningsonly
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
CD %PROJECT_DIR%\build CD %PROJECT_DIR%\build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
SET PATH=%PROJECT_DIR%\osrm-deps\libs\bin;%PATH% SET PATH=%PROJECT_DIR%\osrm-deps\lib;%PATH%
ECHO running extractor-tests.exe ... ECHO running extractor-tests.exe ...
unit_tests\%Configuration%\extractor-tests.exe unit_tests\%Configuration%\extractor-tests.exe
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
ECHO running engine-tests.exe ... ECHO running engine-tests.exe ...
unit_tests\%Configuration%\engine-tests.exe unit_tests\%Configuration%\engine-tests.exe
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
ECHO running util-tests.exe ... ECHO running util-tests.exe ...
unit_tests\%Configuration%\util-tests.exe unit_tests\%Configuration%\util-tests.exe
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
ECHO running server-tests.exe ... ECHO running server-tests.exe ...
unit_tests\%Configuration%\server-tests.exe unit_tests\%Configuration%\server-tests.exe
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% EQU 1 GOTO ERROR
ECHO running library-tests.exe ... ::TODO: CH processing sometimes mysteriously hangs, need to find why and enable tests below.
SET test_region=monaco ::ECHO running library-tests.exe ...
SET test_region_ch=ch\monaco ::SET test_region=monaco
SET test_region_corech=corech\monaco ::SET test_region_ch=ch\monaco
SET test_region_mld=mld\monaco ::SET test_region_corech=corech\monaco
SET test_osm=%test_region%.osm.pbf ::SET test_region_mld=mld\monaco
IF NOT EXIST %test_osm% powershell Invoke-WebRequest https://s3.amazonaws.com/mapbox/osrm/testing/monaco.osm.pbf -OutFile %test_osm% ::SET test_osm=%test_region%.osm.pbf
%Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% ::IF NOT EXIST %test_osm% powershell Invoke-WebRequest http://project-osrm.wolt.com/testing/monaco.osm.pbf -OutFile %test_osm%
MKDIR ch ::ECHO running %Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm%
XCOPY %test_region%.osrm.* ch\ ::%Configuration%\osrm-extract.exe
XCOPY %test_region%.osrm ch\ ::%Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm%
MKDIR corech ::MKDIR ch
XCOPY %test_region%.osrm.* corech\ ::XCOPY %test_region%.osrm.* ch\
XCOPY %test_region%.osrm corech\ ::XCOPY %test_region%.osrm ch\
MKDIR mld ::MKDIR corech
XCOPY %test_region%.osrm.* mld\ ::XCOPY %test_region%.osrm.* corech\
XCOPY %test_region%.osrm mld\ ::XCOPY %test_region%.osrm corech\
%Configuration%\osrm-contract.exe %test_region_ch%.osrm ::MKDIR mld
%Configuration%\osrm-contract.exe --core 0.8 %test_region_corech%.osrm ::XCOPY %test_region%.osrm.* mld\
%Configuration%\osrm-partition.exe %test_region_mld%.osrm ::XCOPY %test_region%.osrm mld\
%Configuration%\osrm-customize.exe %test_region_mld%.osrm ::%Configuration%\osrm-contract.exe %test_region_ch%.osrm
XCOPY /Y ch\*.* ..\test\data\ch\ ::%Configuration%\osrm-contract.exe --core 0.8 %test_region_corech%.osrm
XCOPY /Y corech\*.* ..\test\data\corech\ ::%Configuration%\osrm-partition.exe %test_region_mld%.osrm
XCOPY /Y mld\*.* ..\test\data\mld\ ::%Configuration%\osrm-customize.exe %test_region_mld%.osrm
unit_tests\%Configuration%\library-tests.exe ::XCOPY /Y ch\*.* ..\test\data\ch\
::XCOPY /Y corech\*.* ..\test\data\corech\
::XCOPY /Y mld\*.* ..\test\data\mld\
::unit_tests\%Configuration%\library-tests.exe
:ERROR :ERROR
ECHO ~~~~~~~~~~~~~~~~~~~~~~ ERROR %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ECHO ~~~~~~~~~~~~~~~~~~~~~~ ERROR %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -10,7 +10,7 @@ install:
init: init:
- git config --global core.autocrlf input - git config --global core.autocrlf input
os: Visual Studio 2015 os: Visual Studio 2019
# clone directory # clone directory
clone_folder: c:\projects\osrm clone_folder: c:\projects\osrm
@ -25,9 +25,10 @@ before_test:
- npm --version - npm --version
- npm install --ignore-scripts - npm install --ignore-scripts
- npm link --ignore-scripts - npm link --ignore-scripts
- SET PATH=%CD%\osrm-deps\libs\bin;%PATH% - SET PATH=%CD%\osrm-deps\lib;%PATH%
- SET OSRM_BUILD_DIR=build\%Configuration% - SET OSRM_BUILD_DIR=build\%Configuration%
- npm test # TODO tests fail with "JavaScript heap out of memory", need a better host?
# - npm test
branches: branches:
only: only:

View File

@ -11,7 +11,6 @@ SET CONFIGURATION=Release
FOR /F "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do SET APPVEYOR_REPO_BRANCH=%%i FOR /F "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do SET APPVEYOR_REPO_BRANCH=%%i
ECHO APPVEYOR_REPO_BRANCH^: %APPVEYOR_REPO_BRANCH% ECHO APPVEYOR_REPO_BRANCH^: %APPVEYOR_REPO_BRANCH%
SET PATH=C:\mb\windows-builds-64\tmp-bin\cmake-3.7.0-rc2-win32-x86\bin;%PATH%
SET PATH=C:\Program Files\7-Zip;%PATH% SET PATH=C:\Program Files\7-Zip;%PATH%
powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force

View File

@ -1,51 +0,0 @@
# Locate STXXL library
# This module defines
# STXXL_FOUND, if false, do not try to link to libstxxl
# STXXL_LIBRARY
# STXXL_INCLUDE_DIR, where to find stxxl.h
#
IF( NOT STXXL_FIND_QUIETLY )
MESSAGE(STATUS "Looking for STXXL...")
ENDIF()
FIND_PATH(STXXL_INCLUDE_DIR stxxl.h
HINTS
$ENV{STXXL_DIR}
PATH_SUFFIXES stxxl include/stxxl/stxxl include/stxxl include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt/local # DarwinPorts
/opt
)
FIND_LIBRARY(STXXL_LIBRARY
NAMES stxxl stxxl_debug
HINTS
$ENV{STXXL_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt/local
/opt
)
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set STXXL_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(STXXL DEFAULT_MSG STXXL_LIBRARY STXXL_INCLUDE_DIR)
IF( NOT STXXL_FIND_QUIETLY )
IF( STXXL_FOUND )
MESSAGE(STATUS "Found STXXL: ${STXXL_LIBRARY}" )
ENDIF()
ENDIF()
MARK_AS_ADVANCED(STXXL_INCLUDE_DIR STXXL_LIBRARY)

View File

@ -29,15 +29,16 @@ To pass parameters to each location some options support an array like encoding:
**Request options** **Request options**
| Option | Values | Description | | Option | Values | Description |
|----------------|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------| |----------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in clockwise direction. | |bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in clockwise direction. |
|radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. | |radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. |
|generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. | |generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. |
|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. | |hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. |
|approaches |`{approach};{approach}[;{approach} ...]` |Keep waypoints on curb side. | |approaches |`{approach};{approach}[;{approach} ...]` |Keep waypoints on curb side. |
|exclude |`{class}[,{class}]` |Additive list of classes to avoid, order does not matter. | |exclude |`{class}[,{class}]` |Additive list of classes to avoid, order does not matter. |
|snapping |`default` (default), `any` |Default snapping avoids is_startpoint (see profile) edges, `any` will snap to any edge in the graph | |snapping |`default` (default), `any` |Default snapping avoids is_startpoint (see profile) edges, `any` will snap to any edge in the graph |
|skip_waypoints |`true`, `false` (default) |Removes waypoints from the response. Waypoints are still calculated, but not serialized. Could be useful in case you are interested in some other part of response and do not want to transfer waste data. |
Where the elements follow the following format: Where the elements follow the following format:
@ -128,6 +129,9 @@ In addition to the [general options](#general-options) the following options are
|------------|------------------------------|----------------------------------------------------| |------------|------------------------------|----------------------------------------------------|
|number |`integer >= 1` (default `1`) |Number of nearest segments that should be returned. | |number |`integer >= 1` (default `1`) |Number of nearest segments that should be returned. |
As `waypoints` is a single thing, returned byt that service, using it with option `skip_waypoints` set to `true` is quite useless, but still
possible. In that case only `code` field will be returned.
**Response** **Response**
- `code` if the request was successful `Ok` otherwise see the service dependent and general status codes. - `code` if the request was successful `Ok` otherwise see the service dependent and general status codes.
@ -207,8 +211,8 @@ In addition to the [general options](#general-options) the following options are
|annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. |
|geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) |
|overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.|
|continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. | |continue\_straight |`default` (default), `true`, `false` |Forces the route to keep going straight at waypoints constraining uturns there even if it would be faster. Default value depends on the profile. |
|waypoints | `{index};{index};{index}...` |Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. | |waypoints | `{index};{index};{index}...` |Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. |
\* Please note that even if alternative routes are requested, a result cannot be guaranteed. \* Please note that even if alternative routes are requested, a result cannot be guaranteed.
@ -257,6 +261,8 @@ In addition to the [general options](#general-options) the following options are
Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal** Unlike other array encoded options, the length of `sources` and `destinations` can be **smaller or equal**
to number of input locations; to number of input locations;
With `skip_waypoints` set to `true`, both `sources` and `destinations` arrays will be skipped.
**Example:** **Example:**
``` ```
@ -967,7 +973,7 @@ Root object is the only object, available from a 'raw' `flatbuffers` buffer. It
- `error`: `bool` Marks response as erroneous. Erroneus response should include `code` field set, all the other field may not present. - `error`: `bool` Marks response as erroneous. Erroneus response should include `code` field set, all the other field may not present.
- `code`: `Error` Error description object, only present, when `error` is `true` - `code`: `Error` Error description object, only present, when `error` is `true`
- `waypoints`: `[Waypoint]` Array of `Waypoint` objects. Should present for every service call. Table service will put `sources` array here. - `waypoints`: `[Waypoint]` Array of `Waypoint` objects. Should present for every service call, unless `skip_waypoints` is set to `true`. Table service will put `sources` array here.
- `routes`: `[RouteObject]` Array of `RouteObject` objects. May be empty or absent. Should present for Route/Trip/Match services call. - `routes`: `[RouteObject]` Array of `RouteObject` objects. May be empty or absent. Should present for Route/Trip/Match services call.
- `table`: `Table` Table object, may absent. Should be present in case of Table service call. - `table`: `Table` Table object, may absent. Should be present in case of Table service call.
@ -1112,6 +1118,7 @@ Almost same as `json` Table object. The main difference is that 'sources' field
used instead. All the other differences follow: used instead. All the other differences follow:
- `durations`: `[float]` Flat representation of a durations matrix. Element at row;col can be adressed as [row * cols + col] - `durations`: `[float]` Flat representation of a durations matrix. Element at row;col can be adressed as [row * cols + col]
- `destinations`: `[float]` Flat representation of a destinations matrix. Element at row;col can be adressed as [row * cols + col] - `distances`: `[float]` Flat representation of a destinations matrix. Element at row;col can be adressed as [row * cols + col]
- `destinations`: `[Waypoint]` Array of `Waypoint` objects. Will be `null` if `skip_waypoints` will be set to `true`
- `rows`: `ushort` Number of rows in durations/destinations matrices. - `rows`: `ushort` Number of rows in durations/destinations matrices.
- `cols`: `ushort` Number of cols in durations/destinations matrices. - `cols`: `ushort` Number of cols in durations/destinations matrices.

View File

@ -50,6 +50,7 @@ Returns the fastest route between two or more coordinates while visiting the way
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
- `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
- `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
- `options.alternatives` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Search for alternative routes. (optional, default `false`) - `options.alternatives` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Search for alternative routes. (optional, default `false`)
- `options.alternatives` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Search for up to this many alternative routes. - `options.alternatives` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Search for up to this many alternative routes.
_Please note that even if alternative routes are requested, a result cannot be guaranteed._ (optional, default `0`) _Please note that even if alternative routes are requested, a result cannot be guaranteed._ (optional, default `0`)
@ -91,6 +92,7 @@ Note: `coordinates` in the general options only supports a single `{longitude},{
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
- `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
- `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
- `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned. - `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Number of nearest segments that should be returned.
Must be an integer greater than or equal to `1`. (optional, default `1`) Must be an integer greater than or equal to `1`. (optional, default `1`)
- `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`. - `options.approaches` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Keep waypoints on curb side. Can be `null` (unrestricted, default) or `curb`.
@ -128,6 +130,7 @@ tables. Optionally returns distance table.
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
- `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`. - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `null` (unlimited, default) or `double >= 0`.
- `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
- `options.sources` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to - `options.sources` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to
use use
location with given index as source. Default is to use all. location with given index as source. Default is to use all.
@ -208,6 +211,7 @@ if they can not be matched successfully.
- `options.bearings` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction. - `options.bearings` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
- `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
- `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`) - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`)
- `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`)
- `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`)
@ -274,6 +278,7 @@ Right now, the following combinations are possible:
Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`. Can be `null` or an array of `[{value},{range}]` with `integer 0 .. 360,integer 0 .. 180`.
- `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `double >= 0` or `null` (unlimited, default). - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Limits the coordinate snapping to streets in the given radius in meters. Can be `double >= 0` or `null` (unlimited, default).
- `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings. - `options.hints` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Hints for the coordinate snapping. Array of base64 encoded strings.
- `options.generate_hints` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Whether or not adds a Hint to the response which can be used in subsequent requests. (optional, default `true`)
- `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`) - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Return route steps for each route. (optional, default `false`)
- `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`) - `options.annotations` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** An array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed` or boolean for enabling/disabling all. (optional, default `false`)
- `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`)

View File

@ -89,7 +89,7 @@ They all return a table of functions when you use `require` to load them. You ca
### setup() ### setup()
The `setup` function is called once when the profile is loaded and must return a table of configurations. It's also where you can do other global setup, like loading data sources that are used during processing. The `setup` function is called once when the profile is loaded and must return a table of configurations. It's also where you can do other global setup, like loading data sources that are used during processing.
Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA iinterpreter will have its own set of globals. Note that processing of data is parallelized and several unconnected LUA interpreters will be running at the same time. The `setup` function will be called once for each. Each LUA interpreter will have its own set of globals.
The following global properties can be set under `properties` in the hash you return in the `setup` function: The following global properties can be set under `properties` in the hash you return in the `setup` function:
@ -98,7 +98,7 @@ Attribute | Type | Notes
weight_name | String | Name used in output for the routing weight property (default `'duration'`) weight_name | String | Name used in output for the routing weight property (default `'duration'`)
weight_precision | Unsigned | Decimal precision of edge weights (default `1`) weight_precision | Unsigned | Decimal precision of edge weights (default `1`)
left_hand_driving | Boolean | Are vehicles assumed to drive on the left? (used in guidance, default `false`) left_hand_driving | Boolean | Are vehicles assumed to drive on the left? (used in guidance, default `false`)
use_turn_restrictions | Boolean | Are turn instructions followed? (default `false`) use_turn_restrictions | Boolean | Are turn restrictions followed? (default `false`)
continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed? (default `true`) continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed? (default `true`)
max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s) max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s)
max_turn_weight | Float | Maximum turn penalty weight max_turn_weight | Float | Maximum turn penalty weight
@ -178,7 +178,7 @@ exits | String | The ramp's exit numbers or
pronunciation | String | Name pronunciation pronunciation | String | Name pronunciation
road_classification.motorway_class | Boolean | Guidance: way is a motorway road_classification.motorway_class | Boolean | Guidance: way is a motorway
road_classification.link_class | Boolean | Guidance: way is a slip/link road road_classification.link_class | Boolean | Guidance: way is a slip/link road
road_classification.road_priority_class | Enum | Guidance: order in priority list. Defined in `include/extractor/guidance/road_classification.hpp` road_classification.road_priority_class | Enum | Guidance: order in priority list. Defined in `include/extractor/road_classification.hpp`
road_classification.may_be_ignored | Boolean | Guidance: way is non-highway road_classification.may_be_ignored | Boolean | Guidance: way is non-highway
road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way road_classification.num_lanes | Unsigned | Guidance: total number of lanes in way
@ -223,7 +223,7 @@ source_number_of_lanes | Read | Integer |
source_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) source_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
source_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) source_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
source_speed | Read | Integer | Speed on this source road in km/h source_speed | Read | Integer | Speed on this source road in km/h
source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/guidance/road_classification.hpp` source_priority_class | Read | Enum | The type of road priority class of the source. Defined in `include/extractor/road_classification.hpp`
target_restricted | Read | Boolean | Is the target a restricted access road? (See definition in `process_way`) target_restricted | Read | Boolean | Is the target a restricted access road? (See definition in `process_way`)
target_mode | Read | Enum | Travel mode after the turn. Defined in `include/extractor/travel_mode.hpp` target_mode | Read | Enum | Travel mode after the turn. Defined in `include/extractor/travel_mode.hpp`
target_is_motorway | Read | Boolean | Is the target road a motorway? target_is_motorway | Read | Boolean | Is the target road a motorway?
@ -232,7 +232,7 @@ target_number_of_lanes | Read | Integer |
target_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) target_highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
target_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)) target_access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15))
target_speed | Read | Integer | Speed on this target road in km/h target_speed | Read | Integer | Speed on this target road in km/h
target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/guidance/road_classification.hpp` target_priority_class | Read | Enum | The type of road priority class of the target. Defined in `include/extractor/road_classification.hpp`
roads_on_the_right | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the right of the turn that are also connected at the intersection roads_on_the_right | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the right of the turn that are also connected at the intersection
roads_on_the_left | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the left of the turn that are also connected at the intersection. If turn is a u turn, this is empty. roads_on_the_left | Read | Vector<ExtractionTurnLeg> | Vector with information about other roads on the left of the turn that are also connected at the intersection. If turn is a u turn, this is empty.
weight | Read/write | Float | Penalty to be applied for this turn (routing weight) weight | Read/write | Float | Penalty to be applied for this turn (routing weight)
@ -252,7 +252,7 @@ number_of_lanes | Read | Integer | How many lanes does th
highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15) highway_turn_classification | Read | Integer | Classification based on highway tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15) access_turn_classification | Read | Integer | Classification based on access tag defined by user during setup. (default when not set: 0, allowed classification values are: 0-15)
speed | Read | Integer | Speed on this road in km/h speed | Read | Integer | Speed on this road in km/h
priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/guidance/road_classification.hpp` priority_class | Read | Enum | The type of road priority class of the leg. Defined in `include/extractor/road_classification.hpp`
is_incoming | Read | Boolean | Is the road an incoming road of the intersection is_incoming | Read | Boolean | Is the road an incoming road of the intersection
is_outgoing | Read | Boolean | Is the road an outgoing road of the intersection is_outgoing | Read | Boolean | Is the road an outgoing road of the intersection

97
docs/windows-deps.md Normal file
View File

@ -0,0 +1,97 @@
# Building OSRM for Windows
## Dependencies
Get a decent Windows with decent Visual Studio (14 at least for C++11 support). The published binaries are build with
VS2019 and Windows SDK8.1.
In case you are using [prepacked Windows VM with VS2019](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/), you
have to install [Windows SDK 8.1](https://go.microsoft.com/fwlink/p/?LinkId=323507)
Prepare directories for dependencies, build and target file location.Target directory ($target starting from that moment) should have /include and /lib subdirectories.
### Bzip2
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/bzip2-1.0.8.tar.gz
* https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
3. Issue `nmake /f makefile.msc`
4. Copy bzlib.h to $target\include and libbz2.lib to $target\lib
### ZLib
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/zlib-1.2.11.tar.gz
* https://www.zlib.net/zlib-1.2.11.tar.gz
2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
3. Switch to `contrib\vstudio\vc14`
4. If needed, open `zlibvc.sln` with Visual Studio and retarget to your version of compiler and SDK.
5. Issue `msbuild zlibvc.sln /p:BuildInParallel=true /p:Configuration=Release /p:Platform=x64 /m:<Number of cpu cores>`
6. Copy x64\ZlibStatRelease\zlibstat.lib to $target\lib\libz.lib, copy zlib.h and zconf.h to $target\include
### ICU
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://wolt-project.wolt.com/deps/icu4c-66_1-src.zip
* https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.zip
* https://wolt-project.wolt.com/deps/icu4c-66_1-data.zip
* https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-data.zip
2. Do retarget if neededby openinig .\source\allinone\allinone.sln and editing projects
3. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
4. Run build:
msbuild .\source\allinone\allinone.sln /nologo /p:BuildInParallel=true /p:Configuration=Release /p:Platform=x64 /m:<Number of cpu cores>
5. Copy lib64\*.lib to $target\lib, copy include contents to $target\include
6. Copy bin64\*dll to any dir withing your $PATH. At the same time copy them to $target\lib
### Boost
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/boost_1_73_0.zip
* https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.zip
2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
3. Build b2:
bootstrap.bat --with-toolset=msvc-14.2
4. Build boost:
b2 -a -d release state --build-type=minimal toolset=msvc-14.2 -q runtime-link=shared link=static address-model=64 --with-iostreams --with-test --with-thread --with-filesystem --with-date_time --with-system --with-program_options --with-regex --disable-filesystem2 -sHAVE_ICU=1 include=<target>\include library-path=<target>\lib -sZLIB_SOURCE=<builddir>/zlib -zBZIP2_BINARY=libbz2 -sBZIP2_INCLUDE=<target>\include -sBZIP2_LIBPATH=<target>\lib -sICU_ICUUC_NAME=icuuc -sICU_ICUDT_NAME=icudt -sICU_ICUIN_NAME=icuin -sBUILD=boost_unit_test_framework -j<number of cpu cores>
5. Copy `boost` subdirectory to <target>\include and contents of `stage` to <target>\lib
### Expat
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/libexpat-2_2_9.zip
* https://github.com/libexpat/libexpat/archive/R_2_2_9.zip
2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
3. Configure build my calling cmake:
mkdir expat\build
cd expat\build
cmake -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DEXPAT_MSVC_STATIC_CRT=ON -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF -DEXPAT_SHARED_LIBS=OFF ..
4. Build expat: `msbuild expat.sln /nologo /p:Configuration=Release /p:Platform=x64`
5. Copy `Release\libexpat.*` to <target>/lib. Copy `expat/lib/expat.h` and `expat/lib/expat_external.h` to <target>/include
### LUA
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/lua-5.3.5.tar.gz
* https://www.lua.org/ftp/lua-5.3.5.tar.gz
2. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
3. Lua doesn't have native MSVC support, so you have to compile it by hand:
cd src
cl /MD /O2 /c /DLUA_COMPAT_5_2 *.c
ren lua.obj lua.o
ren luac.obj luac.o
link /LIB /OUT:lua5.3.5.dll *.obj
4. Copy `lua5.3.5.lib` to <target>/lib. Copy `lua.h`,`lauxlib,h`,`lua.hpp`,`lualib.h`,`luaconf.h` to <target>/include
### TBB
1. Download either from Wolt OSRM mirror or original distribution and unpack.
* https://project-osrm.wolt.com/deps/oneTBB-v2020.2.zip
* https://github.com/oneapi-src/oneTBB/archive/v2020.2.zip
2. Retarget by opening build\vs2013\makefile.sln
3. Start 'x64 Native Tools Command Prompt for VS2019' and change directory to unpacked source tree.
4. Switch to build\vs2013 and build: `msbuild makefle.sln /nologo /p:Configuration=Release /p:Platform=x64`
5. Copy x64/Release/*.{dll,lib} files to <target>/lib and copy contents of include directory to <target>/include

View File

@ -127,6 +127,7 @@ Feature: Bike - Access tags on ways
| | | agricultural | | | | | agricultural | |
| | | forestry | | | | | forestry | |
| | | delivery | | | | | delivery | |
| | | use_sidepath | |
Scenario: Bike - Access tags on both node and way Scenario: Bike - Access tags on both node and way
Then routability should be Then routability should be

View File

@ -1,27 +1,38 @@
var util = require('util'); var util = require('util');
var flatbuffers = require('../support/flatbuffers').flatbuffers;
var FBResult = require('../support/fbresult_generated').osrm.engine.api.fbresult.FBResult;
module.exports = function () { module.exports = function () {
const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/); const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/);
const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/); const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/);
const estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/); const estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/);
const durationsRegexFb = new RegExp(/^I request a travel time matrix with flatbuffers I should get$/);
const distancesRegexFb = new RegExp(/^I request a travel distance matrix with flatbuffers I should get$/);
const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT
const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT
this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', callback);}.bind(this)); const FORMAT_JSON = 'json';
this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', callback);}.bind(this)); const FORMAT_FB = 'flatbuffers';
this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'fallback_speed_cells', callback);}.bind(this));
this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', FORMAT_JSON, callback);}.bind(this));
this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', FORMAT_JSON, callback);}.bind(this));
this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'fallback_speed_cells', FORMAT_JSON, callback);}.bind(this));
this.When(durationsRegexFb, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', FORMAT_FB, callback);}.bind(this));
this.When(distancesRegexFb, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', FORMAT_FB, callback);}.bind(this));
}; };
const durationsParse = function(v) { return isNaN(parseInt(v)); }; const durationsParse = function(v) { return isNaN(parseInt(v)); };
const distancesParse = function(v) { return isNaN(parseFloat(v)); }; const distancesParse = function(v) { return isNaN(parseFloat(v)); };
const estimatesParse = function(v) { return isNaN(parseFloat(v)); }; const estimatesParse = function(v) { return isNaN(parseFloat(v)); };
function tableParse(table, noRoute, annotation, callback) { function tableParse(table, noRoute, annotation, format, callback) {
const parse = annotation == 'distances' ? distancesParse : (annotation == 'durations' ? durationsParse : estimatesParse); const parse = annotation == 'distances' ? distancesParse : (annotation == 'durations' ? durationsParse : estimatesParse);
const params = this.queryParams; const params = this.queryParams;
params.annotations = ['durations','fallback_speed_cells'].indexOf(annotation) !== -1 ? 'duration' : 'distance'; params.annotations = ['durations','fallback_speed_cells'].indexOf(annotation) !== -1 ? 'duration' : 'distance';
params.output = format;
var tableRows = table.raw(); var tableRows = table.raw();
@ -62,27 +73,53 @@ function tableParse(table, noRoute, annotation, callback) {
if (err) return callback(err); if (err) return callback(err);
if (!response.body.length) return callback(new Error('Invalid response body')); if (!response.body.length) return callback(new Error('Invalid response body'));
var json = JSON.parse(response.body); var result = [];
if (format === 'json') {
var json = JSON.parse(response.body);
var result = {}; if (annotation === 'fallback_speed_cells') {
if (annotation === 'fallback_speed_cells') { result = table.raw().map(row => row.map(() => ''));
result = table.raw().map(row => row.map(() => '')); json[annotation].forEach(pair => {
json[annotation].forEach(pair => { result[pair[0]+1][pair[1]+1] = 'Y';
result[pair[0]+1][pair[1]+1] = 'Y';
});
result = result.slice(1).map(row => {
var hashes = {};
row.slice(1).forEach((v,i) => {
hashes[tableRows[0][i+1]] = v;
}); });
return hashes; result = result.slice(1).map(row => {
}); var hashes = {};
} else { row.slice(1).forEach((v,i) => {
result = json[annotation].map(row => { hashes[tableRows[0][i+1]] = v;
var hashes = {}; });
row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; }); return hashes;
return hashes; });
}); } else {
result = json[annotation].map(row => {
var hashes = {};
row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; });
return hashes;
});
}
} else { //flatbuffers
var body = response.body;
var bytes = new Uint8Array(body.length);
for (var indx = 0; indx < body.length; ++indx) {
bytes[indx] = body.charCodeAt(indx);
}
var buf = new flatbuffers.ByteBuffer(bytes);
var fb = FBResult.getRootAsFBResult(buf);
var matrix;
if (annotation === 'durations') {
matrix = fb.table().durationsArray();
}
if (annotation === 'distances') {
matrix = fb.table().distancesArray();
}
var cols = fb.table().cols();
var rows = fb.table().rows();
for (let r = 0; r < rows; ++r) {
result[r]={};
for(let c=0; c < cols; ++c) {
result[r][tableRows[0][c+1]] = matrix[r*cols + c];
}
}
} }
var testRow = (row, ri, cb) => { var testRow = (row, ri, cb) => {

View File

@ -12,4 +12,9 @@ module.exports = function () {
q.awaitAll(callback); q.awaitAll(callback);
}); });
this.Given(/^skip waypoints$/, (callback) => {
this.queryParams['skip_waypoints'] = true;
callback();
});
}; };

View File

@ -22,14 +22,9 @@ module.exports = function () {
this.PROFILES_PATH = path.resolve(this.ROOT_PATH, 'profiles'); this.PROFILES_PATH = path.resolve(this.ROOT_PATH, 'profiles');
this.FIXTURES_PATH = path.resolve(this.ROOT_PATH, 'unit_tests/fixtures'); this.FIXTURES_PATH = path.resolve(this.ROOT_PATH, 'unit_tests/fixtures');
this.BIN_PATH = process.env.OSRM_BUILD_DIR && process.env.OSRM_BUILD_DIR || path.resolve(this.ROOT_PATH, 'build'); this.BIN_PATH = process.env.OSRM_BUILD_DIR && process.env.OSRM_BUILD_DIR || path.resolve(this.ROOT_PATH, 'build');
var stxxl_config = path.resolve(this.ROOT_PATH, 'test/.stxxl');
if (!fs.existsSync(stxxl_config)) {
return callback(new Error('*** '+stxxl_config+ 'does not exist'));
}
this.DATASET_NAME = 'cucumber'; this.DATASET_NAME = 'cucumber';
this.PLATFORM_WINDOWS = process.platform.match(/^win.*/); this.PLATFORM_WINDOWS = process.platform.match(/^win.*/);
this.DEFAULT_ENVIRONMENT = Object.assign({STXXLCFG: stxxl_config}, process.env); this.DEFAULT_ENVIRONMENT = process.env;
this.DEFAULT_PROFILE = 'bicycle'; this.DEFAULT_PROFILE = 'bicycle';
this.DEFAULT_INPUT_FORMAT = 'osm'; this.DEFAULT_INPUT_FORMAT = 'osm';
this.DEFAULT_LOAD_METHOD = process.argv[process.argv.indexOf('-m') +1].match('mmap') ? 'mmap' : 'datastore'; this.DEFAULT_LOAD_METHOD = process.argv[process.argv.indexOf('-m') +1].match('mmap') ? 'mmap' : 'datastore';

View File

@ -155,6 +155,13 @@ module.exports = function () {
if (headers.has('locations')){ if (headers.has('locations')){
got.locations = (locations || '').trim(); got.locations = (locations || '').trim();
} }
if (headers.has('waypoints_count')) {
if ('waypoints' in json) {
got.waypoints_count = json.waypoints.length;
} else{
got.waypoints_count = 0;
}
}
/* /*
if (headers.has('approaches')){ if (headers.has('approaches')){
got.approaches = (approaches || '').trim(); got.approaches = (approaches || '').trim();

View File

@ -17,9 +17,9 @@ Feature: Basic Routing
| ab | | ab |
When I route I should get When I route I should get
| from | to | route | data_version | | from | to | route | data_version | waypoints_count |
| a | b | ab,ab | | | a | b | ab,ab | | 2 |
| b | a | ab,ab | | | b | a | ab,ab | | 2 |
Scenario: Data_version test Scenario: Data_version test
Given the node map Given the node map
@ -38,6 +38,23 @@ Feature: Basic Routing
| a | b | ab,ab | cucumber_data_version | | a | b | ab,ab | cucumber_data_version |
| b | a | ab,ab | cucumber_data_version | | b | a | ab,ab | cucumber_data_version |
Scenario: Skip_waypoints test
Given the node map
"""
a b
"""
And skip waypoints
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route | waypoints_count |
| a | b | ab,ab | 0 |
| b | a | ab,ab | 0 |
Scenario: Routing in between two nodes of way Scenario: Routing in between two nodes of way
Given the node map Given the node map
""" """

View File

@ -21,6 +21,21 @@ Feature: Basic Duration Matrix
| a | 0 | 10 | | a | 0 | 10 |
| b | 10 | 0 | | b | 10 | 0 |
Scenario: Testbot - Travel time matrix of minimal network requested with flatbuffer format
Given the node map
"""
a b
"""
And the ways
| nodes |
| ab |
When I request a travel time matrix with flatbuffers I should get
| | a | b |
| a | 0 | 10 |
| b | 10 | 0 |
@ch @ch
Scenario: Testbot - Travel time matrix of minimal network with toll exclude Scenario: Testbot - Travel time matrix of minimal network with toll exclude
Given the query options Given the query options

View File

@ -12,6 +12,7 @@
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/range/algorithm/transform.hpp> #include <boost/range/algorithm/transform.hpp>
#include <memory>
#include <vector> #include <vector>
namespace osrm namespace osrm
@ -73,7 +74,7 @@ class BaseAPI
} }
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
MakeWaypoints(flatbuffers::FlatBufferBuilder &builder, MakeWaypoints(flatbuffers::FlatBufferBuilder *builder,
const std::vector<PhantomNodes> &segment_end_coordinates) const const std::vector<PhantomNodes> &segment_end_coordinates) const
{ {
BOOST_ASSERT(parameters.coordinates.size() > 0); BOOST_ASSERT(parameters.coordinates.size() > 0);
@ -82,43 +83,43 @@ class BaseAPI
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints; std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
waypoints.resize(parameters.coordinates.size()); waypoints.resize(parameters.coordinates.size());
waypoints[0] = waypoints[0] =
MakeWaypoint(builder, segment_end_coordinates.front().source_phantom).Finish(); MakeWaypoint(builder, segment_end_coordinates.front().source_phantom)->Finish();
std::transform(segment_end_coordinates.begin(), std::transform(segment_end_coordinates.begin(),
segment_end_coordinates.end(), segment_end_coordinates.end(),
std::next(waypoints.begin()), std::next(waypoints.begin()),
[this, &builder](const PhantomNodes &phantom_pair) { [this, builder](const PhantomNodes &phantom_pair) {
return MakeWaypoint(builder, phantom_pair.target_phantom).Finish(); return MakeWaypoint(builder, phantom_pair.target_phantom)->Finish();
}); });
return builder.CreateVector(waypoints); return builder->CreateVector(waypoints);
} }
// FIXME: gcc 4.9 does not like MakeWaypoints to be protected // FIXME: gcc 4.9 does not like MakeWaypoints to be protected
// protected: // protected:
fbresult::WaypointBuilder MakeWaypoint(flatbuffers::FlatBufferBuilder &builder, std::unique_ptr<fbresult::WaypointBuilder> MakeWaypoint(flatbuffers::FlatBufferBuilder *builder,
const PhantomNode &phantom) const const PhantomNode &phantom) const
{ {
auto location = auto location =
fbresult::Position(static_cast<double>(util::toFloating(phantom.location.lon)), fbresult::Position(static_cast<double>(util::toFloating(phantom.location.lon)),
static_cast<double>(util::toFloating(phantom.location.lat))); static_cast<double>(util::toFloating(phantom.location.lat)));
auto name_string = builder.CreateString( auto name_string = builder->CreateString(
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string()); facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string());
boost::optional<flatbuffers::Offset<flatbuffers::String>> hint_string = boost::none; flatbuffers::Offset<flatbuffers::String> hint_string;
if (parameters.generate_hints) if (parameters.generate_hints)
{ {
hint_string = builder.CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64()); hint_string = builder->CreateString(Hint{phantom, facade.GetCheckSum()}.ToBase64());
} }
fbresult::WaypointBuilder waypoint(builder); auto waypoint = std::make_unique<fbresult::WaypointBuilder>(*builder);
waypoint.add_location(&location); waypoint->add_location(&location);
waypoint.add_distance(util::coordinate_calculation::fccApproximateDistance( waypoint->add_distance(util::coordinate_calculation::fccApproximateDistance(
phantom.location, phantom.input_location)); phantom.location, phantom.input_location));
waypoint.add_name(name_string); waypoint->add_name(name_string);
if (hint_string) if (parameters.generate_hints)
{ {
waypoint.add_hint(*hint_string); waypoint->add_hint(hint_string);
} }
return waypoint; return waypoint;
} }

View File

@ -87,6 +87,9 @@ struct BaseParameters
// Adds hints to response which can be included in subsequent requests, see `hints` above. // Adds hints to response which can be included in subsequent requests, see `hints` above.
bool generate_hints = true; bool generate_hints = true;
// Remove waypoints array from the response.
bool skip_waypoints = false;
SnappingType snapping = SnappingType::Default; SnappingType snapping = SnappingType::Default;
BaseParameters(const std::vector<util::Coordinate> coordinates_ = {}, BaseParameters(const std::vector<util::Coordinate> coordinates_ = {},

View File

@ -50,7 +50,7 @@ class MatchAPI final : public RouteAPI
flatbuffers::FlatBufferBuilder &fb_result) const flatbuffers::FlatBufferBuilder &fb_result) const
{ {
auto data_timestamp = facade.GetTimestamp(); auto data_timestamp = facade.GetTimestamp();
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; flatbuffers::Offset<flatbuffers::String> data_version_string;
if (!data_timestamp.empty()) if (!data_timestamp.empty())
{ {
data_version_string = fb_result.CreateString(data_timestamp); data_version_string = fb_result.CreateString(data_timestamp);
@ -60,12 +60,12 @@ class MatchAPI final : public RouteAPI
return MakeTracepoints(fb_result, sub_matchings); return MakeTracepoints(fb_result, sub_matchings);
}); });
if (data_version_string) if (!data_timestamp.empty())
{ {
response.add_data_version(*data_version_string); response->add_data_version(data_version_string);
} }
fb_result.Finish(response.Finish()); fb_result.Finish(response->Finish());
} }
void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings, void MakeResponse(const std::vector<map_matching::SubMatching> &sub_matchings,
const std::vector<InternalRouteResult> &sub_routes, const std::vector<InternalRouteResult> &sub_routes,
@ -83,7 +83,10 @@ class MatchAPI final : public RouteAPI
route.values["confidence"] = sub_matchings[index].confidence; route.values["confidence"] = sub_matchings[index].confidence;
routes.values.push_back(std::move(route)); routes.values.push_back(std::move(route));
} }
response.values["tracepoints"] = MakeTracepoints(sub_matchings); if (!parameters.skip_waypoints)
{
response.values["tracepoints"] = MakeTracepoints(sub_matchings);
}
response.values["matchings"] = std::move(routes); response.values["matchings"] = std::move(routes);
response.values["code"] = "Ok"; response.values["code"] = "Ok";
} }
@ -138,29 +141,29 @@ class MatchAPI final : public RouteAPI
} }
const auto &phantom = const auto &phantom =
sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index]; sub_matchings[matching_index.sub_matching_index].nodes[matching_index.point_index];
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantom); auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantom);
waypoint.add_matchings_index(matching_index.sub_matching_index); waypoint->add_matchings_index(matching_index.sub_matching_index);
waypoint.add_alternatives_count(sub_matchings[matching_index.sub_matching_index] waypoint->add_alternatives_count(sub_matchings[matching_index.sub_matching_index]
.alternatives_count[matching_index.point_index]); .alternatives_count[matching_index.point_index]);
// waypoint indices need to be adjusted if route legs were collapsed // waypoint indices need to be adjusted if route legs were collapsed
// waypoint parameter assumes there is only one match object // waypoint parameter assumes there is only one match object
if (!parameters.waypoints.empty()) if (!parameters.waypoints.empty())
{ {
if (tidy_result.was_waypoint[trace_index]) if (tidy_result.was_waypoint[trace_index])
{ {
waypoint.add_waypoint_index(was_waypoint_idx); waypoint->add_waypoint_index(was_waypoint_idx);
was_waypoint_idx++; was_waypoint_idx++;
} }
else else
{ {
waypoint.add_waypoint_index(0); waypoint->add_waypoint_index(0);
} }
} }
else else
{ {
waypoint.add_waypoint_index(matching_index.point_index); waypoint->add_waypoint_index(matching_index.point_index);
} }
waypoints.push_back(waypoint.Finish()); waypoints.push_back(waypoint->Finish());
} }
return fb_result.CreateVector(waypoints); return fb_result.CreateVector(waypoints);

View File

@ -2,6 +2,7 @@
#define ENGINE_API_NEAREST_API_HPP #define ENGINE_API_NEAREST_API_HPP
#include "engine/api/base_api.hpp" #include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/nearest_parameters.hpp" #include "engine/api/nearest_parameters.hpp"
#include "engine/api/json_factory.hpp" #include "engine/api/json_factory.hpp"
@ -54,25 +55,32 @@ class NearestAPI final : public BaseAPI
data_version_string = fb_result.CreateString(data_timestamp); data_version_string = fb_result.CreateString(data_timestamp);
} }
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints; flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
waypoints.resize(phantom_nodes.front().size()); waypoints_vector;
std::transform(phantom_nodes.front().begin(), if (!parameters.skip_waypoints)
phantom_nodes.front().end(), {
waypoints.begin(), std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) { waypoints.resize(phantom_nodes.front().size());
auto &phantom_node = phantom_with_distance.phantom_node; std::transform(
phantom_nodes.front().begin(),
phantom_nodes.front().end(),
waypoints.begin(),
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) {
auto &phantom_node = phantom_with_distance.phantom_node;
auto node_values = MakeNodes(phantom_node); auto node_values = MakeNodes(phantom_node);
fbresult::Uint64Pair nodes{node_values.first, node_values.second}; fbresult::Uint64Pair nodes{node_values.first, node_values.second};
auto waypoint = MakeWaypoint(fb_result, phantom_node); auto waypoint = MakeWaypoint(&fb_result, phantom_node);
waypoint.add_nodes(&nodes); waypoint->add_nodes(&nodes);
return waypoint->Finish();
});
return waypoint.Finish(); waypoints_vector = fb_result.CreateVector(waypoints);
}); }
auto waypoints_vector = fb_result.CreateVector(waypoints);
fbresult::FBResultBuilder response(fb_result); fbresult::FBResultBuilder response(fb_result);
response.add_waypoints(waypoints_vector); response.add_waypoints(waypoints_vector);
if (data_version_string) if (data_version_string)
{ {
@ -83,28 +91,31 @@ class NearestAPI final : public BaseAPI
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
util::json::Object &response) const util::json::Object &response) const
{ {
util::json::Array waypoints; if (!parameters.skip_waypoints)
waypoints.values.resize(phantom_nodes.front().size()); {
std::transform(phantom_nodes.front().begin(), util::json::Array waypoints;
phantom_nodes.front().end(), waypoints.values.resize(phantom_nodes.front().size());
waypoints.values.begin(), std::transform(phantom_nodes.front().begin(),
[this](const PhantomNodeWithDistance &phantom_with_distance) { phantom_nodes.front().end(),
auto &phantom_node = phantom_with_distance.phantom_node; waypoints.values.begin(),
auto waypoint = MakeWaypoint(phantom_node); [this](const PhantomNodeWithDistance &phantom_with_distance) {
auto &phantom_node = phantom_with_distance.phantom_node;
auto waypoint = MakeWaypoint(phantom_node);
util::json::Array nodes; util::json::Array nodes;
auto node_values = MakeNodes(phantom_node); auto node_values = MakeNodes(phantom_node);
nodes.values.push_back(node_values.first); nodes.values.push_back(node_values.first);
nodes.values.push_back(node_values.second); nodes.values.push_back(node_values.second);
waypoint.values["nodes"] = std::move(nodes); waypoint.values["nodes"] = std::move(nodes);
return waypoint; return waypoint;
}); });
response.values["waypoints"] = std::move(waypoints);
}
response.values["code"] = "Ok"; response.values["code"] = "Ok";
response.values["waypoints"] = std::move(waypoints);
} }
const NearestParameters &parameters; const NearestParameters &parameters;

View File

@ -3,6 +3,7 @@
#include "extractor/maneuver_override.hpp" #include "extractor/maneuver_override.hpp"
#include "engine/api/base_api.hpp" #include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/json_factory.hpp" #include "engine/api/json_factory.hpp"
#include "engine/api/route_parameters.hpp" #include "engine/api/route_parameters.hpp"
@ -72,7 +73,7 @@ class RouteAPI : public BaseAPI
{ {
auto data_timestamp = facade.GetTimestamp(); auto data_timestamp = facade.GetTimestamp();
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; flatbuffers::Offset<flatbuffers::String> data_version_string;
if (!data_timestamp.empty()) if (!data_timestamp.empty())
{ {
data_version_string = fb_result.CreateString(data_timestamp); data_version_string = fb_result.CreateString(data_timestamp);
@ -80,14 +81,14 @@ class RouteAPI : public BaseAPI
auto response = auto response =
MakeFBResponse(raw_routes, fb_result, [this, &all_start_end_points, &fb_result]() { MakeFBResponse(raw_routes, fb_result, [this, &all_start_end_points, &fb_result]() {
return BaseAPI::MakeWaypoints(fb_result, all_start_end_points); return BaseAPI::MakeWaypoints(&fb_result, all_start_end_points);
}); });
if (data_version_string) if (!data_timestamp.empty())
{ {
response.add_data_version(*data_version_string); response->add_data_version(data_version_string);
} }
fb_result.Finish(response.Finish()); fb_result.Finish(response->Finish());
} }
void void
@ -109,7 +110,10 @@ class RouteAPI : public BaseAPI
route.target_traversed_in_reverse)); route.target_traversed_in_reverse));
} }
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points); if (!parameters.skip_waypoints)
{
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
}
response.values["routes"] = std::move(jsRoutes); response.values["routes"] = std::move(jsRoutes);
response.values["code"] = "Ok"; response.values["code"] = "Ok";
auto data_timestamp = facade.GetTimestamp(); auto data_timestamp = facade.GetTimestamp();
@ -121,9 +125,10 @@ class RouteAPI : public BaseAPI
protected: protected:
template <typename GetWptsFn> template <typename GetWptsFn>
fbresult::FBResultBuilder MakeFBResponse(const InternalManyRoutesResult &raw_routes, std::unique_ptr<fbresult::FBResultBuilder>
flatbuffers::FlatBufferBuilder &fb_result, MakeFBResponse(const InternalManyRoutesResult &raw_routes,
GetWptsFn getWaypoints) const flatbuffers::FlatBufferBuilder &fb_result,
GetWptsFn getWaypoints) const
{ {
std::vector<flatbuffers::Offset<fbresult::RouteObject>> routes; std::vector<flatbuffers::Offset<fbresult::RouteObject>> routes;
@ -140,11 +145,16 @@ class RouteAPI : public BaseAPI
} }
auto routes_vector = fb_result.CreateVector(routes); auto routes_vector = fb_result.CreateVector(routes);
auto waypoints_vector = getWaypoints(); flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
waypoints_vector;
if (!parameters.skip_waypoints)
{
waypoints_vector = getWaypoints();
}
fbresult::FBResultBuilder response(fb_result); auto response = std::make_unique<fbresult::FBResultBuilder>(fb_result);
response.add_routes(routes_vector); response->add_routes(routes_vector);
response.add_waypoints(waypoints_vector); response->add_waypoints(waypoints_vector);
return response; return response;
} }
@ -363,8 +373,7 @@ class RouteAPI : public BaseAPI
requested_annotations = RouteParameters::AnnotationsType::All; requested_annotations = RouteParameters::AnnotationsType::All;
} }
boost::optional<flatbuffers::Offset<fbresult::Annotation>> annotation_buffer = flatbuffers::Offset<fbresult::Annotation> annotation_buffer;
boost::none;
if (requested_annotations != RouteParameters::AnnotationsType::None) if (requested_annotations != RouteParameters::AnnotationsType::None)
{ {
annotation_buffer = annotation_buffer =
@ -387,9 +396,9 @@ class RouteAPI : public BaseAPI
} }
legBuilder.add_steps(steps_vector); legBuilder.add_steps(steps_vector);
if (annotation_buffer) if (requested_annotations != RouteParameters::AnnotationsType::None)
{ {
legBuilder.add_annotations(*annotation_buffer); legBuilder.add_annotations(annotation_buffer);
} }
routeLegs.emplace_back(legBuilder.Finish()); routeLegs.emplace_back(legBuilder.Finish());
} }
@ -496,8 +505,9 @@ class RouteAPI : public BaseAPI
} }
auto nodes_vector = fb_result.CreateVector(nodes); auto nodes_vector = fb_result.CreateVector(nodes);
// Add any supporting metadata, if needed // Add any supporting metadata, if needed
boost::optional<flatbuffers::Offset<fbresult::Metadata>> metadata_buffer = boost::none; bool use_metadata = requested_annotations & RouteParameters::AnnotationsType::Datasources;
if (requested_annotations & RouteParameters::AnnotationsType::Datasources) flatbuffers::Offset<fbresult::Metadata> metadata_buffer;
if (use_metadata)
{ {
const auto MAX_DATASOURCE_ID = 255u; const auto MAX_DATASOURCE_ID = 255u;
std::vector<flatbuffers::Offset<flatbuffers::String>> names; std::vector<flatbuffers::Offset<flatbuffers::String>> names;
@ -519,9 +529,9 @@ class RouteAPI : public BaseAPI
annotation.add_weight(weight); annotation.add_weight(weight);
annotation.add_datasources(datasources); annotation.add_datasources(datasources);
annotation.add_nodes(nodes_vector); annotation.add_nodes(nodes_vector);
if (metadata_buffer) if (use_metadata)
{ {
annotation.add_metadata(*metadata_buffer); annotation.add_metadata(metadata_buffer);
} }
return annotation.Finish(); return annotation.Finish();
@ -647,7 +657,6 @@ class RouteAPI : public BaseAPI
step.intersections.end(), step.intersections.end(),
intersections.begin(), intersections.begin(),
[&fb_result, this](const guidance::IntermediateIntersection &intersection) { [&fb_result, this](const guidance::IntermediateIntersection &intersection) {
std::vector<flatbuffers::Offset<fbresult::Lane>> lanes; std::vector<flatbuffers::Offset<fbresult::Lane>> lanes;
if (json::detail::hasValidLanes(intersection)) if (json::detail::hasValidLanes(intersection))
{ {

View File

@ -2,6 +2,7 @@
#define ENGINE_API_TABLE_HPP #define ENGINE_API_TABLE_HPP
#include "engine/api/base_api.hpp" #include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/json_factory.hpp" #include "engine/api/json_factory.hpp"
#include "engine/api/table_parameters.hpp" #include "engine/api/table_parameters.hpp"
@ -73,7 +74,7 @@ class TableAPI final : public BaseAPI
auto number_of_destinations = parameters.destinations.size(); auto number_of_destinations = parameters.destinations.size();
auto data_timestamp = facade.GetTimestamp(); auto data_timestamp = facade.GetTimestamp();
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; flatbuffers::Offset<flatbuffers::String> data_version_string;
if (!data_timestamp.empty()) if (!data_timestamp.empty())
{ {
data_version_string = fb_result.CreateString(data_timestamp); data_version_string = fb_result.CreateString(data_timestamp);
@ -83,41 +84,56 @@ class TableAPI final : public BaseAPI
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources; flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources;
if (parameters.sources.empty()) if (parameters.sources.empty())
{ {
sources = MakeWaypoints(fb_result, phantoms); if (!parameters.skip_waypoints)
{
sources = MakeWaypoints(fb_result, phantoms);
}
number_of_sources = phantoms.size(); number_of_sources = phantoms.size();
} }
else else
{ {
sources = MakeWaypoints(fb_result, phantoms, parameters.sources); if (!parameters.skip_waypoints)
{
sources = MakeWaypoints(fb_result, phantoms, parameters.sources);
}
} }
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
destinations; destinations;
if (parameters.destinations.empty()) if (parameters.destinations.empty())
{ {
destinations = MakeWaypoints(fb_result, phantoms); if (!parameters.skip_waypoints)
{
destinations = MakeWaypoints(fb_result, phantoms);
}
number_of_destinations = phantoms.size(); number_of_destinations = phantoms.size();
} }
else else
{ {
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations); if (!parameters.skip_waypoints)
{
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations);
}
} }
boost::optional<flatbuffers::Offset<flatbuffers::Vector<float>>> durations = boost::none; bool use_durations = parameters.annotations & TableParameters::AnnotationsType::Duration;
if (parameters.annotations & TableParameters::AnnotationsType::Duration) flatbuffers::Offset<flatbuffers::Vector<float>> durations;
if (use_durations)
{ {
durations = MakeDurationTable(fb_result, tables.first); durations = MakeDurationTable(fb_result, tables.first);
} }
boost::optional<flatbuffers::Offset<flatbuffers::Vector<float>>> distances = boost::none; bool use_distances = parameters.annotations & TableParameters::AnnotationsType::Distance;
if (parameters.annotations & TableParameters::AnnotationsType::Distance) flatbuffers::Offset<flatbuffers::Vector<float>> distances;
if (use_distances)
{ {
distances = MakeDistanceTable(fb_result, tables.second); distances = MakeDistanceTable(fb_result, tables.second);
} }
boost::optional<flatbuffers::Offset<flatbuffers::Vector<uint32_t>>> speed_cells = bool have_speed_cells =
boost::none; parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0;
if (parameters.fallback_speed != INVALID_FALLBACK_SPEED && parameters.fallback_speed > 0) flatbuffers::Offset<flatbuffers::Vector<uint32_t>> speed_cells;
if (have_speed_cells)
{ {
speed_cells = MakeEstimatesTable(fb_result, fallback_speed_cells); speed_cells = MakeEstimatesTable(fb_result, fallback_speed_cells);
} }
@ -126,24 +142,24 @@ class TableAPI final : public BaseAPI
table.add_destinations(destinations); table.add_destinations(destinations);
table.add_rows(number_of_sources); table.add_rows(number_of_sources);
table.add_cols(number_of_destinations); table.add_cols(number_of_destinations);
if (durations) if (use_durations)
{ {
table.add_durations(*durations); table.add_durations(durations);
} }
if (distances) if (use_distances)
{ {
table.add_distances(*distances); table.add_distances(distances);
} }
if (speed_cells) if (have_speed_cells)
{ {
table.add_fallback_speed_cells(*speed_cells); table.add_fallback_speed_cells(speed_cells);
} }
auto table_buffer = table.Finish(); auto table_buffer = table.Finish();
fbresult::FBResultBuilder response(fb_result); fbresult::FBResultBuilder response(fb_result);
if (data_version_string) if (!data_timestamp.empty())
{ {
response.add_data_version(*data_version_string); response.add_data_version(data_version_string);
} }
response.add_table(table_buffer); response.add_table(table_buffer);
response.add_waypoints(sources); response.add_waypoints(sources);
@ -162,22 +178,34 @@ class TableAPI final : public BaseAPI
// symmetric case // symmetric case
if (parameters.sources.empty()) if (parameters.sources.empty())
{ {
response.values["sources"] = MakeWaypoints(phantoms); if (!parameters.skip_waypoints)
{
response.values["sources"] = MakeWaypoints(phantoms);
}
number_of_sources = phantoms.size(); number_of_sources = phantoms.size();
} }
else else
{ {
response.values["sources"] = MakeWaypoints(phantoms, parameters.sources); if (!parameters.skip_waypoints)
{
response.values["sources"] = MakeWaypoints(phantoms, parameters.sources);
}
} }
if (parameters.destinations.empty()) if (parameters.destinations.empty())
{ {
response.values["destinations"] = MakeWaypoints(phantoms); if (!parameters.skip_waypoints)
{
response.values["destinations"] = MakeWaypoints(phantoms);
}
number_of_destinations = phantoms.size(); number_of_destinations = phantoms.size();
} }
else else
{ {
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations); if (!parameters.skip_waypoints)
{
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
}
} }
if (parameters.annotations & TableParameters::AnnotationsType::Duration) if (parameters.annotations & TableParameters::AnnotationsType::Duration)
@ -211,7 +239,7 @@ class TableAPI final : public BaseAPI
boost::range::transform( boost::range::transform(
phantoms, std::back_inserter(waypoints), [this, &builder](const PhantomNode &phantom) { phantoms, std::back_inserter(waypoints), [this, &builder](const PhantomNode &phantom) {
return BaseAPI::MakeWaypoint(builder, phantom).Finish(); return BaseAPI::MakeWaypoint(&builder, phantom)->Finish();
}); });
return builder.CreateVector(waypoints); return builder.CreateVector(waypoints);
} }
@ -227,7 +255,7 @@ class TableAPI final : public BaseAPI
std::back_inserter(waypoints), std::back_inserter(waypoints),
[this, &builder, phantoms](const std::size_t idx) { [this, &builder, phantoms](const std::size_t idx) {
BOOST_ASSERT(idx < phantoms.size()); BOOST_ASSERT(idx < phantoms.size());
return BaseAPI::MakeWaypoint(builder, phantoms[idx]).Finish(); return BaseAPI::MakeWaypoint(&builder, phantoms[idx])->Finish();
}); });
return builder.CreateVector(waypoints); return builder.CreateVector(waypoints);
} }

View File

@ -48,7 +48,7 @@ class TripAPI final : public RouteAPI
flatbuffers::FlatBufferBuilder &fb_result) const flatbuffers::FlatBufferBuilder &fb_result) const
{ {
auto data_timestamp = facade.GetTimestamp(); auto data_timestamp = facade.GetTimestamp();
boost::optional<flatbuffers::Offset<flatbuffers::String>> data_version_string = boost::none; flatbuffers::Offset<flatbuffers::String> data_version_string;
if (!data_timestamp.empty()) if (!data_timestamp.empty())
{ {
data_version_string = fb_result.CreateString(data_timestamp); data_version_string = fb_result.CreateString(data_timestamp);
@ -59,11 +59,11 @@ class TripAPI final : public RouteAPI
return MakeWaypoints(fb_result, sub_trips, phantoms); return MakeWaypoints(fb_result, sub_trips, phantoms);
}); });
if (data_version_string) if (!data_timestamp.empty())
{ {
response.add_data_version(*data_version_string); response->add_data_version(data_version_string);
} }
fb_result.Finish(response.Finish()); fb_result.Finish(response->Finish());
} }
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips, void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
const std::vector<InternalRouteResult> &sub_routes, const std::vector<InternalRouteResult> &sub_routes,
@ -81,7 +81,10 @@ class TripAPI final : public RouteAPI
sub_routes[index].target_traversed_in_reverse); sub_routes[index].target_traversed_in_reverse);
routes.values.push_back(std::move(route)); routes.values.push_back(std::move(route));
} }
response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); if (!parameters.skip_waypoints)
{
response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms);
}
response.values["trips"] = std::move(routes); response.values["trips"] = std::move(routes);
response.values["code"] = "Ok"; response.values["code"] = "Ok";
} }
@ -124,10 +127,10 @@ class TripAPI final : public RouteAPI
auto trip_index = input_idx_to_trip_idx[input_index]; auto trip_index = input_idx_to_trip_idx[input_index];
BOOST_ASSERT(!trip_index.NotUsed()); BOOST_ASSERT(!trip_index.NotUsed());
auto waypoint = BaseAPI::MakeWaypoint(fb_result, phantoms[input_index]); auto waypoint = BaseAPI::MakeWaypoint(&fb_result, phantoms[input_index]);
waypoint.add_waypoint_index(trip_index.point_index); waypoint->add_waypoint_index(trip_index.point_index);
waypoint.add_trips_index(trip_index.sub_trip_index); waypoint->add_trips_index(trip_index.sub_trip_index);
waypoints.push_back(waypoint.Finish()); waypoints.push_back(waypoint->Finish());
} }
return fb_result.CreateVector(waypoints); return fb_result.CreateVector(waypoints);

View File

@ -192,17 +192,22 @@ void annotatePath(const FacadeT &facade,
const bool is_first_segment = unpacked_path.empty(); const bool is_first_segment = unpacked_path.empty();
const std::size_t start_index = std::size_t start_index = 0;
(is_first_segment ? ((start_traversed_in_reverse) if (is_first_segment)
? weight_vector.size() - {
phantom_node_pair.source_phantom.fwd_segment_position - 1 unsigned short segment_position = phantom_node_pair.source_phantom.fwd_segment_position;
: phantom_node_pair.source_phantom.fwd_segment_position) if (start_traversed_in_reverse)
: 0); {
segment_position = weight_vector.size() -
phantom_node_pair.source_phantom.fwd_segment_position - 1;
}
BOOST_ASSERT(segment_position >= 0);
start_index = static_cast<std::size_t>(segment_position);
}
const std::size_t end_index = weight_vector.size(); const std::size_t end_index = weight_vector.size();
bool is_left_hand_driving = facade.IsLeftHandDriving(node_id); bool is_left_hand_driving = facade.IsLeftHandDriving(node_id);
BOOST_ASSERT(start_index >= 0);
BOOST_ASSERT(start_index < end_index); BOOST_ASSERT(start_index < end_index);
for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx) for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx)
{ {

View File

@ -85,33 +85,6 @@ struct InternalExtractorEdge
DurationData duration_data; DurationData duration_data;
// coordinate of the source node // coordinate of the source node
util::Coordinate source_coordinate; util::Coordinate source_coordinate;
// necessary static util functions for stxxl's sorting
static InternalExtractorEdge min_osm_value()
{
return InternalExtractorEdge(
MIN_OSM_NODEID, MIN_OSM_NODEID, WeightData(), DurationData(), util::Coordinate());
}
static InternalExtractorEdge max_osm_value()
{
return InternalExtractorEdge(
MAX_OSM_NODEID, MAX_OSM_NODEID, WeightData(), DurationData(), util::Coordinate());
}
static InternalExtractorEdge min_internal_value()
{
auto v = min_osm_value();
v.result.source = 0;
v.result.target = 0;
return v;
}
static InternalExtractorEdge max_internal_value()
{
auto v = max_osm_value();
v.result.source = std::numeric_limits<NodeID>::max();
v.result.target = std::numeric_limits<NodeID>::max();
return v;
}
}; };
} }
} }

77
include/extractor/raster_source.hpp Normal file → Executable file
View File

@ -4,16 +4,21 @@
#include "util/coordinate.hpp" #include "util/coordinate.hpp"
#include "util/exception.hpp" #include "util/exception.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_int.hpp> #include <boost/spirit/include/qi_int.hpp>
#include <storage/io.hpp> #include <storage/io.hpp>
#include <iterator> #include <iterator>
#include <string>
#include <unordered_map> #include <unordered_map>
using namespace std;
namespace osrm namespace osrm
{ {
@ -43,37 +48,31 @@ class RasterGrid
xdim = _xdim; xdim = _xdim;
ydim = _ydim; ydim = _ydim;
_data.reserve(ydim * xdim); _data.reserve(ydim * xdim);
BOOST_ASSERT(ydim * xdim <= _data.capacity());
// Construct FileReader
storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint); storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint);
std::string buffer; std::string buffer;
buffer.resize(file_reader.GetSize()); buffer.resize(xdim * 11); // INT32_MAX = 2147483647 = 10 chars + 1 white space = 11
BOOST_ASSERT(xdim * 11 <= buffer.size());
BOOST_ASSERT(buffer.size() > 1); for (unsigned int y = 0; y < ydim; y++)
file_reader.ReadInto(&buffer[0], buffer.size());
boost::algorithm::trim(buffer);
auto itr = buffer.begin();
auto end = buffer.end();
bool r = false;
try
{ {
r = boost::spirit::qi::parse( // read one line from file.
itr, end, +boost::spirit::qi::int_ % +boost::spirit::qi::space, _data); file_reader.ReadLine(&buffer[0], xdim * 11);
} boost::algorithm::trim(buffer);
catch (std::exception const &ex)
{
throw util::exception("Failed to read from raster source " + filepath.string() + ": " +
ex.what() + SOURCE_REF);
}
if (!r || itr != end) std::vector<std::string> result;
{ boost::split(
throw util::exception("Failed to parse raster source: " + filepath.string() + result, buffer, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on);
SOURCE_REF); unsigned int x = 0;
for (const auto &s : result)
{
if (x < xdim)
_data[(y * xdim) + x] = atoi(s.c_str());
++x;
}
BOOST_ASSERT(x == xdim);
} }
} }
@ -143,8 +142,36 @@ class RasterContainer
RasterDatum GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat); RasterDatum GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat);
private: private:
};
// << singletone >> RasterCache
// The instance of RasterContainer is created for every threads osrm-extract uses.
// To avoid multiple load of same file on each RasterContainer,
// The LoadedSources and LoadedSourcePaths are separated to RasterCache class
// and handled as the singletone pattern to avoid duplicate creation.
class RasterCache
{
public:
// class method to get the instance
static RasterCache &getInstance()
{
if (NULL == g_instance)
{
g_instance = new RasterCache();
}
return *g_instance;
}
// get reference of cache
std::vector<RasterSource> &getLoadedSources() { return LoadedSources; }
std::unordered_map<std::string, int> &getLoadedSourcePaths() { return LoadedSourcePaths; }
private:
// constructor
RasterCache() = default;
// member
std::vector<RasterSource> LoadedSources; std::vector<RasterSource> LoadedSources;
std::unordered_map<std::string, int> LoadedSourcePaths; std::unordered_map<std::string, int> LoadedSourcePaths;
// the instance
static RasterCache *g_instance;
}; };
} }
} }

View File

@ -37,8 +37,11 @@ struct Engine final : public Nan::ObjectWrap
std::shared_ptr<osrm::OSRM> this_; std::shared_ptr<osrm::OSRM> this_;
}; };
} // ns node_osrm } // namespace node_osrm
NODE_MODULE(osrm, node_osrm::Engine::Init) #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
NAN_MODULE_WORKER_ENABLED(osrm, node_osrm::Engine::Init)
#pragma GCC diagnostic pop
#endif #endif

View File

@ -116,8 +116,8 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
if (args[0]->IsString()) if (args[0]->IsString())
{ {
engine_config->storage_config = osrm::StorageConfig( engine_config->storage_config =
*v8::String::Utf8Value(Nan::To<v8::String>(args[0]).ToLocalChecked())); osrm::StorageConfig(*Nan::Utf8String(Nan::To<v8::String>(args[0]).ToLocalChecked()));
engine_config->use_shared_memory = false; engine_config->use_shared_memory = false;
return engine_config; return engine_config;
} }
@ -155,7 +155,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
} }
engine_config->memory_file = engine_config->memory_file =
*v8::String::Utf8Value(Nan::To<v8::String>(memory_file).ToLocalChecked()); *Nan::Utf8String(Nan::To<v8::String>(memory_file).ToLocalChecked());
} }
auto dataset_name = params->Get(Nan::New("dataset_name").ToLocalChecked()); auto dataset_name = params->Get(Nan::New("dataset_name").ToLocalChecked());
@ -166,7 +166,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
if (dataset_name->IsString()) if (dataset_name->IsString())
{ {
engine_config->dataset_name = engine_config->dataset_name =
*v8::String::Utf8Value(Nan::To<v8::String>(dataset_name).ToLocalChecked()); *Nan::Utf8String(Nan::To<v8::String>(dataset_name).ToLocalChecked());
} }
else else
{ {
@ -178,7 +178,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
if (!path->IsUndefined()) if (!path->IsUndefined())
{ {
engine_config->storage_config = engine_config->storage_config =
osrm::StorageConfig(*v8::String::Utf8Value(Nan::To<v8::String>(path).ToLocalChecked())); osrm::StorageConfig(*Nan::Utf8String(Nan::To<v8::String>(path).ToLocalChecked()));
engine_config->use_shared_memory = false; engine_config->use_shared_memory = false;
} }
@ -221,15 +221,15 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
if (algorithm->IsString()) if (algorithm->IsString())
{ {
auto algorithm_str = Nan::To<v8::String>(algorithm).ToLocalChecked(); auto algorithm_str = Nan::To<v8::String>(algorithm).ToLocalChecked();
if (*v8::String::Utf8Value(algorithm_str) == std::string("CH")) if (*Nan::Utf8String(algorithm_str) == std::string("CH"))
{ {
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH; engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
} }
else if (*v8::String::Utf8Value(algorithm_str) == std::string("CoreCH")) else if (*Nan::Utf8String(algorithm_str) == std::string("CoreCH"))
{ {
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH; engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
} }
else if (*v8::String::Utf8Value(algorithm_str) == std::string("MLD")) else if (*Nan::Utf8String(algorithm_str) == std::string("MLD"))
{ {
engine_config->algorithm = osrm::EngineConfig::Algorithm::MLD; engine_config->algorithm = osrm::EngineConfig::Algorithm::MLD;
} }
@ -290,23 +290,22 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
} }
if (max_locations_trip->IsNumber()) if (max_locations_trip->IsNumber())
engine_config->max_locations_trip = static_cast<int>(max_locations_trip->NumberValue()); engine_config->max_locations_trip = Nan::To<int>(max_locations_trip).FromJust();
if (max_locations_viaroute->IsNumber()) if (max_locations_viaroute->IsNumber())
engine_config->max_locations_viaroute = engine_config->max_locations_viaroute = Nan::To<int>(max_locations_viaroute).FromJust();
static_cast<int>(max_locations_viaroute->NumberValue());
if (max_locations_distance_table->IsNumber()) if (max_locations_distance_table->IsNumber())
engine_config->max_locations_distance_table = engine_config->max_locations_distance_table =
static_cast<int>(max_locations_distance_table->NumberValue()); Nan::To<int>(max_locations_distance_table).FromJust();
if (max_locations_map_matching->IsNumber()) if (max_locations_map_matching->IsNumber())
engine_config->max_locations_map_matching = engine_config->max_locations_map_matching =
static_cast<int>(max_locations_map_matching->NumberValue()); Nan::To<int>(max_locations_map_matching).FromJust();
if (max_results_nearest->IsNumber()) if (max_results_nearest->IsNumber())
engine_config->max_results_nearest = static_cast<int>(max_results_nearest->NumberValue()); engine_config->max_results_nearest = Nan::To<int>(max_results_nearest).FromJust();
if (max_alternatives->IsNumber()) if (max_alternatives->IsNumber())
engine_config->max_alternatives = static_cast<int>(max_alternatives->NumberValue()); engine_config->max_alternatives = Nan::To<int>(max_alternatives).FromJust();
if (max_radius_map_matching->IsNumber()) if (max_radius_map_matching->IsNumber())
engine_config->max_radius_map_matching = engine_config->max_radius_map_matching =
static_cast<double>(max_radius_map_matching->NumberValue()); Nan::To<double>(max_radius_map_matching).FromJust();
return engine_config; return engine_config;
} }
@ -343,8 +342,8 @@ parseCoordinateArray(const v8::Local<v8::Array> &coordinates_array)
return resulting_coordinates; return resulting_coordinates;
} }
double lon = coordinate_pair->Get(0)->NumberValue(); double lon = Nan::To<double>(coordinate_pair->Get(0)).FromJust();
double lat = coordinate_pair->Get(1)->NumberValue(); double lat = Nan::To<double>(coordinate_pair->Get(1)).FromJust();
if (std::isnan(lon) || std::isnan(lat) || std::isinf(lon) || std::isinf(lat)) if (std::isnan(lon) || std::isnan(lat) || std::isinf(lon) || std::isinf(lat))
{ {
@ -430,7 +429,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
return false; return false;
} }
if (obj->Has(Nan::New("approaches").ToLocalChecked())) if (Nan::Has(obj, Nan::New("approaches").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> approaches = obj->Get(Nan::New("approaches").ToLocalChecked()); v8::Local<v8::Value> approaches = obj->Get(Nan::New("approaches").ToLocalChecked());
if (approaches.IsEmpty()) if (approaches.IsEmpty())
@ -487,7 +486,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
} }
} }
if (obj->Has(Nan::New("bearings").ToLocalChecked())) if (Nan::Has(obj, Nan::New("bearings").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> bearings = obj->Get(Nan::New("bearings").ToLocalChecked()); v8::Local<v8::Value> bearings = obj->Get(Nan::New("bearings").ToLocalChecked());
if (bearings.IsEmpty()) if (bearings.IsEmpty())
@ -528,8 +527,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
return false; return false;
} }
const auto bearing = static_cast<short>(bearing_pair->Get(0)->NumberValue()); const auto bearing = Nan::To<int>(bearing_pair->Get(0)).FromJust();
const auto range = static_cast<short>(bearing_pair->Get(1)->NumberValue()); const auto range = Nan::To<int>(bearing_pair->Get(1)).FromJust();
if (bearing < 0 || bearing > 360 || range < 0 || range > 180) if (bearing < 0 || bearing > 360 || range < 0 || range > 180)
{ {
@ -537,7 +536,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
return false; return false;
} }
params->bearings.push_back(osrm::Bearing{bearing, range}); params->bearings.push_back(
osrm::Bearing{static_cast<short>(bearing), static_cast<short>(range)});
} }
else else
{ {
@ -553,7 +553,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
} }
} }
if (obj->Has(Nan::New("hints").ToLocalChecked())) if (Nan::Has(obj, Nan::New("hints").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> hints = obj->Get(Nan::New("hints").ToLocalChecked()); v8::Local<v8::Value> hints = obj->Get(Nan::New("hints").ToLocalChecked());
if (hints.IsEmpty()) if (hints.IsEmpty())
@ -581,14 +581,13 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (hint->IsString()) if (hint->IsString())
{ {
if (hint->ToString()->Length() == 0) if (Nan::To<v8::String>(hint).ToLocalChecked()->Length() == 0)
{ {
Nan::ThrowError("Hint cannot be an empty string"); Nan::ThrowError("Hint cannot be an empty string");
return false; return false;
} }
params->hints.push_back( params->hints.push_back(osrm::engine::Hint::FromBase64(*Nan::Utf8String(hint)));
osrm::engine::Hint::FromBase64(*v8::String::Utf8Value(hint)));
} }
else if (hint->IsNull()) else if (hint->IsNull())
{ {
@ -602,7 +601,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
} }
} }
if (obj->Has(Nan::New("radiuses").ToLocalChecked())) if (Nan::Has(obj, Nan::New("radiuses").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> radiuses = obj->Get(Nan::New("radiuses").ToLocalChecked()); v8::Local<v8::Value> radiuses = obj->Get(Nan::New("radiuses").ToLocalChecked());
if (radiuses.IsEmpty()) if (radiuses.IsEmpty())
@ -632,9 +631,9 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
{ {
params->radiuses.emplace_back(); params->radiuses.emplace_back();
} }
else if (radius->IsNumber() && radius->NumberValue() >= 0) else if (radius->IsNumber() && Nan::To<double>(radius).FromJust() >= 0)
{ {
params->radiuses.push_back(static_cast<double>(radius->NumberValue())); params->radiuses.push_back(Nan::To<double>(radius).FromJust());
} }
else else
{ {
@ -644,7 +643,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
} }
} }
if (obj->Has(Nan::New("generate_hints").ToLocalChecked())) if (Nan::Has(obj, Nan::New("generate_hints").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> generate_hints = obj->Get(Nan::New("generate_hints").ToLocalChecked()); v8::Local<v8::Value> generate_hints = obj->Get(Nan::New("generate_hints").ToLocalChecked());
if (generate_hints.IsEmpty()) if (generate_hints.IsEmpty())
@ -656,10 +655,10 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
return false; return false;
} }
params->generate_hints = generate_hints->BooleanValue(); params->generate_hints = Nan::To<bool>(generate_hints).FromJust();
} }
if (obj->Has(Nan::New("exclude").ToLocalChecked())) if (Nan::Has(obj, Nan::New("exclude").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> exclude = obj->Get(Nan::New("exclude").ToLocalChecked()); v8::Local<v8::Value> exclude = obj->Get(Nan::New("exclude").ToLocalChecked());
if (exclude.IsEmpty()) if (exclude.IsEmpty())
@ -681,7 +680,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (class_name->IsString()) if (class_name->IsString())
{ {
std::string class_name_str = *v8::String::Utf8Value(class_name); std::string class_name_str = *Nan::Utf8String(class_name);
params->exclude.emplace_back(class_name_str); params->exclude.emplace_back(class_name_str);
} }
else else
@ -698,7 +697,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
template <typename ParamType> template <typename ParamType>
inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &params) inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &params)
{ {
if (obj->Has(Nan::New("steps").ToLocalChecked())) if (Nan::Has(obj, Nan::New("steps").ToLocalChecked()).FromJust())
{ {
auto steps = obj->Get(Nan::New("steps").ToLocalChecked()); auto steps = obj->Get(Nan::New("steps").ToLocalChecked());
if (steps.IsEmpty()) if (steps.IsEmpty())
@ -706,7 +705,7 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (steps->IsBoolean()) if (steps->IsBoolean())
{ {
params->steps = steps->BooleanValue(); params->steps = Nan::To<bool>(steps).FromJust();
} }
else else
{ {
@ -715,7 +714,7 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
} }
} }
if (obj->Has(Nan::New("annotations").ToLocalChecked())) if (Nan::Has(obj, Nan::New("annotations").ToLocalChecked()).FromJust())
{ {
auto annotations = obj->Get(Nan::New("annotations").ToLocalChecked()); auto annotations = obj->Get(Nan::New("annotations").ToLocalChecked());
if (annotations.IsEmpty()) if (annotations.IsEmpty())
@ -723,7 +722,7 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (annotations->IsBoolean()) if (annotations->IsBoolean())
{ {
params->annotations = annotations->BooleanValue(); params->annotations = Nan::To<bool>(annotations).FromJust();
} }
else if (annotations->IsArray()) else if (annotations->IsArray())
{ {
@ -778,7 +777,7 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
} }
} }
if (obj->Has(Nan::New("geometries").ToLocalChecked())) if (Nan::Has(obj, Nan::New("geometries").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> geometries = obj->Get(Nan::New("geometries").ToLocalChecked()); v8::Local<v8::Value> geometries = obj->Get(Nan::New("geometries").ToLocalChecked());
if (geometries.IsEmpty()) if (geometries.IsEmpty())
@ -812,7 +811,7 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
} }
} }
if (obj->Has(Nan::New("overview").ToLocalChecked())) if (Nan::Has(obj, Nan::New("overview").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> overview = obj->Get(Nan::New("overview").ToLocalChecked()); v8::Local<v8::Value> overview = obj->Get(Nan::New("overview").ToLocalChecked());
if (overview.IsEmpty()) if (overview.IsEmpty())
@ -857,7 +856,7 @@ argumentsToPluginParameters(const Nan::FunctionCallbackInfo<v8::Value> &args)
return {}; return {};
} }
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[1]).ToLocalChecked(); v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[1]).ToLocalChecked();
if (obj->Has(Nan::New("format").ToLocalChecked())) if (Nan::Has(obj, Nan::New("format").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> format = obj->Get(Nan::New("format").ToLocalChecked()); v8::Local<v8::Value> format = obj->Get(Nan::New("format").ToLocalChecked());
@ -904,7 +903,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked(); v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked();
if (obj->Has(Nan::New("continue_straight").ToLocalChecked())) if (Nan::Has(obj, Nan::New("continue_straight").ToLocalChecked()).FromJust())
{ {
auto value = obj->Get(Nan::New("continue_straight").ToLocalChecked()); auto value = obj->Get(Nan::New("continue_straight").ToLocalChecked());
if (value.IsEmpty()) if (value.IsEmpty())
@ -917,11 +916,11 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
if (value->IsBoolean()) if (value->IsBoolean())
{ {
params->continue_straight = value->BooleanValue(); params->continue_straight = Nan::To<bool>(value).FromJust();
} }
} }
if (obj->Has(Nan::New("alternatives").ToLocalChecked())) if (Nan::Has(obj, Nan::New("alternatives").ToLocalChecked()).FromJust())
{ {
auto value = obj->Get(Nan::New("alternatives").ToLocalChecked()); auto value = obj->Get(Nan::New("alternatives").ToLocalChecked());
if (value.IsEmpty()) if (value.IsEmpty())
@ -929,13 +928,13 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (value->IsBoolean()) if (value->IsBoolean())
{ {
params->alternatives = value->BooleanValue(); params->alternatives = Nan::To<bool>(value).FromJust();
params->number_of_alternatives = value->BooleanValue() ? 1u : 0u; params->number_of_alternatives = Nan::To<bool>(value).FromJust() ? 1u : 0u;
} }
else if (value->IsNumber()) else if (value->IsNumber())
{ {
params->alternatives = value->BooleanValue(); params->alternatives = Nan::To<bool>(value).FromJust();
params->number_of_alternatives = static_cast<unsigned>(value->NumberValue()); params->number_of_alternatives = Nan::To<unsigned>(value).FromJust();
} }
else else
{ {
@ -944,7 +943,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("waypoints").ToLocalChecked())) if (Nan::Has(obj, Nan::New("waypoints").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked()); v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked());
if (waypoints.IsEmpty()) if (waypoints.IsEmpty())
@ -994,7 +993,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
Nan::ThrowError("Waypoints must correspond with the index of an input coordinate"); Nan::ThrowError("Waypoints must correspond with the index of an input coordinate");
return route_parameters_ptr(); return route_parameters_ptr();
} }
params->waypoints.emplace_back(static_cast<unsigned>(waypoint_value->NumberValue())); params->waypoints.emplace_back(Nan::To<unsigned>(waypoint_value).FromJust());
} }
if (!params->waypoints.empty()) if (!params->waypoints.empty())
@ -1010,7 +1009,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("snapping").ToLocalChecked())) if (Nan::Has(obj, Nan::New("snapping").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> snapping = obj->Get(Nan::New("snapping").ToLocalChecked()); v8::Local<v8::Value> snapping = obj->Get(Nan::New("snapping").ToLocalChecked());
if (snapping.IsEmpty()) if (snapping.IsEmpty())
@ -1095,9 +1094,9 @@ argumentsToTileParameters(const Nan::FunctionCallbackInfo<v8::Value> &args, bool
return tile_parameters_ptr(); return tile_parameters_ptr();
} }
params->x = x->Uint32Value(); params->x = Nan::To<uint32_t>(x).FromJust();
params->y = y->Uint32Value(); params->y = Nan::To<uint32_t>(y).FromJust();
params->z = z->Uint32Value(); params->z = Nan::To<uint32_t>(z).FromJust();
if (!params->IsValid()) if (!params->IsValid())
{ {
@ -1121,7 +1120,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj.IsEmpty()) if (obj.IsEmpty())
return nearest_parameters_ptr(); return nearest_parameters_ptr();
if (obj->Has(Nan::New("number").ToLocalChecked())) if (Nan::Has(obj, Nan::New("number").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> number = obj->Get(Nan::New("number").ToLocalChecked()); v8::Local<v8::Value> number = obj->Get(Nan::New("number").ToLocalChecked());
@ -1132,7 +1131,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
else else
{ {
unsigned number_value = static_cast<unsigned>(number->NumberValue()); unsigned number_value = Nan::To<unsigned>(number).FromJust();
if (number_value < 1) if (number_value < 1)
{ {
@ -1140,7 +1139,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return nearest_parameters_ptr(); return nearest_parameters_ptr();
} }
params->number_of_results = static_cast<unsigned>(number->NumberValue()); params->number_of_results = Nan::To<unsigned>(number).FromJust();
} }
} }
@ -1160,7 +1159,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj.IsEmpty()) if (obj.IsEmpty())
return table_parameters_ptr(); return table_parameters_ptr();
if (obj->Has(Nan::New("sources").ToLocalChecked())) if (Nan::Has(obj, Nan::New("sources").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> sources = obj->Get(Nan::New("sources").ToLocalChecked()); v8::Local<v8::Value> sources = obj->Get(Nan::New("sources").ToLocalChecked());
if (sources.IsEmpty()) if (sources.IsEmpty())
@ -1181,7 +1180,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (source->IsUint32()) if (source->IsUint32())
{ {
size_t source_value = static_cast<size_t>(source->NumberValue()); size_t source_value = Nan::To<unsigned>(source).FromJust();
if (source_value > params->coordinates.size()) if (source_value > params->coordinates.size())
{ {
Nan::ThrowError( Nan::ThrowError(
@ -1189,7 +1188,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return table_parameters_ptr(); return table_parameters_ptr();
} }
params->sources.push_back(static_cast<size_t>(source->NumberValue())); params->sources.push_back(Nan::To<unsigned>(source).FromJust());
} }
else else
{ {
@ -1199,7 +1198,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("destinations").ToLocalChecked())) if (Nan::Has(obj, Nan::New("destinations").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> destinations = obj->Get(Nan::New("destinations").ToLocalChecked()); v8::Local<v8::Value> destinations = obj->Get(Nan::New("destinations").ToLocalChecked());
if (destinations.IsEmpty()) if (destinations.IsEmpty())
@ -1220,7 +1219,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (destination->IsUint32()) if (destination->IsUint32())
{ {
size_t destination_value = static_cast<size_t>(destination->NumberValue()); size_t destination_value = Nan::To<unsigned>(destination).FromJust();
if (destination_value > params->coordinates.size()) if (destination_value > params->coordinates.size())
{ {
Nan::ThrowError("Destination indices must be less than or equal to the number " Nan::ThrowError("Destination indices must be less than or equal to the number "
@ -1228,7 +1227,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return table_parameters_ptr(); return table_parameters_ptr();
} }
params->destinations.push_back(static_cast<size_t>(destination->NumberValue())); params->destinations.push_back(Nan::To<unsigned>(destination).FromJust());
} }
else else
{ {
@ -1238,7 +1237,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("annotations").ToLocalChecked())) if (Nan::Has(obj, Nan::New("annotations").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> annotations = obj->Get(Nan::New("annotations").ToLocalChecked()); v8::Local<v8::Value> annotations = obj->Get(Nan::New("annotations").ToLocalChecked());
if (annotations.IsEmpty()) if (annotations.IsEmpty())
@ -1278,7 +1277,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("fallback_speed").ToLocalChecked())) if (Nan::Has(obj, Nan::New("fallback_speed").ToLocalChecked()).FromJust())
{ {
auto fallback_speed = obj->Get(Nan::New("fallback_speed").ToLocalChecked()); auto fallback_speed = obj->Get(Nan::New("fallback_speed").ToLocalChecked());
@ -1287,16 +1286,16 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
Nan::ThrowError("fallback_speed must be a number"); Nan::ThrowError("fallback_speed must be a number");
return table_parameters_ptr(); return table_parameters_ptr();
} }
else if (fallback_speed->NumberValue() <= 0) else if (Nan::To<double>(fallback_speed).FromJust() <= 0)
{ {
Nan::ThrowError("fallback_speed must be > 0"); Nan::ThrowError("fallback_speed must be > 0");
return table_parameters_ptr(); return table_parameters_ptr();
} }
params->fallback_speed = static_cast<double>(fallback_speed->NumberValue()); params->fallback_speed = Nan::To<double>(fallback_speed).FromJust();
} }
if (obj->Has(Nan::New("fallback_coordinate").ToLocalChecked())) if (Nan::Has(obj, Nan::New("fallback_coordinate").ToLocalChecked()).FromJust())
{ {
auto fallback_coordinate = obj->Get(Nan::New("fallback_coordinate").ToLocalChecked()); auto fallback_coordinate = obj->Get(Nan::New("fallback_coordinate").ToLocalChecked());
@ -1306,7 +1305,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return table_parameters_ptr(); return table_parameters_ptr();
} }
std::string fallback_coordinate_str = *v8::String::Utf8Value(fallback_coordinate); std::string fallback_coordinate_str = *Nan::Utf8String(fallback_coordinate);
if (fallback_coordinate_str == "snapped") if (fallback_coordinate_str == "snapped")
{ {
@ -1324,7 +1323,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("scale_factor").ToLocalChecked())) if (Nan::Has(obj, Nan::New("scale_factor").ToLocalChecked()).FromJust())
{ {
auto scale_factor = obj->Get(Nan::New("scale_factor").ToLocalChecked()); auto scale_factor = obj->Get(Nan::New("scale_factor").ToLocalChecked());
@ -1333,13 +1332,13 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
Nan::ThrowError("scale_factor must be a number"); Nan::ThrowError("scale_factor must be a number");
return table_parameters_ptr(); return table_parameters_ptr();
} }
else if (scale_factor->NumberValue() <= 0) else if (Nan::To<double>(scale_factor).FromJust() <= 0)
{ {
Nan::ThrowError("scale_factor must be > 0"); Nan::ThrowError("scale_factor must be > 0");
return table_parameters_ptr(); return table_parameters_ptr();
} }
params->scale_factor = static_cast<double>(scale_factor->NumberValue()); params->scale_factor = Nan::To<double>(scale_factor).FromJust();
} }
return params; return params;
@ -1362,7 +1361,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return trip_parameters_ptr(); return trip_parameters_ptr();
} }
if (obj->Has(Nan::New("roundtrip").ToLocalChecked())) if (Nan::Has(obj, Nan::New("roundtrip").ToLocalChecked()).FromJust())
{ {
auto roundtrip = obj->Get(Nan::New("roundtrip").ToLocalChecked()); auto roundtrip = obj->Get(Nan::New("roundtrip").ToLocalChecked());
if (roundtrip.IsEmpty()) if (roundtrip.IsEmpty())
@ -1370,7 +1369,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (roundtrip->IsBoolean()) if (roundtrip->IsBoolean())
{ {
params->roundtrip = roundtrip->BooleanValue(); params->roundtrip = Nan::To<bool>(roundtrip).FromJust();
} }
else else
{ {
@ -1379,7 +1378,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("source").ToLocalChecked())) if (Nan::Has(obj, Nan::New("source").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> source = obj->Get(Nan::New("source").ToLocalChecked()); v8::Local<v8::Value> source = obj->Get(Nan::New("source").ToLocalChecked());
if (source.IsEmpty()) if (source.IsEmpty())
@ -1391,7 +1390,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return trip_parameters_ptr(); return trip_parameters_ptr();
} }
std::string source_str = *v8::String::Utf8Value(source); std::string source_str = *Nan::Utf8String(source);
if (source_str == "first") if (source_str == "first")
{ {
@ -1408,7 +1407,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("destination").ToLocalChecked())) if (Nan::Has(obj, Nan::New("destination").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> destination = obj->Get(Nan::New("destination").ToLocalChecked()); v8::Local<v8::Value> destination = obj->Get(Nan::New("destination").ToLocalChecked());
if (destination.IsEmpty()) if (destination.IsEmpty())
@ -1420,7 +1419,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return trip_parameters_ptr(); return trip_parameters_ptr();
} }
std::string destination_str = *v8::String::Utf8Value(destination); std::string destination_str = *Nan::Utf8String(destination);
if (destination_str == "last") if (destination_str == "last")
{ {
@ -1451,7 +1450,7 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked(); v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked();
if (obj->Has(Nan::New("timestamps").ToLocalChecked())) if (Nan::Has(obj, Nan::New("timestamps").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> timestamps = obj->Get(Nan::New("timestamps").ToLocalChecked()); v8::Local<v8::Value> timestamps = obj->Get(Nan::New("timestamps").ToLocalChecked());
if (timestamps.IsEmpty()) if (timestamps.IsEmpty())
@ -1483,11 +1482,11 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
Nan::ThrowError("Timestamps array items must be numbers"); Nan::ThrowError("Timestamps array items must be numbers");
return match_parameters_ptr(); return match_parameters_ptr();
} }
params->timestamps.emplace_back(static_cast<std::size_t>(timestamp->NumberValue())); params->timestamps.emplace_back(Nan::To<unsigned>(timestamp).FromJust());
} }
} }
if (obj->Has(Nan::New("gaps").ToLocalChecked())) if (Nan::Has(obj, Nan::New("gaps").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> gaps = obj->Get(Nan::New("gaps").ToLocalChecked()); v8::Local<v8::Value> gaps = obj->Get(Nan::New("gaps").ToLocalChecked());
if (gaps.IsEmpty()) if (gaps.IsEmpty())
@ -1517,7 +1516,7 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
} }
} }
if (obj->Has(Nan::New("tidy").ToLocalChecked())) if (Nan::Has(obj, Nan::New("tidy").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> tidy = obj->Get(Nan::New("tidy").ToLocalChecked()); v8::Local<v8::Value> tidy = obj->Get(Nan::New("tidy").ToLocalChecked());
if (tidy.IsEmpty()) if (tidy.IsEmpty())
@ -1529,10 +1528,10 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return match_parameters_ptr(); return match_parameters_ptr();
} }
params->tidy = tidy->BooleanValue(); params->tidy = Nan::To<bool>(tidy).FromJust();
} }
if (obj->Has(Nan::New("waypoints").ToLocalChecked())) if (Nan::Has(obj, Nan::New("waypoints").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked()); v8::Local<v8::Value> waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked());
if (waypoints.IsEmpty()) if (waypoints.IsEmpty())
@ -1582,7 +1581,8 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
Nan::ThrowError("Waypoints must correspond with the index of an input coordinate"); Nan::ThrowError("Waypoints must correspond with the index of an input coordinate");
return match_parameters_ptr(); return match_parameters_ptr();
} }
params->waypoints.emplace_back(static_cast<unsigned>(waypoint_value->NumberValue())); params->waypoints.emplace_back(
static_cast<unsigned>(Nan::To<unsigned>(waypoint_value).FromJust()));
} }
} }

View File

@ -152,6 +152,10 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
qi::lit("generate_hints=") > qi::lit("generate_hints=") >
qi::bool_[ph::bind(&engine::api::BaseParameters::generate_hints, qi::_r1) = qi::_1]; qi::bool_[ph::bind(&engine::api::BaseParameters::generate_hints, qi::_r1) = qi::_1];
skip_waypoints_rule =
qi::lit("skip_waypoints=") >
qi::bool_[ph::bind(&engine::api::BaseParameters::skip_waypoints, qi::_r1) = qi::_1];
bearings_rule = bearings_rule =
qi::lit("bearings=") > qi::lit("bearings=") >
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'; (-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';';
@ -183,6 +187,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
| hints_rule(qi::_r1) // | hints_rule(qi::_r1) //
| bearings_rule(qi::_r1) // | bearings_rule(qi::_r1) //
| generate_hints_rule(qi::_r1) // | generate_hints_rule(qi::_r1) //
| skip_waypoints_rule(qi::_r1) //
| approach_rule(qi::_r1) // | approach_rule(qi::_r1) //
| exclude_rule(qi::_r1) // | exclude_rule(qi::_r1) //
| snapping_rule(qi::_r1); | snapping_rule(qi::_r1);
@ -203,6 +208,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
qi::rule<Iterator, Signature> hints_rule; qi::rule<Iterator, Signature> hints_rule;
qi::rule<Iterator, Signature> generate_hints_rule; qi::rule<Iterator, Signature> generate_hints_rule;
qi::rule<Iterator, Signature> skip_waypoints_rule;
qi::rule<Iterator, Signature> approach_rule; qi::rule<Iterator, Signature> approach_rule;
qi::rule<Iterator, Signature> exclude_rule; qi::rule<Iterator, Signature> exclude_rule;

View File

@ -61,7 +61,6 @@ class RequestParser
header_line_start, header_line_start,
header_lws, header_lws,
header_name, header_name,
space_before_header_value,
header_value, header_value,
expecting_newline_2, expecting_newline_2,
expecting_newline_3 expecting_newline_3

35
include/storage/io.hpp Normal file → Executable file
View File

@ -10,6 +10,7 @@
#include "util/log.hpp" #include "util/log.hpp"
#include "util/version.hpp" #include "util/version.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/iostreams/device/array.hpp> #include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/seek.hpp> #include <boost/iostreams/seek.hpp>
@ -60,29 +61,27 @@ class FileReader
std::size_t GetSize() std::size_t GetSize()
{ {
const boost::filesystem::ifstream::pos_type position = input_stream.tellg(); const boost::filesystem::path path(filepath);
input_stream.seekg(0, std::ios::end); try
const boost::filesystem::ifstream::pos_type file_size = input_stream.tellg();
if (file_size == boost::filesystem::ifstream::pos_type(-1))
{ {
throw util::RuntimeError("Unable to determine file size for " + return std::size_t(boost::filesystem::file_size(path)) -
std::string(filepath.string()), ((fingerprint == FingerprintFlag::VerifyFingerprint) ? sizeof(util::FingerPrint)
ErrorCode::FileIOError, : 0);
SOURCE_REF,
std::strerror(errno));
} }
catch (const boost::filesystem::filesystem_error &ex)
// restore the current position
input_stream.seekg(position, std::ios::beg);
if (fingerprint == FingerprintFlag::VerifyFingerprint)
{ {
return std::size_t(file_size) - sizeof(util::FingerPrint); std::cout << ex.what() << std::endl;
throw;
} }
else }
/* Read one line */
template <typename T> void ReadLine(T *dest, const std::size_t count)
{
if (0 < count)
{ {
return file_size; memset(dest, 0, count * sizeof(T));
input_stream.getline(reinterpret_cast<char *>(dest), count * sizeof(T));
} }
} }

View File

@ -17,10 +17,6 @@
#include <cstdint> #include <cstdint>
#include <tuple> #include <tuple>
#if USE_STXXL_LIBRARY
#include <stxxl/vector>
#endif
namespace osrm namespace osrm
{ {
namespace storage namespace storage
@ -134,24 +130,6 @@ inline void write(storage::tar::FileWriter &writer,
writer.WriteStreaming<T>(name, vec.begin(), vec.size()); writer.WriteStreaming<T>(name, vec.begin(), vec.size());
} }
#if USE_STXXL_LIBRARY
template <typename T>
inline void read(storage::tar::FileReader &reader, const std::string &name, stxxl::vector<T> &vec)
{
auto size = reader.ReadElementCount64(name);
vec.reserve(size);
reader.ReadStreaming<T>(name, std::back_inserter(vec), size);
}
template <typename T>
inline void
write(storage::tar::FileWriter &writer, const std::string &name, const stxxl::vector<T> &vec)
{
writer.WriteElementCount64(name, vec.size());
writer.WriteStreaming<T>(name, vec.begin(), vec.size());
}
#endif
template <typename T> void read(io::BufferReader &reader, std::vector<T> &data) template <typename T> void read(io::BufferReader &reader, std::vector<T> &data)
{ {
const auto count = reader.ReadElementCount64(); const auto count = reader.ReadElementCount64();

View File

@ -122,7 +122,7 @@ template <typename Key, typename Value> struct CSVFilesParser
util::Log() << "Loaded " << filename << " with " << result.size() << "values"; util::Log() << "Loaded " << filename << " with " << result.size() << "values";
return std::move(result); return result;
} }
catch (const boost::exception &e) catch (const boost::exception &e)
{ {

View File

@ -7,29 +7,11 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#if USE_STXXL_LIBRARY
#include <stxxl/mng>
#endif
namespace osrm namespace osrm
{ {
namespace util namespace util
{ {
inline void DumpSTXXLStats()
{
#if USE_STXXL_LIBRARY
#if STXXL_VERSION_MAJOR > 1 || (STXXL_VERSION_MAJOR == 1 && STXXL_VERSION_MINOR >= 4)
auto manager = stxxl::block_manager::get_instance();
util::Log() << "STXXL: peak bytes used: " << manager->get_maximum_allocation();
util::Log() << "STXXL: total disk allocated: " << manager->get_total_bytes();
#else
#warning STXXL 1.4+ recommended - STXXL memory summary will not be available
util::Log() << "STXXL: memory summary not available, needs STXXL 1.4 or higher";
#endif
#endif
}
inline void DumpMemoryStats() inline void DumpMemoryStats()
{ {
#ifndef _WIN32 #ifndef _WIN32

View File

@ -19,10 +19,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#if USE_STXXL_LIBRARY
#include <stxxl/vector>
#endif
namespace osrm namespace osrm
{ {
namespace util namespace util
@ -253,16 +249,10 @@ template <typename DataT> void swap(vector_view<DataT> &lhs, vector_view<DataT>
std::swap(lhs.m_size, rhs.m_size); std::swap(lhs.m_size, rhs.m_size);
} }
#if USE_STXXL_LIBRARY
template <typename T> using ExternalVector = stxxl::vector<T>;
#else
template <typename T> using ExternalVector = std::vector<T>;
#endif
template <typename DataT, storage::Ownership Ownership> template <typename DataT, storage::Ownership Ownership>
using InternalOrExternalVector = using InternalOrExternalVector =
typename std::conditional<Ownership == storage::Ownership::External, typename std::conditional<Ownership == storage::Ownership::External,
ExternalVector<DataT>, std::vector<DataT>,
std::vector<DataT>>::type; std::vector<DataT>>::type;
template <typename DataT, storage::Ownership Ownership> template <typename DataT, storage::Ownership Ownership>

10
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "osrm", "name": "osrm",
"version": "5.20.0-latest.1", "version": "5.22.0-customsnapping.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1740,6 +1740,7 @@
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
"integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"inherits": "~2.0.0" "inherits": "~2.0.0"
} }
@ -5567,6 +5568,7 @@
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"inherits": "~2.0.0", "inherits": "~2.0.0",
@ -7646,9 +7648,9 @@
"dev": true "dev": true
}, },
"nan": { "nan": {
"version": "2.11.1", "version": "2.14.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
"integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
}, },
"natural-compare": { "natural-compare": {
"version": "1.4.0", "version": "1.4.0",

View File

@ -5,7 +5,7 @@
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": { "dependencies": {
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"nan": "^2.11.1", "nan": "^2.14.1",
"node-cmake": "^2.3.2", "node-cmake": "^2.3.2",
"node-pre-gyp": "^0.12.0", "node-pre-gyp": "^0.12.0",
"rimraf": "^2.5.4" "rimraf": "^2.5.4"

View File

@ -56,7 +56,13 @@ function setup()
'private', 'private',
'agricultural', 'agricultural',
'forestry', 'forestry',
'delivery' 'delivery',
-- When a way is tagged with `use_sidepath` a parallel way suitable for
-- cyclists is mapped and must be used instead (by law). This tag is
-- used on ways that normally may be used by cyclists, but not when
-- a signposted parallel cycleway is available. For purposes of routing
-- cyclists, this value should be treated as 'no access for bicycles'.
'use_sidepath'
}, },
restricted_access_tag_list = Set { }, restricted_access_tag_list = Set { },

View File

@ -38,7 +38,7 @@ local way = {
local result = {} local result = {}
-- call the way function -- call the way function
Debug.way_function(way,result) Debug.process_way(way,result)
-- print input and output -- print input and output
pprint(way) pprint(way)

View File

@ -10,7 +10,7 @@ local pprint = require('lib/pprint')
-- globals that are normally set from C++ -- globals that are normally set from C++
-- should match values defined in include/extractor/guidance/road_classification.hpp -- should match values defined in include/extractor/road_classification.hpp
road_priority_class = { road_priority_class = {
motorway = 0, motorway = 0,
trunk = 2, trunk = 2,

View File

@ -15,7 +15,7 @@ local pprint = require('lib/pprint')
-- profiles code modifies this table -- profiles code modifies this table
properties = {} properties = {}
-- should match values defined in include/extractor/guidance/road_classification.hpp -- should match values defined in include/extractor/road_classification.hpp
road_priority_class = { road_priority_class = {
motorway = 0, motorway = 0,
trunk = 2, trunk = 2,

View File

@ -18,11 +18,3 @@ sudo apt-get update -qq --yes || true
sudo apt-get install -qq --yes --force-yes g++-4.8-arm-linux-gnueabihf g++-4.8-multilib-arm-linux-gnueabihf gcc-4.8-arm-linux-gnueabihf gcc-4.8-multilib-arm-linux-gnueabihf sudo apt-get install -qq --yes --force-yes g++-4.8-arm-linux-gnueabihf g++-4.8-multilib-arm-linux-gnueabihf gcc-4.8-arm-linux-gnueabihf gcc-4.8-multilib-arm-linux-gnueabihf
sudo apt-get install -qq --yes --force-yes libexpat1-dev:armhf zlib1g-dev:armhf libbz2-dev:armhf libboost-date-time-dev:armhf libboost-filesystem-dev:armhf libboost-iostreams-dev:armhf libboost-program-options-dev:armhf libboost-regex-dev:armhf libboost-system-dev:armhf libboost-thread-dev:armhf libtbb-dev:armhf libboost-test-dev:armhf sudo apt-get install -qq --yes --force-yes libexpat1-dev:armhf zlib1g-dev:armhf libbz2-dev:armhf libboost-date-time-dev:armhf libboost-filesystem-dev:armhf libboost-iostreams-dev:armhf libboost-program-options-dev:armhf libboost-regex-dev:armhf libboost-system-dev:armhf libboost-thread-dev:armhf libtbb-dev:armhf libboost-test-dev:armhf
## build libstxxl1v5:armhf from sources, no package in trusty
if [ $UBUNTU_RELEASE == trusty ] ; then
( cd /tmp && wget http://sourceforge.net/projects/stxxl/files/stxxl/1.4.1/stxxl-1.4.1.tar.gz && tar xf stxxl-1.4.1.tar.gz )
( cd /tmp/stxxl-1.4.1 && mkdir build && cd build && CC=arm-linux-gnueabihf-gcc-4.8 CXX=arm-linux-gnueabihf-g++-4.8 cmake .. && make && sudo make install )
else
sudo apt-get install -qq --yes --force-yes libstxxl1v5:armhf
fi

View File

@ -3,4 +3,4 @@
sudo dpkg --add-architecture i386 sudo dpkg --add-architecture i386
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test && ( sudo apt-get update -qq --yes || true ) sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test && ( sudo apt-get update -qq --yes || true )
sudo apt-get install -qq --yes --force-yes g++-7-multilib libxml2-dev:i386 libexpat1-dev:i386 libzip-dev:i386 libbz2-dev:i386 libstxxl-dev:i386 libtbb-dev:i386 lua5.2:i386 liblua5.2-dev:i386 libboost-date-time-dev:i386 libboost-filesystem-dev:i386 libboost-iostreams-dev:i386 libboost-program-options-dev:i386 libboost-regex-dev:i386 libboost-system-dev:i386 libboost-thread-dev:i386 libboost-test-dev:i386 sudo apt-get install -qq --yes --force-yes g++-7-multilib libxml2-dev:i386 libexpat1-dev:i386 libzip-dev:i386 libbz2-dev:i386 libtbb-dev:i386 lua5.2:i386 liblua5.2-dev:i386 libboost-date-time-dev:i386 libboost-filesystem-dev:i386 libboost-iostreams-dev:i386 libboost-program-options-dev:i386 libboost-regex-dev:i386 libboost-system-dev:i386 libboost-thread-dev:i386 libboost-test-dev:i386

View File

@ -51,8 +51,8 @@ struct Parameters
// Alternative paths are still reasonable around the via node candidate (local optimality). // Alternative paths are still reasonable around the via node candidate (local optimality).
// At least optimal around 10% sub-paths around the via node candidate. // At least optimal around 10% sub-paths around the via node candidate.
double kAtLeastOptimalAroundViaBy = 0.1; double kAtLeastOptimalAroundViaBy = 0.1;
// Alternative paths similarity requirement (sharing) based on calles. // Alternative paths similarity requirement (sharing) based on cells.
// At least 15% different than the shortest path. // At least 5% different than the shortest path.
double kCellsAtMostSameBy = 0.95; double kCellsAtMostSameBy = 0.95;
}; };

View File

@ -206,12 +206,7 @@ void GraphCompressor::Compress(
graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation( graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation(
rev_edge_data2.annotation_data, rev_edge_data1.annotation_data); rev_edge_data2.annotation_data, rev_edge_data1.annotation_data);
/* // Add node penalty when compress edge crosses a traffic signal
// Do not compress edge if it crosses a traffic signal.
// This can't be done in CanCombineWith, becase we only store the
// traffic signals in the `traffic signal` list, which EdgeData
// doesn't have access to.
*/
const bool has_node_penalty = traffic_signals.find(node_v) != traffic_signals.end(); const bool has_node_penalty = traffic_signals.find(node_v) != traffic_signals.end();
EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION; EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION;
EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT; EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT;

View File

@ -92,15 +92,15 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
const auto _ymin = static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{ymin})); const auto _ymin = static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{ymin}));
const auto _ymax = static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{ymax})); const auto _ymax = static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{ymax}));
const auto itr = LoadedSourcePaths.find(path_string); const auto itr = RasterCache::getInstance().getLoadedSourcePaths().find(path_string);
if (itr != LoadedSourcePaths.end()) if (itr != RasterCache::getInstance().getLoadedSourcePaths().end())
{ {
util::Log() << "[source loader] Already loaded source '" << path_string << "' at source_id " util::Log() << "[source loader] Already loaded source '" << path_string << "' at source_id "
<< itr->second; << itr->second;
return itr->second; return itr->second;
} }
int source_id = static_cast<int>(LoadedSources.size()); int source_id = static_cast<int>(RasterCache::getInstance().getLoadedSources().size());
util::Log() << "[source loader] Loading from " << path_string << " ... "; util::Log() << "[source loader] Loading from " << path_string << " ... ";
TIMER_START(loading_source); TIMER_START(loading_source);
@ -116,8 +116,8 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
RasterSource source{std::move(rasterData), ncols, nrows, _xmin, _xmax, _ymin, _ymax}; RasterSource source{std::move(rasterData), ncols, nrows, _xmin, _xmax, _ymin, _ymax};
TIMER_STOP(loading_source); TIMER_STOP(loading_source);
LoadedSourcePaths.emplace(path_string, source_id); RasterCache::getInstance().getLoadedSourcePaths().emplace(path_string, source_id);
LoadedSources.push_back(std::move(source)); RasterCache::getInstance().getLoadedSources().push_back(std::move(source));
util::Log() << "[source loader] ok, after " << TIMER_SEC(loading_source) << "s"; util::Log() << "[source loader] ok, after " << TIMER_SEC(loading_source) << "s";
@ -127,10 +127,11 @@ int RasterContainer::LoadRasterSource(const std::string &path_string,
// External function for looking up nearest data point from a specified source // External function for looking up nearest data point from a specified source
RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, double lon, double lat) RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, double lon, double lat)
{ {
if (LoadedSources.size() < source_id + 1) if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1)
{ {
throw util::exception("Attempted to access source " + std::to_string(source_id) + throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(LoadedSources.size()) + ", but there are only " +
std::to_string(RasterCache::getInstance().getLoadedSources().size()) +
" loaded" + SOURCE_REF); " loaded" + SOURCE_REF);
} }
@ -139,7 +140,7 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou
BOOST_ASSERT(lon < 180); BOOST_ASSERT(lon < 180);
BOOST_ASSERT(lon > -180); BOOST_ASSERT(lon > -180);
const auto &found = LoadedSources[source_id]; const auto &found = RasterCache::getInstance().getLoadedSources()[source_id];
return found.GetRasterData(static_cast<std::int32_t>(util::toFixed(util::FloatLongitude{lon})), return found.GetRasterData(static_cast<std::int32_t>(util::toFixed(util::FloatLongitude{lon})),
static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{lat}))); static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{lat})));
} }
@ -148,10 +149,11 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou
RasterDatum RasterDatum
RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat) RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double lon, double lat)
{ {
if (LoadedSources.size() < source_id + 1) if (RasterCache::getInstance().getLoadedSources().size() < source_id + 1)
{ {
throw util::exception("Attempted to access source " + std::to_string(source_id) + throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(LoadedSources.size()) + ", but there are only " +
std::to_string(RasterCache::getInstance().getLoadedSources().size()) +
" loaded" + SOURCE_REF); " loaded" + SOURCE_REF);
} }
@ -160,10 +162,12 @@ RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l
BOOST_ASSERT(lon < 180); BOOST_ASSERT(lon < 180);
BOOST_ASSERT(lon > -180); BOOST_ASSERT(lon > -180);
const auto &found = LoadedSources[source_id]; const auto &found = RasterCache::getInstance().getLoadedSources()[source_id];
return found.GetRasterInterpolate( return found.GetRasterInterpolate(
static_cast<std::int32_t>(util::toFixed(util::FloatLongitude{lon})), static_cast<std::int32_t>(util::toFixed(util::FloatLongitude{lon})),
static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{lat}))); static_cast<std::int32_t>(util::toFixed(util::FloatLatitude{lat})));
} }
RasterCache *RasterCache::g_instance = NULL;
} }
} }

View File

@ -45,9 +45,8 @@ boost::optional<ParameterT> parseParameters(std::string::iterator &iter,
const auto ok = const auto ok =
boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters))); boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters)));
// return move(a.b) is needed to move b out of a and then return the rvalue by implicit move
if (ok && iter == end) if (ok && iter == end)
return std::move(parameters); return parameters;
} }
catch (const qi::expectation_failure<It> &failure) catch (const qi::expectation_failure<It> &failure)
{ {

View File

@ -68,7 +68,14 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
// the request has been parsed // the request has been parsed
if (result == RequestParser::RequestStatus::valid) if (result == RequestParser::RequestStatus::valid)
{ {
current_request.endpoint = TCP_socket.remote_endpoint().address();
boost::system::error_code ec;
current_request.endpoint = TCP_socket.remote_endpoint(ec).address();
if (ec)
{
handle_shutdown();
return;
}
request_handler.HandleRequest(current_request, current_reply); request_handler.HandleRequest(current_request, current_reply);
if (boost::iequals(current_request.connection, "close")) if (boost::iequals(current_request.connection, "close"))
@ -149,6 +156,8 @@ void Connection::handle_write(const boost::system::error_code &error)
current_request = http::request(); current_request = http::request();
current_reply = http::reply(); current_reply = http::reply();
request_parser = RequestParser(); request_parser = RequestParser();
incoming_data_buffer = boost::array<char, 8192>();
output_buffer.clear();
this->start(); this->start();
} }
else else
@ -166,7 +175,8 @@ void Connection::handle_timeout(boost::system::error_code ec)
// Absent next request during waiting time in the keepalive mode - should stop right there. // Absent next request during waiting time in the keepalive mode - should stop right there.
if (ec != boost::asio::error::operation_aborted) if (ec != boost::asio::error::operation_aborted)
{ {
TCP_socket.cancel(); boost::system::error_code ignore_error;
TCP_socket.cancel(ignore_error);
handle_shutdown(); handle_shutdown();
} }
} }

View File

@ -217,7 +217,7 @@ RequestParser::RequestStatus RequestParser::consume(http::request &current_reque
case internal_state::header_name: case internal_state::header_name:
if (input == ':') if (input == ':')
{ {
state = internal_state::space_before_header_value; state = internal_state::header_value;
return RequestStatus::indeterminate; return RequestStatus::indeterminate;
} }
if (!is_char(input) || is_CTL(input) || is_special(input)) if (!is_char(input) || is_CTL(input) || is_special(input))
@ -226,14 +226,12 @@ RequestParser::RequestStatus RequestParser::consume(http::request &current_reque
} }
current_header.name.push_back(input); current_header.name.push_back(input);
return RequestStatus::indeterminate; return RequestStatus::indeterminate;
case internal_state::space_before_header_value: case internal_state::header_value:
if (input == ' ') if (input == ' ')
{ {
state = internal_state::header_value; state = internal_state::header_value;
return RequestStatus::indeterminate; return RequestStatus::indeterminate;
} }
return RequestStatus::invalid;
case internal_state::header_value:
if (input == '\r') if (input == '\r')
{ {
state = internal_state::expecting_newline_2; state = internal_state::expecting_newline_2;

View File

@ -189,21 +189,18 @@ int main(int argc, char *argv[]) try
osrm::contract(contractor_config); osrm::contract(contractor_config);
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
catch (const osrm::RuntimeError &e) catch (const osrm::RuntimeError &e)
{ {
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
util::Log(logERROR) << e.what(); util::Log(logERROR) << e.what();
return e.GetCode(); return e.GetCode();
} }
catch (const std::bad_alloc &e) catch (const std::bad_alloc &e)
{ {
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
util::Log(logERROR) << e.what(); util::Log(logERROR) << e.what();
util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile"; util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile";

View File

@ -186,28 +186,24 @@ int main(int argc, char *argv[]) try
osrm::extract(extractor_config); osrm::extract(extractor_config);
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
catch (const osrm::RuntimeError &e) catch (const osrm::RuntimeError &e)
{ {
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
util::Log(logERROR) << e.what(); util::Log(logERROR) << e.what();
return e.GetCode(); return e.GetCode();
} }
catch (const std::system_error &e) catch (const std::system_error &e)
{ {
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
util::Log(logERROR) << e.what(); util::Log(logERROR) << e.what();
return e.code().value(); return e.code().value();
} }
catch (const std::bad_alloc &e) catch (const std::bad_alloc &e)
{ {
util::DumpSTXXLStats();
util::DumpMemoryStats(); util::DumpMemoryStats();
util::Log(logERROR) << "[exception] " << e.what(); util::Log(logERROR) << "[exception] " << e.what();
util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile"; util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile";

View File

@ -16,7 +16,7 @@ namespace
static const char COL_RESET[]{"\x1b[0m"}; static const char COL_RESET[]{"\x1b[0m"};
static const char RED[]{"\x1b[31m"}; static const char RED[]{"\x1b[31m"};
static const char YELLOW[]{"\x1b[33m"}; static const char YELLOW[]{"\x1b[33m"};
#ifndef NDEBUG #ifdef ENABLE_DEBUG_LOGGING
static const char MAGENTA[]{"\x1b[35m"}; static const char MAGENTA[]{"\x1b[35m"};
#endif #endif
// static const char GREEN[] { "\x1b[32m"}; // static const char GREEN[] { "\x1b[32m"};
@ -80,7 +80,7 @@ Log::Log(LogLevel level_, std::ostream &ostream) : level(level_), stream(ostream
stream << (is_terminal ? RED : "") << "[error] "; stream << (is_terminal ? RED : "") << "[error] ";
break; break;
case logDEBUG: case logDEBUG:
#ifndef NDEBUG #ifdef ENABLE_DEBUG_LOGGING
stream << (is_terminal ? MAGENTA : "") << "[debug] "; stream << (is_terminal ? MAGENTA : "") << "[debug] ";
#endif #endif
break; break;
@ -126,7 +126,7 @@ Log::~Log()
std::cerr << std::endl; std::cerr << std::endl;
break; break;
case logDEBUG: case logDEBUG:
#ifdef NDEBUG #ifndef ENABLE_DEBUG_LOGGING
break; break;
#endif #endif
case logINFO: case logINFO:

View File

@ -1 +0,0 @@
disk=###.stxxl,20,memory

View File

@ -1 +0,0 @@
disk=/tmp/stxxl_###,200M,syscall autogrow

View File

@ -1,6 +1,4 @@
DATA_NAME:=monaco DATA_NAME:=monaco
DATA_URL:=https://s3.amazonaws.com/mapbox/osrm/testing/$(DATA_NAME).osm.pbf
DATA_POLY_URL:=https://s3.amazonaws.com/mapbox/osrm/testing/$(DATA_NAME).poly
OSRM_BUILD_DIR?=../../build OSRM_BUILD_DIR?=../../build
PROFILE_ROOT:=../../profiles PROFILE_ROOT:=../../profiles
SCRIPT_ROOT:=../../scripts SCRIPT_ROOT:=../../scripts
@ -22,12 +20,6 @@ clean:
-rm -r $(DATA_NAME).* -rm -r $(DATA_NAME).*
-rm -r ch corech mld -rm -r ch corech mld
$(DATA_NAME).osm.pbf:
wget $(DATA_URL) -O $(DATA_NAME).osm.pbf
$(DATA_NAME).poly:
wget $(DATA_POLY_URL) -O $(DATA_NAME).poly
ch/$(DATA_NAME).osrm: $(DATA_NAME).osrm ch/$(DATA_NAME).osrm: $(DATA_NAME).osrm
mkdir -p ch mkdir -p ch
cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* ch/ cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* ch/

BIN
test/data/monaco.osm.pbf Normal file

Binary file not shown.

31
test/data/monaco.poly Normal file
View File

@ -0,0 +1,31 @@
none
1
7.448637E+00 4.373992E+01
7.420651E+00 4.372335E+01
7.409205E+00 4.372933E+01
7.410161E+00 4.373072E+01
7.411732E+00 4.373139E+01
7.413011E+00 4.373162E+01
7.412909E+00 4.373379E+01
7.412364E+00 4.373429E+01
7.415174E+00 4.373618E+01
7.421612E+00 4.374033E+01
7.421557E+00 4.374080E+01
7.423117E+00 4.374135E+01
7.424507E+00 4.374069E+01
7.426007E+00 4.374226E+01
7.427535E+00 4.374369E+01
7.428709E+00 4.374590E+01
7.430755E+00 4.374885E+01
7.431923E+00 4.374856E+01
7.433675E+00 4.374952E+01
7.435904E+00 4.374979E+01
7.437361E+00 4.375083E+01
7.436782E+00 4.375149E+01
7.437709E+00 4.375169E+01
7.438827E+00 4.375133E+01
7.438466E+00 4.374899E+01
7.441831E+00 4.374505E+01
7.448637E+00 4.373992E+01
END
END

View File

@ -3399,7 +3399,9 @@ namespace sol {
runtime = LUA_ERRRUN, runtime = LUA_ERRRUN,
memory = LUA_ERRMEM, memory = LUA_ERRMEM,
handler = LUA_ERRERR, handler = LUA_ERRERR,
#if SOL_LUA_VERSION < 504
gc = LUA_ERRGCMM, gc = LUA_ERRGCMM,
#endif
syntax = LUA_ERRSYNTAX, syntax = LUA_ERRSYNTAX,
file = LUA_ERRFILE, file = LUA_ERRFILE,
}; };
@ -3409,7 +3411,9 @@ namespace sol {
yielded = LUA_YIELD, yielded = LUA_YIELD,
runtime = LUA_ERRRUN, runtime = LUA_ERRRUN,
memory = LUA_ERRMEM, memory = LUA_ERRMEM,
#if SOL_LUA_VERSION < 504
gc = LUA_ERRGCMM, gc = LUA_ERRGCMM,
#endif
handler = LUA_ERRERR, handler = LUA_ERRERR,
dead = -1, dead = -1,
}; };
@ -3418,7 +3422,9 @@ namespace sol {
ok = LUA_OK, ok = LUA_OK,
syntax = LUA_ERRSYNTAX, syntax = LUA_ERRSYNTAX,
memory = LUA_ERRMEM, memory = LUA_ERRMEM,
#if SOL_LUA_VERSION < 504
gc = LUA_ERRGCMM, gc = LUA_ERRGCMM,
#endif
file = LUA_ERRFILE, file = LUA_ERRFILE,
}; };
@ -3462,8 +3468,10 @@ namespace sol {
return names[3]; return names[3];
case call_status::handler: case call_status::handler:
return names[4]; return names[4];
#if SOL_LUA_VERSION < 504
case call_status::gc: case call_status::gc:
return names[5]; return names[5];
#endif
case call_status::syntax: case call_status::syntax:
return names[6]; return names[6];
case call_status::file: case call_status::file:
@ -3485,8 +3493,10 @@ namespace sol {
return names[0]; return names[0];
case load_status::memory: case load_status::memory:
return names[1]; return names[1];
#if SOL_LUA_VERSION < 504
case load_status::gc: case load_status::gc:
return names[2]; return names[2];
#endif
case load_status::syntax: case load_status::syntax:
return names[3]; return names[3];
case load_status::file: case load_status::file:
@ -14374,9 +14384,12 @@ namespace sol {
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) { void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
#if SOL_LUA_VERSION < 502 #if SOL_LUA_VERSION < 502
stats = static_cast<call_status>(lua_resume(lua_state(), static_cast<int>(argcount))); stats = static_cast<call_status>(lua_resume(lua_state(), static_cast<int>(argcount)));
#else #elif SOL_LUA_VERSION < 504
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount))); stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
#endif // Lua 5.1 compat #else
int nstack = 0;
stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nstack));
#endif
} }
template<std::size_t... I, typename... Ret> template<std::size_t... I, typename... Ret>

View File

@ -65,6 +65,30 @@ BOOST_AUTO_TEST_CASE(test_match)
} }
} }
BOOST_AUTO_TEST_CASE(test_match_skip_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
MatchParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = json::Object();
const auto rc = osrm.Match(params, result);
auto &json_result = result.get<json::Object>();
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end());
}
BOOST_AUTO_TEST_CASE(test_match_split) BOOST_AUTO_TEST_CASE(test_match_split)
{ {
using namespace osrm; using namespace osrm;
@ -118,4 +142,70 @@ BOOST_AUTO_TEST_CASE(test_match_split)
} }
} }
BOOST_AUTO_TEST_CASE(test_match_fb_serialization)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
MatchParameters params;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Match(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() != nullptr);
const auto waypoints = fb->waypoints();
BOOST_CHECK(waypoints->size() == params.coordinates.size());
BOOST_CHECK(fb->routes() != nullptr);
const auto matchings = fb->routes();
const auto &number_of_matchings = matchings->size();
for (const auto &waypoint : *waypoints)
{
BOOST_CHECK(waypoint_check(waypoint));
const auto matchings_index = waypoint->matchings_index();
const auto waypoint_index = waypoint->waypoint_index();
const auto &route_legs = matchings->operator[](matchings_index)->legs();
BOOST_CHECK_LT(waypoint_index, route_legs->size() + 1);
BOOST_CHECK_LT(matchings_index, number_of_matchings);
}
}
BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
MatchParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Match(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() == nullptr);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -43,6 +43,27 @@ BOOST_AUTO_TEST_CASE(test_nearest_response)
} }
} }
BOOST_AUTO_TEST_CASE(test_nearest_response_skip_waypoints)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
using namespace osrm;
NearestParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = json::Object();
const auto rc = osrm.Nearest(params, result);
BOOST_REQUIRE(rc == Status::Ok);
auto &json_result = result.get<json::Object>();
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end());
}
BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates) BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
{ {
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm"); auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
@ -118,7 +139,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_for_location_in_small_component)
} }
} }
BOOST_AUTO_TEST_CASE(test_nearest_fb_serilization) BOOST_AUTO_TEST_CASE(test_nearest_fb_serialization)
{ {
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm"); auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
@ -147,6 +168,27 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_serilization)
} }
} }
BOOST_AUTO_TEST_CASE(test_nearest_fb_serialization_skip_waypoints)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
using namespace osrm;
NearestParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Nearest(params, result);
BOOST_REQUIRE(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() == nullptr);
}
BOOST_AUTO_TEST_CASE(test_nearest_fb_error) BOOST_AUTO_TEST_CASE(test_nearest_fb_error)
{ {
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm"); auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");

View File

@ -270,6 +270,53 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
} }
} }
BOOST_AUTO_TEST_CASE(test_route_same_coordinates_no_waypoints)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
using namespace osrm;
RouteParameters params;
params.skip_waypoints = true;
params.steps = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = json::Object();
const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &json_result = result.get<json::Object>();
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end());
const auto &routes = json_result.values.at("routes").get<json::Array>().values;
BOOST_REQUIRE_GT(routes.size(), 0);
for (const auto &route : routes)
{
const auto &route_object = route.get<json::Object>();
const auto distance = route_object.values.at("distance").get<json::Number>().value;
BOOST_CHECK_EQUAL(distance, 0);
const auto duration = route_object.values.at("duration").get<json::Number>().value;
BOOST_CHECK_EQUAL(duration, 0);
// geometries=polyline by default
const auto geometry = route_object.values.at("geometry").get<json::String>().value;
BOOST_CHECK(!geometry.empty());
const auto &legs = route_object.values.at("legs").get<json::Array>().values;
BOOST_CHECK(!legs.empty());
// The rest of legs contents is verified by test_route_same_coordinates
}
}
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component) BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
{ {
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm"); auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
@ -575,4 +622,43 @@ BOOST_AUTO_TEST_CASE(test_route_serialize_fb)
} }
} }
BOOST_AUTO_TEST_CASE(test_route_serialize_fb_skip_waypoints)
{
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
using namespace osrm;
RouteParameters params;
params.skip_waypoints = true;
params.steps = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() == nullptr);
BOOST_CHECK(fb->routes() != nullptr);
const auto routes = fb->routes();
BOOST_REQUIRE_GT(routes->size(), 0);
for (const auto &route : *routes)
{
BOOST_CHECK_EQUAL(route->distance(), 0);
BOOST_CHECK_EQUAL(route->duration(), 0);
const auto &legs = route->legs();
BOOST_CHECK(legs->size() > 0);
// Rest of the content is verified by test_route_serialize_fb
}
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -77,6 +77,57 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
} }
} }
BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix_no_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
TableParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.sources.push_back(0);
params.destinations.push_back(2);
params.annotations = TableParameters::AnnotationsType::All;
engine::api::ResultT result = json::Object();
const auto rc = osrm.Table(params, result);
auto &json_result = result.get<json::Object>();
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
// check that returned durations error is expected size and proportions
// this test expects a 1x1 matrix
const auto &durations_array = json_result.values.at("durations").get<json::Array>().values;
BOOST_CHECK_EQUAL(durations_array.size(), params.sources.size());
for (unsigned int i = 0; i < durations_array.size(); i++)
{
const auto durations_matrix = durations_array[i].get<json::Array>().values;
BOOST_CHECK_EQUAL(durations_matrix.size(),
params.sources.size() * params.destinations.size());
}
// check that returned distances error is expected size and proportions
// this test expects a 1x1 matrix
const auto &distances_array = json_result.values.at("distances").get<json::Array>().values;
BOOST_CHECK_EQUAL(distances_array.size(), params.sources.size());
for (unsigned int i = 0; i < distances_array.size(); i++)
{
const auto distances_matrix = distances_array[i].get<json::Array>().values;
BOOST_CHECK_EQUAL(distances_matrix.size(),
params.sources.size() * params.destinations.size());
}
// waypoint arrays should be missing
BOOST_CHECK(json_result.values.find("destinations") == json_result.values.end());
BOOST_CHECK(json_result.values.find("sources") == json_result.values.end());
}
BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix) BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
{ {
using namespace osrm; using namespace osrm;
@ -247,4 +298,46 @@ BOOST_AUTO_TEST_CASE(test_table_serialiaze_fb)
} }
} }
BOOST_AUTO_TEST_CASE(test_table_serialiaze_fb_no_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
TableParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.coordinates.push_back(get_dummy_location());
params.sources.push_back(0);
params.destinations.push_back(2);
params.annotations = TableParameters::AnnotationsType::All;
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Table(params, result);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->table() != nullptr);
// check that returned durations error is expected size and proportions
// this test expects a 1x1 matrix
BOOST_CHECK(fb->table()->durations() != nullptr);
auto durations_array = fb->table()->durations();
BOOST_CHECK_EQUAL(durations_array->size(), params.sources.size() * params.destinations.size());
// check that returned distances error is expected size and proportions
// this test expects a 1x1 matrix
BOOST_CHECK(fb->table()->distances() != nullptr);
auto distances_array = fb->table()->distances();
BOOST_CHECK_EQUAL(distances_array->size(), params.sources.size() * params.destinations.size());
BOOST_CHECK(fb->table()->destinations() == nullptr);
BOOST_CHECK(fb->waypoints() == nullptr);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -5,6 +5,7 @@
#include "fixture.hpp" #include "fixture.hpp"
#include "osrm/trip_parameters.hpp" #include "osrm/trip_parameters.hpp"
#include <engine/api/flatbuffers/fbresult_generated.h>
#include "osrm/coordinate.hpp" #include "osrm/coordinate.hpp"
#include "osrm/engine_config.hpp" #include "osrm/engine_config.hpp"
@ -57,6 +58,30 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
} }
} }
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component_skip_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(locations.at(0));
params.coordinates.push_back(locations.at(1));
params.coordinates.push_back(locations.at(2));
engine::api::ResultT result = json::Object();
const auto rc = osrm.Trip(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &json_result = result.get<json::Object>();
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end());
}
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component) BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
{ {
using namespace osrm; using namespace osrm;
@ -422,4 +447,72 @@ BOOST_AUTO_TEST_CASE(test_tfse_legal_parameters)
CheckOk(osrm, params); CheckOk(osrm, params);
} }
BOOST_AUTO_TEST_CASE(test_roundtrip_response_fb_serialization)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
params.coordinates.push_back(locations.at(0));
params.coordinates.push_back(locations.at(1));
params.coordinates.push_back(locations.at(2));
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Trip(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() != nullptr);
const auto waypoints = fb->waypoints();
BOOST_CHECK(waypoints->size() == params.coordinates.size());
BOOST_CHECK(fb->routes() != nullptr);
const auto trips = fb->routes();
BOOST_CHECK_EQUAL(trips->size(), 1);
for (const auto &waypoint : *waypoints)
{
const auto longitude = waypoint->location()->longitude();
const auto latitude = waypoint->location()->latitude();
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
const auto trip = waypoint->trips_index();
const auto pos = waypoint->waypoint_index();
BOOST_CHECK(trip < trips->size());
BOOST_CHECK(pos < waypoints->size());
}
}
BOOST_AUTO_TEST_CASE(test_roundtrip_response_fb_serialization_skip_waypoints)
{
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
params.skip_waypoints = true;
params.coordinates.push_back(locations.at(0));
params.coordinates.push_back(locations.at(1));
params.coordinates.push_back(locations.at(2));
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
const auto rc = osrm.Trip(params, result);
BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->waypoints() == nullptr);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()