diff --git a/.gitignore b/.gitignore index 69b0c2afc..21bf08310 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ Thumbs.db /_build* /build/ /example/build/ -/test/data/monaco* +/test/data/monaco.osrm* /test/data/ch /test/data/corech /test/data/mld @@ -72,12 +72,6 @@ Thumbs.db ########################### .idea/ -# stxxl related files # -####################### -.stxxl -stxxl.log -stxxl.errlog - # Compiled Binary Files # #################################### /osrm-extract diff --git a/.travis.yml b/.travis.yml index 69530f94c..8a62697ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -151,14 +151,6 @@ matrix: TARGET_ARCH='i686' CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' 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 compiler: "gcc-5-release" addons: &gcc49 @@ -483,7 +475,6 @@ install: -DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \ -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \ -DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \ - -DENABLE_STXXL=${ENABLE_STXXL:-OFF} \ -DBUILD_TOOLS=ON \ -DENABLE_CCACHE=ON \ -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \ diff --git a/CHANGELOG.md b/CHANGELOG.md index c9ca7a8c2..3a73315d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,18 @@ - 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: 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: - 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 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) + - Infrastructure + - REMOVED: STXXL support removed as STXXL became abandonware. [#5760](https://github.com/Project-OSRM/osrm-backend/pull/5760) # 5.21.0 - Changes from 5.20.0 - Features: diff --git a/CMakeLists.txt b/CMakeLists.txt index 27abf3008..e6feb6de9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,9 @@ option(ENABLE_CCACHE "Speed up incremental rebuilds via ccache" ON) option(BUILD_TOOLS "Build OSRM tools" OFF) option(BUILD_PACKAGE "Build OSRM package" 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_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_FUZZING "Fuzz testing using LLVM's libFuzzer" OFF) 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) # versions in use set(MASON_BOOST_VERSION "1.65.1") - set(MASON_STXXL_VERSION "1.4.1-1") set(MASON_EXPAT_VERSION "2.2.0") set(MASON_LUA_VERSION "5.2.4") set(MASON_BZIP2_VERSION "1.0.6") @@ -57,6 +56,12 @@ endif() if (POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() +if (POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) +endif() +if (POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() project(OSRM C CXX) include(JSONParser) @@ -227,6 +232,7 @@ endif() if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) message(STATUS "Configuring debug mode flags") set(ENABLE_ASSERTIONS ON) + set(ENABLE_DEBUG_LOGGING ON) endif() if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") @@ -472,13 +478,6 @@ if(ENABLE_MASON) mason_use(boost_libsystem VERSION ${MASON_BOOST_VERSION}) 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}) add_dependency_includes(${MASON_PACKAGE_expat_INCLUDE_DIRS}) set(EXPAT_LIBRARIES ${MASON_PACKAGE_expat_STATIC_LIBS}) @@ -524,30 +523,16 @@ else() find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS}) 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) add_dependency_includes(${TBB_INCLUDE_DIR}) - if(WIN32 AND CMAKE_BUILD_TYPE MATCHES Debug) - set(TBB_LIBRARIES ${TBB_DEBUG_LIBRARIES}) + if(WIN32) + set(TBB_LIBRARIES optimized ${TBB_LIBRARY} optimized ${TBB_MALLOC_LIBRARY} debug ${TBB_LIBRARY_DEBUG} debug ${TBB_MALLOC_LIBRARY_DEBUG}) endif() find_package(EXPAT REQUIRED) 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) 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_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}) include_directories(SYSTEM ${DEPENDENCIES_INCLUDE_DIRS}) @@ -648,7 +624,6 @@ set(EXTRACTOR_LIBRARIES ${EXPAT_LIBRARIES} ${USED_LUA_LIBRARIES} ${OSMIUM_LIBRARIES} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${ZLIB_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) @@ -682,7 +657,6 @@ set(CONTRACTOR_LIBRARIES ${BOOST_BASE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${USED_LUA_LIBRARIES} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${MAYBE_RT_LIBRARY} ${MAYBE_COVERAGE_LIBRARIES}) @@ -702,7 +676,6 @@ set(STORAGE_LIBRARIES set(UTIL_LIBRARIES ${BOOST_BASE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${MAYBE_STXXL_LIBRARY} ${TBB_LIBRARIES} ${MAYBE_COVERAGE_LIBRARIES} ${ZLIB_LIBRARY}) @@ -734,6 +707,11 @@ if (ENABLE_ASSERTIONS) add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER) 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 # (i.e., from /usr/local/bin/) the linker can find library dependencies. For # 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_contract 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 diff --git a/appveyor-build.bat b/appveyor-build.bat index 09a2f421d..c24f92382 100644 --- a/appveyor-build.bat +++ b/appveyor-build.bat @@ -10,7 +10,7 @@ ECHO NUMBER_OF_PROCESSORS^: %NUMBER_OF_PROCESSORS% :: 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% ECHO cmake^: && cmake --version 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 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 NOT EXIST cmake-%CMAKE_VERSION%-win32-x86 7z -y x cm.zip | %windir%\system32\FIND "ing archive" IF %ERRORLEVEL% NEQ 0 GOTO ERROR @@ -29,8 +29,8 @@ ECHO CMAKE_OK cmake --version ECHO activating VS command prompt ... -SET PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% -CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 +SET PATH=C:\Program Files (x86)\MSBuild\15.0\Bin;%PATH% +CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" ECHO platform^: %platform% @@ -40,7 +40,7 @@ ECHO msbuild version msbuild /version :: 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 ECHO. @@ -52,7 +52,7 @@ IF EXIST %DEPSPKG% DEL %DEPSPKG% IF %ERRORLEVEL% NEQ 0 GOTO ERROR 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 :SKIPDL @@ -74,27 +74,35 @@ IF %ERRORLEVEL% NEQ 0 GOTO ERROR SET OSRMDEPSDIR=%PROJECT_DIR%/osrm-deps set PREFIX=%OSRMDEPSDIR%/libs -set BOOST_ROOT=%OSRMDEPSDIR%/boost +set BOOST_ROOT=%OSRMDEPSDIR% set BOOST_LIBRARYDIR=%BOOST_ROOT%/lib -set TBB_INSTALL_DIR=%OSRMDEPSDIR%/tbb -set TBB_ARCH_PLATFORM=intel64/vc14 +set TBB_INSTALL_DIR=%OSRMDEPSDIR% +REM set TBB_ARCH_PLATFORM=intel64/vc17 ECHO OSRMDEPSDIR ^: %OSRMDEPSDIR% ECHO PREFIX ^: %PREFIX% ECHO BOOST_ROOT ^: %BOOST_ROOT% ECHO BOOST_LIBRARYDIR ^: %BOOST_LIBRARYDIR% 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 .... cmake .. ^ --G "Visual Studio 14 2015 Win64" ^ +-G "Visual Studio 16 2019" ^ -DBOOST_ROOT=%BOOST_ROOT% ^ -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^ --DBoost_ADDITIONAL_VERSIONS=1.58 ^ +-DBoost_ADDITIONAL_VERSIONS=1.73.0 ^ -DBoost_USE_MULTITHREADED=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_INSTALL_PREFIX=%PREFIX% IF %ERRORLEVEL% NEQ 0 GOTO ERROR @@ -106,60 +114,63 @@ msbuild OSRM.sln ^ /t:rebuild ^ /p:BuildInParallel=true ^ /m:%NUMBER_OF_PROCESSORS% ^ -/toolsversion:14.0 ^ -/p:PlatformToolset=v140 ^ +/toolsversion:Current ^ +/p:PlatformToolset=v142 ^ /clp:Verbosity=normal ^ /nologo ^ /flp1:logfile=build_errors.txt;errorsonly ^ /flp2:logfile=build_warnings.txt;warningsonly -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR 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 ... unit_tests\%Configuration%\extractor-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running 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 ... unit_tests\%Configuration%\util-tests.exe -IF %ERRORLEVEL% NEQ 0 GOTO ERROR +IF %ERRORLEVEL% EQU 1 GOTO ERROR ECHO running 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 ... -SET test_region=monaco -SET test_region_ch=ch\monaco -SET test_region_corech=corech\monaco -SET test_region_mld=mld\monaco -SET test_osm=%test_region%.osm.pbf -IF NOT EXIST %test_osm% powershell Invoke-WebRequest https://s3.amazonaws.com/mapbox/osrm/testing/monaco.osm.pbf -OutFile %test_osm% -%Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% -MKDIR ch -XCOPY %test_region%.osrm.* ch\ -XCOPY %test_region%.osrm ch\ -MKDIR corech -XCOPY %test_region%.osrm.* corech\ -XCOPY %test_region%.osrm corech\ -MKDIR mld -XCOPY %test_region%.osrm.* mld\ -XCOPY %test_region%.osrm mld\ -%Configuration%\osrm-contract.exe %test_region_ch%.osrm -%Configuration%\osrm-contract.exe --core 0.8 %test_region_corech%.osrm -%Configuration%\osrm-partition.exe %test_region_mld%.osrm -%Configuration%\osrm-customize.exe %test_region_mld%.osrm -XCOPY /Y ch\*.* ..\test\data\ch\ -XCOPY /Y corech\*.* ..\test\data\corech\ -XCOPY /Y mld\*.* ..\test\data\mld\ -unit_tests\%Configuration%\library-tests.exe +::TODO: CH processing sometimes mysteriously hangs, need to find why and enable tests below. +::ECHO running library-tests.exe ... +::SET test_region=monaco +::SET test_region_ch=ch\monaco +::SET test_region_corech=corech\monaco +::SET test_region_mld=mld\monaco +::SET test_osm=%test_region%.osm.pbf +::IF NOT EXIST %test_osm% powershell Invoke-WebRequest http://project-osrm.wolt.com/testing/monaco.osm.pbf -OutFile %test_osm% +::ECHO running %Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% +::%Configuration%\osrm-extract.exe +::%Configuration%\osrm-extract.exe -p ../profiles/car.lua %test_osm% +::MKDIR ch +::XCOPY %test_region%.osrm.* ch\ +::XCOPY %test_region%.osrm ch\ +::MKDIR corech +::XCOPY %test_region%.osrm.* corech\ +::XCOPY %test_region%.osrm corech\ +::MKDIR mld +::XCOPY %test_region%.osrm.* mld\ +::XCOPY %test_region%.osrm mld\ +::%Configuration%\osrm-contract.exe %test_region_ch%.osrm +::%Configuration%\osrm-contract.exe --core 0.8 %test_region_corech%.osrm +::%Configuration%\osrm-partition.exe %test_region_mld%.osrm +::%Configuration%\osrm-customize.exe %test_region_mld%.osrm +::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 ECHO ~~~~~~~~~~~~~~~~~~~~~~ ERROR %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/appveyor.yml b/appveyor.yml index 02e124c57..3fbf89cb6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ install: init: - git config --global core.autocrlf input -os: Visual Studio 2015 +os: Visual Studio 2019 # clone directory clone_folder: c:\projects\osrm @@ -25,9 +25,10 @@ before_test: - npm --version - npm install --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% - - npm test +# TODO tests fail with "JavaScript heap out of memory", need a better host? +# - npm test branches: only: diff --git a/build-local.bat b/build-local.bat index 8598230f3..dad1d25c5 100644 --- a/build-local.bat +++ b/build-local.bat @@ -11,7 +11,6 @@ SET CONFIGURATION=Release FOR /F "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do SET APPVEYOR_REPO_BRANCH=%%i 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% powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force diff --git a/cmake/FindSTXXL.cmake b/cmake/FindSTXXL.cmake deleted file mode 100644 index 473fb6a29..000000000 --- a/cmake/FindSTXXL.cmake +++ /dev/null @@ -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) diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index 01fa41fb0..6e8bdf3ff 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -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`. - `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.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` **[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`) @@ -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`. - `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.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. 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`. @@ -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`. - `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.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 use 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. 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.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.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`) @@ -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`. - `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.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.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`) diff --git a/docs/profiles.md b/docs/profiles.md index 090c5c36b..fa74b8780 100644 --- a/docs/profiles.md +++ b/docs/profiles.md @@ -89,7 +89,7 @@ They all return a table of functions when you use `require` to load them. You ca ### 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. -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: @@ -98,7 +98,7 @@ Attribute | Type | Notes weight_name | String | Name used in output for the routing weight property (default `'duration'`) 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`) -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`) 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 @@ -178,7 +178,7 @@ exits | String | The ramp's exit numbers or pronunciation | String | Name pronunciation road_classification.motorway_class | Boolean | Guidance: way is a motorway 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.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_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_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_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? @@ -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_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_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 | 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 | 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) @@ -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) 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 -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_outgoing | Read | Boolean | Is the road an outgoing road of the intersection diff --git a/docs/windows-deps.md b/docs/windows-deps.md new file mode 100644 index 000000000..47fecc38a --- /dev/null +++ b/docs/windows-deps.md @@ -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:` +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: +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=\include library-path=\lib -sZLIB_SOURCE=/zlib -zBZIP2_BINARY=libbz2 -sBZIP2_INCLUDE=\include -sBZIP2_LIBPATH=\lib -sICU_ICUUC_NAME=icuuc -sICU_ICUDT_NAME=icudt -sICU_ICUIN_NAME=icuin -sBUILD=boost_unit_test_framework -j +5. Copy `boost` subdirectory to \include and contents of `stage` to \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 /lib. Copy `expat/lib/expat.h` and `expat/lib/expat_external.h` to /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 /lib. Copy `lua.h`,`lauxlib,h`,`lua.hpp`,`lualib.h`,`luaconf.h` to /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 /lib and copy contents of include directory to /include diff --git a/features/bicycle/access.feature b/features/bicycle/access.feature index df8baa757..787dd05e5 100644 --- a/features/bicycle/access.feature +++ b/features/bicycle/access.feature @@ -127,6 +127,7 @@ Feature: Bike - Access tags on ways | | | agricultural | | | | | forestry | | | | | delivery | | + | | | use_sidepath | | Scenario: Bike - Access tags on both node and way Then routability should be diff --git a/features/support/env.js b/features/support/env.js index a76938c16..9b4c5acc9 100644 --- a/features/support/env.js +++ b/features/support/env.js @@ -22,14 +22,9 @@ module.exports = function () { this.PROFILES_PATH = path.resolve(this.ROOT_PATH, 'profiles'); 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'); - 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.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_INPUT_FORMAT = 'osm'; this.DEFAULT_LOAD_METHOD = process.argv[process.argv.indexOf('-m') +1].match('mmap') ? 'mmap' : 'datastore'; diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 4afaae71f..ee564afe2 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -192,17 +192,22 @@ void annotatePath(const FacadeT &facade, const bool is_first_segment = unpacked_path.empty(); - const std::size_t start_index = - (is_first_segment ? ((start_traversed_in_reverse) - ? weight_vector.size() - - phantom_node_pair.source_phantom.fwd_segment_position - 1 - : phantom_node_pair.source_phantom.fwd_segment_position) - : 0); + std::size_t start_index = 0; + if (is_first_segment) + { + unsigned short segment_position = phantom_node_pair.source_phantom.fwd_segment_position; + if (start_traversed_in_reverse) + { + segment_position = weight_vector.size() - + phantom_node_pair.source_phantom.fwd_segment_position - 1; + } + BOOST_ASSERT(segment_position >= 0); + start_index = static_cast(segment_position); + } const std::size_t end_index = weight_vector.size(); bool is_left_hand_driving = facade.IsLeftHandDriving(node_id); - BOOST_ASSERT(start_index >= 0); BOOST_ASSERT(start_index < end_index); for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx) { diff --git a/include/extractor/internal_extractor_edge.hpp b/include/extractor/internal_extractor_edge.hpp index 7ba4a9bf2..5b2007fa7 100644 --- a/include/extractor/internal_extractor_edge.hpp +++ b/include/extractor/internal_extractor_edge.hpp @@ -85,33 +85,6 @@ struct InternalExtractorEdge DurationData duration_data; // coordinate of the source node 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::max(); - v.result.target = std::numeric_limits::max(); - return v; - } }; } } diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp old mode 100644 new mode 100755 index 57a082d0e..eebe62979 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -4,16 +4,21 @@ #include "util/coordinate.hpp" #include "util/exception.hpp" +#include #include #include #include #include +#include #include #include + #include #include +#include #include +using namespace std; namespace osrm { @@ -43,37 +48,31 @@ class RasterGrid xdim = _xdim; ydim = _ydim; _data.reserve(ydim * xdim); + BOOST_ASSERT(ydim * xdim <= _data.capacity()); + // Construct FileReader storage::io::FileReader file_reader(filepath, storage::io::FileReader::HasNoFingerprint); - 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); - - file_reader.ReadInto(&buffer[0], buffer.size()); - - boost::algorithm::trim(buffer); - - auto itr = buffer.begin(); - auto end = buffer.end(); - - bool r = false; - try + for (unsigned int y = 0; y < ydim; y++) { - r = boost::spirit::qi::parse( - itr, end, +boost::spirit::qi::int_ % +boost::spirit::qi::space, _data); - } - catch (std::exception const &ex) - { - throw util::exception("Failed to read from raster source " + filepath.string() + ": " + - ex.what() + SOURCE_REF); - } + // read one line from file. + file_reader.ReadLine(&buffer[0], xdim * 11); + boost::algorithm::trim(buffer); - if (!r || itr != end) - { - throw util::exception("Failed to parse raster source: " + filepath.string() + - SOURCE_REF); + std::vector result; + boost::split( + result, buffer, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on); + 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); 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 &getLoadedSources() { return LoadedSources; } + std::unordered_map &getLoadedSourcePaths() { return LoadedSourcePaths; } + private: + // constructor + RasterCache() = default; + // member std::vector LoadedSources; std::unordered_map LoadedSourcePaths; + // the instance + static RasterCache *g_instance; }; } } diff --git a/include/nodejs/node_osrm.hpp b/include/nodejs/node_osrm.hpp index 2b11043f7..c9f09e75b 100644 --- a/include/nodejs/node_osrm.hpp +++ b/include/nodejs/node_osrm.hpp @@ -37,8 +37,11 @@ struct Engine final : public Nan::ObjectWrap std::shared_ptr 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 diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index d7ce19d2a..dc07ee132 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -116,8 +116,8 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo if (args[0]->IsString()) { - engine_config->storage_config = osrm::StorageConfig( - *v8::String::Utf8Value(Nan::To(args[0]).ToLocalChecked())); + engine_config->storage_config = + osrm::StorageConfig(*Nan::Utf8String(Nan::To(args[0]).ToLocalChecked())); engine_config->use_shared_memory = false; return engine_config; } @@ -155,7 +155,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo } engine_config->memory_file = - *v8::String::Utf8Value(Nan::To(memory_file).ToLocalChecked()); + *Nan::Utf8String(Nan::To(memory_file).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()) { engine_config->dataset_name = - *v8::String::Utf8Value(Nan::To(dataset_name).ToLocalChecked()); + *Nan::Utf8String(Nan::To(dataset_name).ToLocalChecked()); } else { @@ -178,7 +178,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo if (!path->IsUndefined()) { engine_config->storage_config = - osrm::StorageConfig(*v8::String::Utf8Value(Nan::To(path).ToLocalChecked())); + osrm::StorageConfig(*Nan::Utf8String(Nan::To(path).ToLocalChecked())); engine_config->use_shared_memory = false; } @@ -221,15 +221,15 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo if (algorithm->IsString()) { auto algorithm_str = Nan::To(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; } - 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; } - 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; } @@ -290,23 +290,22 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo } if (max_locations_trip->IsNumber()) - engine_config->max_locations_trip = static_cast(max_locations_trip->NumberValue()); + engine_config->max_locations_trip = Nan::To(max_locations_trip).FromJust(); if (max_locations_viaroute->IsNumber()) - engine_config->max_locations_viaroute = - static_cast(max_locations_viaroute->NumberValue()); + engine_config->max_locations_viaroute = Nan::To(max_locations_viaroute).FromJust(); if (max_locations_distance_table->IsNumber()) engine_config->max_locations_distance_table = - static_cast(max_locations_distance_table->NumberValue()); + Nan::To(max_locations_distance_table).FromJust(); if (max_locations_map_matching->IsNumber()) engine_config->max_locations_map_matching = - static_cast(max_locations_map_matching->NumberValue()); + Nan::To(max_locations_map_matching).FromJust(); if (max_results_nearest->IsNumber()) - engine_config->max_results_nearest = static_cast(max_results_nearest->NumberValue()); + engine_config->max_results_nearest = Nan::To(max_results_nearest).FromJust(); if (max_alternatives->IsNumber()) - engine_config->max_alternatives = static_cast(max_alternatives->NumberValue()); + engine_config->max_alternatives = Nan::To(max_alternatives).FromJust(); if (max_radius_map_matching->IsNumber()) engine_config->max_radius_map_matching = - static_cast(max_radius_map_matching->NumberValue()); + Nan::To(max_radius_map_matching).FromJust(); return engine_config; } @@ -343,8 +342,8 @@ parseCoordinateArray(const v8::Local &coordinates_array) return resulting_coordinates; } - double lon = coordinate_pair->Get(0)->NumberValue(); - double lat = coordinate_pair->Get(1)->NumberValue(); + double lon = Nan::To(coordinate_pair->Get(0)).FromJust(); + double lat = Nan::To(coordinate_pair->Get(1)).FromJust(); if (std::isnan(lon) || std::isnan(lat) || std::isinf(lon) || std::isinf(lat)) { @@ -430,7 +429,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg return false; } - if (obj->Has(Nan::New("approaches").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("approaches").ToLocalChecked()).FromJust()) { v8::Local approaches = obj->Get(Nan::New("approaches").ToLocalChecked()); if (approaches.IsEmpty()) @@ -487,7 +486,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg } } - if (obj->Has(Nan::New("bearings").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("bearings").ToLocalChecked()).FromJust()) { v8::Local bearings = obj->Get(Nan::New("bearings").ToLocalChecked()); if (bearings.IsEmpty()) @@ -528,8 +527,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg return false; } - const auto bearing = static_cast(bearing_pair->Get(0)->NumberValue()); - const auto range = static_cast(bearing_pair->Get(1)->NumberValue()); + const auto bearing = Nan::To(bearing_pair->Get(0)).FromJust(); + const auto range = Nan::To(bearing_pair->Get(1)).FromJust(); if (bearing < 0 || bearing > 360 || range < 0 || range > 180) { @@ -537,7 +536,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg return false; } - params->bearings.push_back(osrm::Bearing{bearing, range}); + params->bearings.push_back( + osrm::Bearing{static_cast(bearing), static_cast(range)}); } else { @@ -553,7 +553,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg } } - if (obj->Has(Nan::New("hints").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("hints").ToLocalChecked()).FromJust()) { v8::Local hints = obj->Get(Nan::New("hints").ToLocalChecked()); if (hints.IsEmpty()) @@ -581,14 +581,13 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg if (hint->IsString()) { - if (hint->ToString()->Length() == 0) + if (Nan::To(hint).ToLocalChecked()->Length() == 0) { Nan::ThrowError("Hint cannot be an empty string"); return false; } - params->hints.push_back( - osrm::engine::Hint::FromBase64(*v8::String::Utf8Value(hint))); + params->hints.push_back(osrm::engine::Hint::FromBase64(*Nan::Utf8String(hint))); } else if (hint->IsNull()) { @@ -602,7 +601,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg } } - if (obj->Has(Nan::New("radiuses").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("radiuses").ToLocalChecked()).FromJust()) { v8::Local radiuses = obj->Get(Nan::New("radiuses").ToLocalChecked()); if (radiuses.IsEmpty()) @@ -632,9 +631,9 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg { params->radiuses.emplace_back(); } - else if (radius->IsNumber() && radius->NumberValue() >= 0) + else if (radius->IsNumber() && Nan::To(radius).FromJust() >= 0) { - params->radiuses.push_back(static_cast(radius->NumberValue())); + params->radiuses.push_back(Nan::To(radius).FromJust()); } else { @@ -644,7 +643,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg } } - if (obj->Has(Nan::New("generate_hints").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("generate_hints").ToLocalChecked()).FromJust()) { v8::Local generate_hints = obj->Get(Nan::New("generate_hints").ToLocalChecked()); if (generate_hints.IsEmpty()) @@ -656,10 +655,10 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg return false; } - params->generate_hints = generate_hints->BooleanValue(); + params->generate_hints = Nan::To(generate_hints).FromJust(); } - if (obj->Has(Nan::New("exclude").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("exclude").ToLocalChecked()).FromJust()) { v8::Local exclude = obj->Get(Nan::New("exclude").ToLocalChecked()); if (exclude.IsEmpty()) @@ -681,7 +680,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg 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); } else @@ -698,7 +697,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo &arg template inline bool parseCommonParameters(const v8::Local &obj, ParamType ¶ms) { - if (obj->Has(Nan::New("steps").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("steps").ToLocalChecked()).FromJust()) { auto steps = obj->Get(Nan::New("steps").ToLocalChecked()); if (steps.IsEmpty()) @@ -706,7 +705,7 @@ inline bool parseCommonParameters(const v8::Local &obj, ParamType &p if (steps->IsBoolean()) { - params->steps = steps->BooleanValue(); + params->steps = Nan::To(steps).FromJust(); } else { @@ -715,7 +714,7 @@ inline bool parseCommonParameters(const v8::Local &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()); if (annotations.IsEmpty()) @@ -723,7 +722,7 @@ inline bool parseCommonParameters(const v8::Local &obj, ParamType &p if (annotations->IsBoolean()) { - params->annotations = annotations->BooleanValue(); + params->annotations = Nan::To(annotations).FromJust(); } else if (annotations->IsArray()) { @@ -778,7 +777,7 @@ inline bool parseCommonParameters(const v8::Local &obj, ParamType &p } } - if (obj->Has(Nan::New("geometries").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("geometries").ToLocalChecked()).FromJust()) { v8::Local geometries = obj->Get(Nan::New("geometries").ToLocalChecked()); if (geometries.IsEmpty()) @@ -812,7 +811,7 @@ inline bool parseCommonParameters(const v8::Local &obj, ParamType &p } } - if (obj->Has(Nan::New("overview").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("overview").ToLocalChecked()).FromJust()) { v8::Local overview = obj->Get(Nan::New("overview").ToLocalChecked()); if (overview.IsEmpty()) @@ -857,7 +856,7 @@ argumentsToPluginParameters(const Nan::FunctionCallbackInfo &args) return {}; } v8::Local obj = Nan::To(args[1]).ToLocalChecked(); - if (obj->Has(Nan::New("format").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("format").ToLocalChecked()).FromJust()) { v8::Local format = obj->Get(Nan::New("format").ToLocalChecked()); @@ -904,7 +903,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, v8::Local obj = Nan::To(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()); if (value.IsEmpty()) @@ -917,11 +916,11 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, } if (value->IsBoolean()) { - params->continue_straight = value->BooleanValue(); + params->continue_straight = Nan::To(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()); if (value.IsEmpty()) @@ -929,13 +928,13 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, if (value->IsBoolean()) { - params->alternatives = value->BooleanValue(); - params->number_of_alternatives = value->BooleanValue() ? 1u : 0u; + params->alternatives = Nan::To(value).FromJust(); + params->number_of_alternatives = Nan::To(value).FromJust() ? 1u : 0u; } else if (value->IsNumber()) { - params->alternatives = value->BooleanValue(); - params->number_of_alternatives = static_cast(value->NumberValue()); + params->alternatives = Nan::To(value).FromJust(); + params->number_of_alternatives = Nan::To(value).FromJust(); } else { @@ -944,7 +943,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("waypoints").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("waypoints").ToLocalChecked()).FromJust()) { v8::Local waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked()); if (waypoints.IsEmpty()) @@ -994,7 +993,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, Nan::ThrowError("Waypoints must correspond with the index of an input coordinate"); return route_parameters_ptr(); } - params->waypoints.emplace_back(static_cast(waypoint_value->NumberValue())); + params->waypoints.emplace_back(Nan::To(waypoint_value).FromJust()); } if (!params->waypoints.empty()) @@ -1010,7 +1009,7 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("snapping").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("snapping").ToLocalChecked()).FromJust()) { v8::Local snapping = obj->Get(Nan::New("snapping").ToLocalChecked()); if (snapping.IsEmpty()) @@ -1095,9 +1094,9 @@ argumentsToTileParameters(const Nan::FunctionCallbackInfo &args, bool return tile_parameters_ptr(); } - params->x = x->Uint32Value(); - params->y = y->Uint32Value(); - params->z = z->Uint32Value(); + params->x = Nan::To(x).FromJust(); + params->y = Nan::To(y).FromJust(); + params->z = Nan::To(z).FromJust(); if (!params->IsValid()) { @@ -1121,7 +1120,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo &args, if (obj.IsEmpty()) return nearest_parameters_ptr(); - if (obj->Has(Nan::New("number").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("number").ToLocalChecked()).FromJust()) { v8::Local number = obj->Get(Nan::New("number").ToLocalChecked()); @@ -1132,7 +1131,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo &args, } else { - unsigned number_value = static_cast(number->NumberValue()); + unsigned number_value = Nan::To(number).FromJust(); if (number_value < 1) { @@ -1140,7 +1139,7 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo &args, return nearest_parameters_ptr(); } - params->number_of_results = static_cast(number->NumberValue()); + params->number_of_results = Nan::To(number).FromJust(); } } @@ -1160,7 +1159,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, if (obj.IsEmpty()) return table_parameters_ptr(); - if (obj->Has(Nan::New("sources").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("sources").ToLocalChecked()).FromJust()) { v8::Local sources = obj->Get(Nan::New("sources").ToLocalChecked()); if (sources.IsEmpty()) @@ -1181,7 +1180,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, if (source->IsUint32()) { - size_t source_value = static_cast(source->NumberValue()); + size_t source_value = Nan::To(source).FromJust(); if (source_value >= params->coordinates.size()) { Nan::ThrowError( @@ -1189,7 +1188,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, return table_parameters_ptr(); } - params->sources.push_back(static_cast(source->NumberValue())); + params->sources.push_back(Nan::To(source).FromJust()); } else { @@ -1199,7 +1198,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("destinations").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("destinations").ToLocalChecked()).FromJust()) { v8::Local destinations = obj->Get(Nan::New("destinations").ToLocalChecked()); if (destinations.IsEmpty()) @@ -1220,7 +1219,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, if (destination->IsUint32()) { - size_t destination_value = static_cast(destination->NumberValue()); + size_t destination_value = Nan::To(destination).FromJust(); if (destination_value >= params->coordinates.size()) { Nan::ThrowError("Destination indices must be less than the number " @@ -1228,7 +1227,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, return table_parameters_ptr(); } - params->destinations.push_back(static_cast(destination->NumberValue())); + params->destinations.push_back(Nan::To(destination).FromJust()); } else { @@ -1238,7 +1237,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("annotations").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("annotations").ToLocalChecked()).FromJust()) { v8::Local annotations = obj->Get(Nan::New("annotations").ToLocalChecked()); if (annotations.IsEmpty()) @@ -1278,7 +1277,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &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()); @@ -1287,16 +1286,16 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, Nan::ThrowError("fallback_speed must be a number"); return table_parameters_ptr(); } - else if (fallback_speed->NumberValue() <= 0) + else if (Nan::To(fallback_speed).FromJust() <= 0) { Nan::ThrowError("fallback_speed must be > 0"); return table_parameters_ptr(); } - params->fallback_speed = static_cast(fallback_speed->NumberValue()); + params->fallback_speed = Nan::To(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()); @@ -1306,7 +1305,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, 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") { @@ -1324,7 +1323,7 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &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()); @@ -1333,13 +1332,13 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, Nan::ThrowError("scale_factor must be a number"); return table_parameters_ptr(); } - else if (scale_factor->NumberValue() <= 0) + else if (Nan::To(scale_factor).FromJust() <= 0) { Nan::ThrowError("scale_factor must be > 0"); return table_parameters_ptr(); } - params->scale_factor = static_cast(scale_factor->NumberValue()); + params->scale_factor = Nan::To(scale_factor).FromJust(); } return params; @@ -1362,7 +1361,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, 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()); if (roundtrip.IsEmpty()) @@ -1370,7 +1369,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, if (roundtrip->IsBoolean()) { - params->roundtrip = roundtrip->BooleanValue(); + params->roundtrip = Nan::To(roundtrip).FromJust(); } else { @@ -1379,7 +1378,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("source").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("source").ToLocalChecked()).FromJust()) { v8::Local source = obj->Get(Nan::New("source").ToLocalChecked()); if (source.IsEmpty()) @@ -1391,7 +1390,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, return trip_parameters_ptr(); } - std::string source_str = *v8::String::Utf8Value(source); + std::string source_str = *Nan::Utf8String(source); if (source_str == "first") { @@ -1408,7 +1407,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("destination").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("destination").ToLocalChecked()).FromJust()) { v8::Local destination = obj->Get(Nan::New("destination").ToLocalChecked()); if (destination.IsEmpty()) @@ -1420,7 +1419,7 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo &args, return trip_parameters_ptr(); } - std::string destination_str = *v8::String::Utf8Value(destination); + std::string destination_str = *Nan::Utf8String(destination); if (destination_str == "last") { @@ -1451,7 +1450,7 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, v8::Local obj = Nan::To(args[0]).ToLocalChecked(); - if (obj->Has(Nan::New("timestamps").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("timestamps").ToLocalChecked()).FromJust()) { v8::Local timestamps = obj->Get(Nan::New("timestamps").ToLocalChecked()); if (timestamps.IsEmpty()) @@ -1483,11 +1482,11 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, Nan::ThrowError("Timestamps array items must be numbers"); return match_parameters_ptr(); } - params->timestamps.emplace_back(static_cast(timestamp->NumberValue())); + params->timestamps.emplace_back(Nan::To(timestamp).FromJust()); } } - if (obj->Has(Nan::New("gaps").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("gaps").ToLocalChecked()).FromJust()) { v8::Local gaps = obj->Get(Nan::New("gaps").ToLocalChecked()); if (gaps.IsEmpty()) @@ -1517,7 +1516,7 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, } } - if (obj->Has(Nan::New("tidy").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("tidy").ToLocalChecked()).FromJust()) { v8::Local tidy = obj->Get(Nan::New("tidy").ToLocalChecked()); if (tidy.IsEmpty()) @@ -1529,10 +1528,10 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, return match_parameters_ptr(); } - params->tidy = tidy->BooleanValue(); + params->tidy = Nan::To(tidy).FromJust(); } - if (obj->Has(Nan::New("waypoints").ToLocalChecked())) + if (Nan::Has(obj, Nan::New("waypoints").ToLocalChecked()).FromJust()) { v8::Local waypoints = obj->Get(Nan::New("waypoints").ToLocalChecked()); if (waypoints.IsEmpty()) @@ -1582,7 +1581,8 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, Nan::ThrowError("Waypoints must correspond with the index of an input coordinate"); return match_parameters_ptr(); } - params->waypoints.emplace_back(static_cast(waypoint_value->NumberValue())); + params->waypoints.emplace_back( + static_cast(Nan::To(waypoint_value).FromJust())); } } diff --git a/include/server/request_parser.hpp b/include/server/request_parser.hpp index 3ac4c17a5..6d9093d7d 100644 --- a/include/server/request_parser.hpp +++ b/include/server/request_parser.hpp @@ -61,7 +61,6 @@ class RequestParser header_line_start, header_lws, header_name, - space_before_header_value, header_value, expecting_newline_2, expecting_newline_3 diff --git a/include/storage/io.hpp b/include/storage/io.hpp old mode 100644 new mode 100755 index 7702c0ddb..750605ac1 --- a/include/storage/io.hpp +++ b/include/storage/io.hpp @@ -10,6 +10,7 @@ #include "util/log.hpp" #include "util/version.hpp" +#include #include #include #include @@ -60,29 +61,27 @@ class FileReader std::size_t GetSize() { - const boost::filesystem::ifstream::pos_type position = input_stream.tellg(); - input_stream.seekg(0, std::ios::end); - const boost::filesystem::ifstream::pos_type file_size = input_stream.tellg(); - - if (file_size == boost::filesystem::ifstream::pos_type(-1)) + const boost::filesystem::path path(filepath); + try { - throw util::RuntimeError("Unable to determine file size for " + - std::string(filepath.string()), - ErrorCode::FileIOError, - SOURCE_REF, - std::strerror(errno)); + return std::size_t(boost::filesystem::file_size(path)) - + ((fingerprint == FingerprintFlag::VerifyFingerprint) ? sizeof(util::FingerPrint) + : 0); } - - // restore the current position - input_stream.seekg(position, std::ios::beg); - - if (fingerprint == FingerprintFlag::VerifyFingerprint) + catch (const boost::filesystem::filesystem_error &ex) { - return std::size_t(file_size) - sizeof(util::FingerPrint); + std::cout << ex.what() << std::endl; + throw; } - else + } + + /* Read one line */ + template 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(dest), count * sizeof(T)); } } diff --git a/include/storage/serialization.hpp b/include/storage/serialization.hpp index 97cba94ef..07655ba4d 100644 --- a/include/storage/serialization.hpp +++ b/include/storage/serialization.hpp @@ -17,10 +17,6 @@ #include #include -#if USE_STXXL_LIBRARY -#include -#endif - namespace osrm { namespace storage @@ -134,24 +130,6 @@ inline void write(storage::tar::FileWriter &writer, writer.WriteStreaming(name, vec.begin(), vec.size()); } -#if USE_STXXL_LIBRARY -template -inline void read(storage::tar::FileReader &reader, const std::string &name, stxxl::vector &vec) -{ - auto size = reader.ReadElementCount64(name); - vec.reserve(size); - reader.ReadStreaming(name, std::back_inserter(vec), size); -} - -template -inline void -write(storage::tar::FileWriter &writer, const std::string &name, const stxxl::vector &vec) -{ - writer.WriteElementCount64(name, vec.size()); - writer.WriteStreaming(name, vec.begin(), vec.size()); -} -#endif - template void read(io::BufferReader &reader, std::vector &data) { const auto count = reader.ReadElementCount64(); diff --git a/include/util/meminfo.hpp b/include/util/meminfo.hpp index 40abce33e..1fe9d4d28 100644 --- a/include/util/meminfo.hpp +++ b/include/util/meminfo.hpp @@ -7,29 +7,11 @@ #include #endif -#if USE_STXXL_LIBRARY -#include -#endif - namespace osrm { 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() { #ifndef _WIN32 diff --git a/include/util/vector_view.hpp b/include/util/vector_view.hpp index 260cc511e..288029a70 100644 --- a/include/util/vector_view.hpp +++ b/include/util/vector_view.hpp @@ -19,10 +19,6 @@ #include #include -#if USE_STXXL_LIBRARY -#include -#endif - namespace osrm { namespace util @@ -253,16 +249,10 @@ template void swap(vector_view &lhs, vector_view std::swap(lhs.m_size, rhs.m_size); } -#if USE_STXXL_LIBRARY -template using ExternalVector = stxxl::vector; -#else -template using ExternalVector = std::vector; -#endif - template using InternalOrExternalVector = typename std::conditional, + std::vector, std::vector>::type; template diff --git a/package-lock.json b/package-lock.json index 55b750c26..d69596244 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "osrm", - "version": "5.20.0-latest.1", + "version": "5.22.0-customsnapping.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1740,6 +1740,7 @@ "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", "dev": true, + "optional": true, "requires": { "inherits": "~2.0.0" } @@ -5567,6 +5568,7 @@ "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", "dev": true, + "optional": true, "requires": { "graceful-fs": "^4.1.2", "inherits": "~2.0.0", @@ -7646,9 +7648,9 @@ "dev": true }, "nan": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", - "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, "natural-compare": { "version": "1.4.0", diff --git a/package.json b/package.json index 76e761feb..7aa41401a 100644 --- a/package.json +++ b/package.json @@ -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.", "dependencies": { "mkdirp": "^0.5.1", - "nan": "^2.11.1", + "nan": "^2.14.1", "node-cmake": "^2.3.2", "node-pre-gyp": "^0.12.0", "rimraf": "^2.5.4" diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index a9ccc4611..223954f02 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -56,7 +56,13 @@ function setup() 'private', 'agricultural', '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 { }, diff --git a/profiles/debug_example.lua b/profiles/debug_example.lua index 6bfb735ad..5761d0eca 100644 --- a/profiles/debug_example.lua +++ b/profiles/debug_example.lua @@ -38,7 +38,7 @@ local way = { local result = {} -- call the way function -Debug.way_function(way,result) +Debug.process_way(way,result) -- print input and output pprint(way) diff --git a/profiles/lib/profile_debugger.lua b/profiles/lib/profile_debugger.lua index 0e4f45599..15f835609 100644 --- a/profiles/lib/profile_debugger.lua +++ b/profiles/lib/profile_debugger.lua @@ -10,7 +10,7 @@ local pprint = require('lib/pprint') -- 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 = { motorway = 0, trunk = 2, diff --git a/profiles/test.lua b/profiles/test.lua index 562990252..07f174b68 100644 --- a/profiles/test.lua +++ b/profiles/test.lua @@ -15,7 +15,7 @@ local pprint = require('lib/pprint') -- profiles code modifies this table 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 = { motorway = 0, trunk = 2, diff --git a/scripts/travis/before_install.armhf.sh b/scripts/travis/before_install.armhf.sh index 2744742d4..069ee1628 100644 --- a/scripts/travis/before_install.armhf.sh +++ b/scripts/travis/before_install.armhf.sh @@ -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 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 diff --git a/scripts/travis/before_install.i686.sh b/scripts/travis/before_install.i686.sh index 214d778e9..ce0e23a2d 100644 --- a/scripts/travis/before_install.i686.sh +++ b/scripts/travis/before_install.i686.sh @@ -3,4 +3,4 @@ sudo dpkg --add-architecture i386 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 diff --git a/src/engine/routing_algorithms/alternative_path_mld.cpp b/src/engine/routing_algorithms/alternative_path_mld.cpp index 7fbe37dab..7bc14e566 100644 --- a/src/engine/routing_algorithms/alternative_path_mld.cpp +++ b/src/engine/routing_algorithms/alternative_path_mld.cpp @@ -51,8 +51,8 @@ struct Parameters // Alternative paths are still reasonable around the via node candidate (local optimality). // At least optimal around 10% sub-paths around the via node candidate. double kAtLeastOptimalAroundViaBy = 0.1; - // Alternative paths similarity requirement (sharing) based on calles. - // At least 15% different than the shortest path. + // Alternative paths similarity requirement (sharing) based on cells. + // At least 5% different than the shortest path. double kCellsAtMostSameBy = 0.95; }; diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index 737006006..9371aeb9c 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -206,12 +206,7 @@ void GraphCompressor::Compress( graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation( rev_edge_data2.annotation_data, rev_edge_data1.annotation_data); - /* - // 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. - */ + // Add node penalty when compress edge crosses a traffic signal const bool has_node_penalty = traffic_signals.find(node_v) != traffic_signals.end(); EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION; EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT; diff --git a/src/extractor/raster_source.cpp b/src/extractor/raster_source.cpp index 012f347a8..10b517ef7 100644 --- a/src/extractor/raster_source.cpp +++ b/src/extractor/raster_source.cpp @@ -92,15 +92,15 @@ int RasterContainer::LoadRasterSource(const std::string &path_string, const auto _ymin = static_cast(util::toFixed(util::FloatLatitude{ymin})); const auto _ymax = static_cast(util::toFixed(util::FloatLatitude{ymax})); - const auto itr = LoadedSourcePaths.find(path_string); - if (itr != LoadedSourcePaths.end()) + const auto itr = RasterCache::getInstance().getLoadedSourcePaths().find(path_string); + if (itr != RasterCache::getInstance().getLoadedSourcePaths().end()) { util::Log() << "[source loader] Already loaded source '" << path_string << "' at source_id " << itr->second; return itr->second; } - int source_id = static_cast(LoadedSources.size()); + int source_id = static_cast(RasterCache::getInstance().getLoadedSources().size()); util::Log() << "[source loader] Loading from " << path_string << " ... "; 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}; TIMER_STOP(loading_source); - LoadedSourcePaths.emplace(path_string, source_id); - LoadedSources.push_back(std::move(source)); + RasterCache::getInstance().getLoadedSourcePaths().emplace(path_string, source_id); + RasterCache::getInstance().getLoadedSources().push_back(std::move(source)); 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 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) + - ", but there are only " + std::to_string(LoadedSources.size()) + + ", but there are only " + + std::to_string(RasterCache::getInstance().getLoadedSources().size()) + " loaded" + SOURCE_REF); } @@ -139,7 +140,7 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou 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(util::toFixed(util::FloatLongitude{lon})), static_cast(util::toFixed(util::FloatLatitude{lat}))); } @@ -148,10 +149,11 @@ RasterDatum RasterContainer::GetRasterDataFromSource(unsigned int source_id, dou RasterDatum 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) + - ", but there are only " + std::to_string(LoadedSources.size()) + + ", but there are only " + + std::to_string(RasterCache::getInstance().getLoadedSources().size()) + " loaded" + SOURCE_REF); } @@ -160,10 +162,12 @@ RasterContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l 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( static_cast(util::toFixed(util::FloatLongitude{lon})), static_cast(util::toFixed(util::FloatLatitude{lat}))); } + +RasterCache *RasterCache::g_instance = NULL; } } diff --git a/src/server/request_parser.cpp b/src/server/request_parser.cpp index 283425693..e39c0e40b 100644 --- a/src/server/request_parser.cpp +++ b/src/server/request_parser.cpp @@ -217,7 +217,7 @@ RequestParser::RequestStatus RequestParser::consume(http::request ¤t_reque case internal_state::header_name: if (input == ':') { - state = internal_state::space_before_header_value; + state = internal_state::header_value; return RequestStatus::indeterminate; } if (!is_char(input) || is_CTL(input) || is_special(input)) @@ -226,14 +226,12 @@ RequestParser::RequestStatus RequestParser::consume(http::request ¤t_reque } current_header.name.push_back(input); return RequestStatus::indeterminate; - case internal_state::space_before_header_value: + case internal_state::header_value: if (input == ' ') { state = internal_state::header_value; return RequestStatus::indeterminate; } - return RequestStatus::invalid; - case internal_state::header_value: if (input == '\r') { state = internal_state::expecting_newline_2; diff --git a/src/tools/contract.cpp b/src/tools/contract.cpp index 258e202f8..244840beb 100644 --- a/src/tools/contract.cpp +++ b/src/tools/contract.cpp @@ -189,21 +189,18 @@ int main(int argc, char *argv[]) try osrm::contract(contractor_config); - util::DumpSTXXLStats(); util::DumpMemoryStats(); return EXIT_SUCCESS; } catch (const osrm::RuntimeError &e) { - util::DumpSTXXLStats(); util::DumpMemoryStats(); util::Log(logERROR) << e.what(); return e.GetCode(); } catch (const std::bad_alloc &e) { - util::DumpSTXXLStats(); util::DumpMemoryStats(); util::Log(logERROR) << e.what(); util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile"; diff --git a/src/tools/extract.cpp b/src/tools/extract.cpp index f44744bfe..6daf2495e 100644 --- a/src/tools/extract.cpp +++ b/src/tools/extract.cpp @@ -186,28 +186,24 @@ int main(int argc, char *argv[]) try osrm::extract(extractor_config); - util::DumpSTXXLStats(); util::DumpMemoryStats(); return EXIT_SUCCESS; } catch (const osrm::RuntimeError &e) { - util::DumpSTXXLStats(); util::DumpMemoryStats(); util::Log(logERROR) << e.what(); return e.GetCode(); } catch (const std::system_error &e) { - util::DumpSTXXLStats(); util::DumpMemoryStats(); util::Log(logERROR) << e.what(); return e.code().value(); } catch (const std::bad_alloc &e) { - util::DumpSTXXLStats(); util::DumpMemoryStats(); util::Log(logERROR) << "[exception] " << e.what(); util::Log(logERROR) << "Please provide more memory or consider using a larger swapfile"; diff --git a/src/util/log.cpp b/src/util/log.cpp index 602012bd9..0d9a06813 100644 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -16,7 +16,7 @@ namespace static const char COL_RESET[]{"\x1b[0m"}; static const char RED[]{"\x1b[31m"}; static const char YELLOW[]{"\x1b[33m"}; -#ifndef NDEBUG +#ifdef ENABLE_DEBUG_LOGGING static const char MAGENTA[]{"\x1b[35m"}; #endif // 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] "; break; case logDEBUG: -#ifndef NDEBUG +#ifdef ENABLE_DEBUG_LOGGING stream << (is_terminal ? MAGENTA : "") << "[debug] "; #endif break; @@ -126,7 +126,7 @@ Log::~Log() std::cerr << std::endl; break; case logDEBUG: -#ifdef NDEBUG +#ifndef ENABLE_DEBUG_LOGGING break; #endif case logINFO: diff --git a/test/.stxxl b/test/.stxxl deleted file mode 100644 index 61cbf0377..000000000 --- a/test/.stxxl +++ /dev/null @@ -1 +0,0 @@ -disk=###.stxxl,20,memory diff --git a/test/data/.stxxl b/test/data/.stxxl deleted file mode 100644 index 4b2217b2c..000000000 --- a/test/data/.stxxl +++ /dev/null @@ -1 +0,0 @@ -disk=/tmp/stxxl_###,200M,syscall autogrow diff --git a/test/data/Makefile b/test/data/Makefile index 3c6adc7d2..89b241c12 100755 --- a/test/data/Makefile +++ b/test/data/Makefile @@ -1,6 +1,4 @@ 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 PROFILE_ROOT:=../../profiles SCRIPT_ROOT:=../../scripts @@ -22,12 +20,6 @@ clean: -rm -r $(DATA_NAME).* -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 mkdir -p ch cp $(DATA_NAME).osrm $(DATA_NAME).osrm.* ch/ diff --git a/test/data/monaco.osm.pbf b/test/data/monaco.osm.pbf new file mode 100644 index 000000000..63346b4ce Binary files /dev/null and b/test/data/monaco.osm.pbf differ diff --git a/test/data/monaco.poly b/test/data/monaco.poly new file mode 100644 index 000000000..467cc4d82 --- /dev/null +++ b/test/data/monaco.poly @@ -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 diff --git a/third_party/sol2/sol2/sol.hpp b/third_party/sol2/sol2/sol.hpp index a349ea9d1..d48b67431 100644 --- a/third_party/sol2/sol2/sol.hpp +++ b/third_party/sol2/sol2/sol.hpp @@ -3399,7 +3399,9 @@ namespace sol { runtime = LUA_ERRRUN, memory = LUA_ERRMEM, handler = LUA_ERRERR, +#if SOL_LUA_VERSION < 504 gc = LUA_ERRGCMM, +#endif syntax = LUA_ERRSYNTAX, file = LUA_ERRFILE, }; @@ -3409,7 +3411,9 @@ namespace sol { yielded = LUA_YIELD, runtime = LUA_ERRRUN, memory = LUA_ERRMEM, +#if SOL_LUA_VERSION < 504 gc = LUA_ERRGCMM, +#endif handler = LUA_ERRERR, dead = -1, }; @@ -3418,7 +3422,9 @@ namespace sol { ok = LUA_OK, syntax = LUA_ERRSYNTAX, memory = LUA_ERRMEM, +#if SOL_LUA_VERSION < 504 gc = LUA_ERRGCMM, +#endif file = LUA_ERRFILE, }; @@ -3462,8 +3468,10 @@ namespace sol { return names[3]; case call_status::handler: return names[4]; +#if SOL_LUA_VERSION < 504 case call_status::gc: return names[5]; +#endif case call_status::syntax: return names[6]; case call_status::file: @@ -3485,8 +3493,10 @@ namespace sol { return names[0]; case load_status::memory: return names[1]; +#if SOL_LUA_VERSION < 504 case load_status::gc: return names[2]; +#endif case load_status::syntax: return names[3]; case load_status::file: @@ -14374,9 +14384,12 @@ namespace sol { void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) { #if SOL_LUA_VERSION < 502 stats = static_cast(lua_resume(lua_state(), static_cast(argcount))); -#else +#elif SOL_LUA_VERSION < 504 stats = static_cast(lua_resume(lua_state(), nullptr, static_cast(argcount))); -#endif // Lua 5.1 compat +#else + int nstack = 0; + stats = static_cast(lua_resume(lua_state(), nullptr, static_cast(argcount), &nstack)); +#endif } template