Merge branch 'master' into sf-osrm-file

This commit is contained in:
Siarhei Fedartsou 2022-09-27 19:33:52 +02:00
commit 500ea837f1
50 changed files with 2134 additions and 1409 deletions

View File

@ -12,6 +12,7 @@ Checks: >
-bugprone-unhandled-self-assignment,
-bugprone-forward-declaration-namespace,
-bugprone-sizeof-expression,
-bugprone-throw-keyword-missing,
-clang-analyzer-*,
-clang-diagnostic-deprecated-declarations,
-clang-diagnostic-constant-conversion,
@ -64,6 +65,7 @@ Checks: >
-readability-else-after-return,
-readability-inconsistent-declaration-parameter-name,
-readability-isolate-declaration,
-readability-identifier-length,
-readability-redundant-declaration,
-readability-uppercase-literal-suffix,
-readability-named-parameter,

3
.gitattributes vendored
View File

@ -13,3 +13,6 @@
# Declare files that will always have LF line endings on checkout.
*.sh text eol=lf
# https://eslint.org/docs/latest/rules/linebreak-style#using-this-rule-with-version-control-systems
*.js text eol=lf

View File

@ -24,6 +24,9 @@ jobs:
needs: format-taginfo-docs
runs-on: windows-2022
continue-on-error: false
env:
BUILD_TYPE: Release
ENABLE_APPLE_SILICON: "OFF"
steps:
- uses: actions/checkout@v3
- run: pip install conan==1.51.3
@ -34,12 +37,38 @@ jobs:
node-version: 16
- run: node --version
- run: npm --version
- name: Prepare environment
shell: bash
run: |
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
- run: npm install --ignore-scripts
- run: npm link --ignore-scripts
- uses: microsoft/setup-msbuild@v1.1
- name: Build
run: |
.\scripts\ci\windows-build.bat
- name: Run node tests
shell: bash
run: |
./lib/binding/osrm-datastore.exe test/data/ch/monaco.osrm
node test/nodejs/index.js
- name: Build Node package
shell: bash
run: ./scripts/ci/node_package.sh
- name: Publish Node package
if: ${{ env.PUBLISH == 'On' }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: build/stage/**/*.tar.gz
omitBody: true
omitBodyDuringUpdate: true
omitName: true
omitNameDuringUpdate: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
format-taginfo-docs:
runs-on: ubuntu-20.04
@ -161,11 +190,11 @@ jobs:
- name: clang-11.0-debug-clang-tidy
continue-on-error: false
node: 12
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
BUILD_TOOLS: ON
BUILD_TYPE: Debug
CCOMPILER: clang-11
CXXCOMPILER: clang++-11
CCOMPILER: clang-14
CXXCOMPILER: clang++-14
CUCUMBER_TIMEOUT: 60000
ENABLE_CLANG_TIDY: ON
@ -250,7 +279,7 @@ jobs:
CCOMPILER: gcc-7
CXXCOMPILER: g++-7
- name: conan-osx-release-node-12
- name: conan-macos-x64-release-node-12
build_node_package: true
continue-on-error: false
node: 12
@ -263,7 +292,7 @@ jobs:
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
- name: conan-osx-release-node-14
- name: conan-macos-x64-release-node-14
build_node_package: true
continue-on-error: false
node: 14
@ -276,7 +305,7 @@ jobs:
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
- name: conan-osx-release-node-16
- name: conan-macos-x64-release-node-16
build_node_package: true
continue-on-error: false
node: 16
@ -289,6 +318,20 @@ jobs:
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
- name: conan-macos-arm64-release-node-16
build_node_package: true
continue-on-error: false
node: 16
runs-on: macos-11
BUILD_TOOLS: ON
BUILD_TYPE: Release
CCOMPILER: clang
CXXCOMPILER: clang++
CUCUMBER_TIMEOUT: 60000
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
ENABLE_APPLE_SILICON: ON
- name: gcc-7-release-shared
continue-on-error: false
node: 12
@ -372,7 +415,7 @@ jobs:
ENABLE_CONAN: ON
NODE_PACKAGE_TESTS_ONLY: ON
- name: conan-osx-release-node-latest
- name: conan-macos-x64-release-node-latest
build_node_package: true
continue-on-error: true
node: latest
@ -384,6 +427,19 @@ jobs:
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
- name: conan-macos-arm64-release-node-latest
build_node_package: true
continue-on-error: true
node: latest
runs-on: macos-11
BUILD_TYPE: Release
CCOMPILER: clang
CXXCOMPILER: clang++
CUCUMBER_TIMEOUT: 60000
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
ENABLE_APPLE_SILICON: ON
- name: node-latest-conan-linux-release
build_node_package: true
continue-on-error: true
@ -408,7 +464,7 @@ jobs:
ENABLE_CONAN: ON
NODE_PACKAGE_TESTS_ONLY: ON
- name: conan-osx-release-node-lts
- name: conan-macos-x64-release-node-lts
build_node_package: true
continue-on-error: true
node: "lts/*"
@ -420,6 +476,19 @@ jobs:
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
- name: conan-macos-arm64-release-node-lts
build_node_package: true
continue-on-error: true
node: "lts/*"
runs-on: macos-11
BUILD_TYPE: Release
CCOMPILER: clang
CXXCOMPILER: clang++
CUCUMBER_TIMEOUT: 60000
ENABLE_ASSERTIONS: ON
ENABLE_CONAN: ON
ENABLE_APPLE_SILICON: ON
- name: node-lts-conan-linux-release
build_node_package: true
continue-on-error: true
@ -463,6 +532,7 @@ jobs:
ENABLE_CONAN: ${{ matrix.ENABLE_CONAN }}
ENABLE_SANITIZER: ${{ matrix.ENABLE_SANITIZER }}
NODE_PACKAGE_TESTS_ONLY: ${{ matrix.NODE_PACKAGE_TESTS_ONLY }}
ENABLE_APPLE_SILICON: ${{ matrix.ENABLE_APPLE_SILICON }}
TARGET_ARCH: ${{ matrix.TARGET_ARCH }}
OSRM_CONNECTION_RETRIES: ${{ matrix.OSRM_CONNECTION_RETRIES }}
OSRM_CONNECTION_EXP_BACKOFF_COEF: ${{ matrix.OSRM_CONNECTION_EXP_BACKOFF_COEF }}
@ -491,9 +561,9 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.conan
key: v3-conan-${{ matrix.name }}-${{ github.sha }}
key: v6-conan-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
v3-conan-${{ matrix.name }}-
v6-conan-${{ matrix.name }}-
- name: Enable test cache
uses: actions/cache@v2
with:
@ -506,10 +576,8 @@ jobs:
run: |
PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
echo PUBLISH=$([[ "${GITHUB_REF:-}" == "refs/tags/v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off") >> $GITHUB_ENV
echo "OSRM_INSTALL_DIR=${GITHUB_WORKSPACE}/install-osrm" >> $GITHUB_ENV
echo "OSRM_BUILD_DIR=${GITHUB_WORKSPACE}/build-osrm" >> $GITHUB_ENV
if [[ "$ENABLE_SANITIZER" == 'ON' ]]; then
# We can only set this after checkout once we know the workspace directory
echo "LSAN_OPTIONS=print_suppressions=0:suppressions=${GITHUB_WORKSPACE}/scripts/ci/leaksanitizer.conf" >> $GITHUB_ENV
@ -524,15 +592,13 @@ jobs:
sudo mdutil -i off /
export MASON_OS=osx
fi
echo "MASON=${GITHUB_WORKSPACE}/scripts/mason.sh" >> $GITHUB_ENV
echo "CMAKE_URL=https://mason-binaries.s3.amazonaws.com/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}.tar.gz" >> $GITHUB_ENV
echo "CMAKE_DIR=mason_packages/${MASON_OS}-x86_64/cmake/${CMAKE_VERSION}" >> $GITHUB_ENV
- name: Install dev dependencies
run: |
python3 -m pip install conan==1.50.0
python3 -m pip install conan==1.51.3
# CMake
mkdir -p ${CMAKE_DIR}
@ -557,7 +623,6 @@ jobs:
# Linux dev packages
if [ "${TARGET_ARCH}" != "i686" ] && [ "${ENABLE_CONAN}" != "ON" ]; then
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -y
sudo apt-get install -y libbz2-dev libxml2-dev libzip-dev liblua5.2-dev libboost-all-dev
if [[ "${CCOMPILER}" != clang-* ]]; then
@ -599,6 +664,17 @@ jobs:
echo "Using ${JOBS} jobs"
pushd ${OSRM_BUILD_DIR}
# handle Apple Silicon cross compilation
if [[ "${ENABLE_APPLE_SILICON}" == "ON" ]]; then
ARCH=arm64
TARGET="${ARCH}-apple-darwin"
CFLAGS="$CFLAGS --target=$TARGET"
CXXFLAGS="$CXXFLAGS --target=$TARGET"
APPLE_SILICON_FLAGS=(-DCMAKE_C_COMPILER_TARGET="$TARGET" -DCMAKE_CXX_COMPILER_TARGET="$TARGET" -DCMAKE_SYSTEM_PROCESSOR="${ARCH}" -DCMAKE_SYSTEM_NAME="Darwin" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS")
else
APPLE_SILICON_FLAGS=()
fi
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DENABLE_CONAN=${ENABLE_CONAN:-OFF} \
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \
@ -610,10 +686,11 @@ jobs:
-DBUILD_TOOLS=${BUILD_TOOLS:-OFF} \
-DENABLE_CCACHE=ON \
-DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
-DENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-OFF}
-DENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-OFF} \
"${APPLE_SILICON_FLAGS[@]}"
make --jobs=${JOBS}
if [[ "${NODE_PACKAGE_TESTS_ONLY}" != "ON" ]]; then
if [[ "${NODE_PACKAGE_TESTS_ONLY}" != "ON" && "${ENABLE_APPLE_SILICON}" != "ON" ]]; then
make tests --jobs=${JOBS}
make benchmarks --jobs=${JOBS}
ccache -s
@ -625,7 +702,7 @@ jobs:
fi
popd
- name: Build example
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' }}
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' && matrix.ENABLE_APPLE_SILICON != 'ON' }}
run: |
mkdir example/build && pushd example/build
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
@ -633,7 +710,7 @@ jobs:
popd
- name: Run all tests
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' }}
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY != 'ON' && matrix.ENABLE_APPLE_SILICON != 'ON' }}
run: |
make -C test/data benchmark
@ -650,7 +727,7 @@ jobs:
popd
npm test
- name: Run Node package tests only
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' }}
if: ${{ matrix.NODE_PACKAGE_TESTS_ONLY == 'ON' && matrix.ENABLE_APPLE_SILICON != 'ON' }}
run: |
npm run nodejs-tests
- name: Upload test logs
@ -675,9 +752,17 @@ jobs:
name: codecov-osrm-backend
fail_ci_if_error: true
verbose: true
- name: Check Apple Silicon binary
if: ${{ matrix.ENABLE_APPLE_SILICON == 'ON' }}
run: |
ARCH=$(file ./lib/binding/node_osrm.node | awk '{printf $NF}')
if [[ "$ARCH" != "arm64" ]]; then
file ./lib/binding/node_osrm.node
>&2 echo "Wrong architecture!"
exit 1
fi
- name: Build Node package
if: ${{ matrix.build_node_package && env.PUBLISH == 'On' }}
if: ${{ matrix.build_node_package }}
run: ./scripts/ci/node_package.sh
- name: Publish Node package
if: ${{ matrix.build_node_package && env.PUBLISH == 'On' }}

View File

@ -9,6 +9,7 @@
- NodeJS:
- FIXED: Support `skip_waypoints` in Node bindings [#6060](https://github.com/Project-OSRM/osrm-backend/pull/6060)
- Misc:
- CHANGED: Optimize RestrictionParser performance. [#6344](https://github.com/Project-OSRM/osrm-backend/pull/6344)
- ADDED: Support floats for speed value in traffic updates CSV. [#6327](https://github.com/Project-OSRM/osrm-backend/pull/6327)
- CHANGED: Use Lua 5.4 in Docker image. [#6346](https://github.com/Project-OSRM/osrm-backend/pull/6346)
- CHANGED: Remove redundant nullptr check. [#6326](https://github.com/Project-OSRM/osrm-backend/pull/6326)
@ -21,6 +22,8 @@
- FIXED: Bug in bicycle profile that caused exceptions if there is a highway=bicycle in the data. [#6296](https://github.com/Project-OSRM/osrm-backend/pull/6296)
- FIXED: Internal refactoring of identifier types used in data facade [#6044](https://github.com/Project-OSRM/osrm-backend/pull/6044)
- Build:
- ADDED: Build Node bindings on Windows. [#6334](https://github.com/Project-OSRM/osrm-backend/pull/6334)
- ADDED: Configure cross-compilation for Apple Silicon. [#6360](https://github.com/Project-OSRM/osrm-backend/pull/6360)
- CHANGED: Use apt-get to install Clang on CI. [#6345](https://github.com/Project-OSRM/osrm-backend/pull/6345)
- CHANGED: Fix TBB in case of Conan + NodeJS build. [#6333](https://github.com/Project-OSRM/osrm-backend/pull/6333)
- CHANGED: Migrate to modern TBB version. [#6300](https://github.com/Project-OSRM/osrm-backend/pull/6300)
@ -56,6 +59,9 @@
- ADDED: Support snapping to multiple ways at an input location. [#5953](https://github.com/Project-OSRM/osrm-backend/pull/5953)
- FIXED: Fix snapping target locations to ways used in turn restrictions. [#6339](https://github.com/Project-OSRM/osrm-backend/pull/6339)
- ADDED: Support OSM traffic signal directions. [#6153](https://github.com/Project-OSRM/osrm-backend/pull/6153)
- FIXED: Ensure u-turn exists in intersection view. [#6376](https://github.com/Project-OSRM/osrm-backend/pull/6376)
- Profile:
- CHANGED: Bicycle surface speeds [#6212](https://github.com/Project-OSRM/osrm-backend/pull/6212)
- Tools:
- CHANGED: Do not generate intermediate .osrm file in osrm-extract. [#6354](https://github.com/Project-OSRM/osrm-backend/pull/6354)

View File

@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.2)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed.
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
@ -61,6 +62,15 @@ if (POLICY CMP0074)
endif()
project(OSRM C CXX)
# add @loader_path/$ORIGIN to rpath to make binaries relocatable
if (APPLE)
set(CMAKE_BUILD_RPATH "@loader_path")
else()
set(CMAKE_BUILD_RPATH "\$ORIGIN")
# https://stackoverflow.com/questions/6324131/rpath-origin-not-having-desired-effect
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin")
endif()
include(JSONParser)
file(READ "package.json" packagejsonraw)
sbeParseJson(packagejson packagejsonraw)
@ -185,7 +195,7 @@ if(ENABLE_GOLD_LINKER)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(OSRM_LDFLAGS "${OSRM_LDFLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
message(STATUS "Using GNU gold as linker.")
@ -459,11 +469,11 @@ if(ENABLE_CONAN)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/conan.cmake)
set(CONAN_BOOST_VERSION 1.79.0)
set(CONAN_BZIP2_VERSION 1.0.8)
set(CONAN_EXPAT_VERSION 2.2.10)
set(CONAN_LUA_VERSION 5.4.4)
set(CONAN_TBB_VERSION 2021.3.0)
set(CONAN_BOOST_VERSION "1.79.0#96e4902111a2e343a8ba0aa95391bb58")
set(CONAN_BZIP2_VERSION "1.0.8#d1b2d5816f25865acf978501dff1f897")
set(CONAN_EXPAT_VERSION "2.2.10#916908d4a570ad839edd25322c3268cd")
set(CONAN_LUA_VERSION "5.4.4#3ec62efc37cd0a5d80b9e5cb35277360")
set(CONAN_TBB_VERSION "2021.3.0#507ec17cbd51a84167e143b20d170eea")
set(CONAN_SYSTEM_INCLUDES ON)
@ -478,22 +488,26 @@ if(ENABLE_CONAN)
set(CONAN_ARGS
REQUIRES
boost/${CONAN_BOOST_VERSION}
bzip2/${CONAN_BZIP2_VERSION}
expat/${CONAN_EXPAT_VERSION}
lua/${CONAN_LUA_VERSION}
onetbb/${CONAN_TBB_VERSION}
"boost/${CONAN_BOOST_VERSION}"
"bzip2/${CONAN_BZIP2_VERSION}"
"expat/${CONAN_EXPAT_VERSION}"
"lua/${CONAN_LUA_VERSION}"
"onetbb/${CONAN_TBB_VERSION}"
BASIC_SETUP
GENERATORS cmake_find_package
KEEP_RPATHS
NO_OUTPUT_DIRS
OPTIONS boost:filesystem_version=3 # https://stackoverflow.com/questions/73392648/error-with-boost-filesystem-version-in-cmake
onetbb:shared=${TBB_SHARED}
boost:without_stacktrace=True # Apple Silicon cross-compilation fails without it
BUILD missing
)
# explicitly say Conan to use x86 dependencies if build for x86 platforms (https://github.com/conan-io/cmake-conan/issues/141)
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
conan_cmake_run("${CONAN_ARGS};ARCH;x86")
# cross-compilation for Apple Silicon
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
conan_cmake_run("${CONAN_ARGS};ARCH;armv8")
else()
conan_cmake_run("${CONAN_ARGS}")
endif()
@ -505,7 +519,7 @@ if(ENABLE_CONAN)
add_dependency_includes(${CONAN_INCLUDE_DIRS_TBB})
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED EXACT ${CONAN_BOOST_VERSION} COMPONENTS ${BOOST_COMPONENTS})
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(Boost_DATE_TIME_LIBRARY "${Boost_date_time_LIB_TARGETS}")
set(Boost_CHRONO_LIBRARY "${Boost_chrono_LIB_TARGETS}")
set(Boost_PROGRAM_OPTIONS_LIBRARY "${Boost_program_options_LIB_TARGETS}")
@ -870,15 +884,16 @@ if (ENABLE_FUZZING)
add_subdirectory(fuzz)
endif ()
# add headers sanity check target that includes all headers independently
# make sure we have all deps for the nodejs sub project's includes (nan, node)
if (ENABLE_NODE_BINDINGS)
set(check_headers_dir "${PROJECT_BINARY_DIR}/check-headers")
file(GLOB_RECURSE headers_to_check
${PROJECT_BINARY_DIR}/*.hpp
${PROJECT_SOURCE_DIR}/include/*.hpp)
foreach(header ${headers_to_check})
if ("${header}" MATCHES ".*/include/nodejs/.*")
# we do not check NodeJS bindings headers
continue()
endif()
get_filename_component(filename ${header} NAME_WE)
set(filename "${check_headers_dir}/${filename}.cpp")
if (NOT EXISTS ${filename})
@ -888,4 +903,4 @@ if (ENABLE_NODE_BINDINGS)
endforeach()
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
endif()

View File

@ -9,28 +9,34 @@ Feature: Bike - Surfaces
| highway | surface | bothw |
| cycleway | | 48 s |
| cycleway | asphalt | 47.9 s |
| cycleway | chipseal | 48 s |
| cycleway | concrete | 48 s |
| cycleway | concrete_lanes | 48 s |
| cycleway | cobblestone:flattened | 72 s |
| cycleway | paving_stones | 72 s |
| cycleway | wood | 72 s |
| cycleway | compacted | 72 s |
| cycleway | cobblestone | 120 s |
| cycleway | fine_gravel | 120 s |
| cycleway | fine_gravel | 72 s |
| cycleway | ground | 72 s |
| cycleway | dirt | 90 s |
| cycleway | cobblestone | 102.9 s |
| cycleway | gravel | 120 s |
| cycleway | pebblestone | 120 s |
| cycleway | dirt | 120 s |
| cycleway | dirt | 90 s |
| cycleway | earth | 120 s |
| cycleway | grass | 120 s |
| cycleway | mud | 240 s |
| cycleway | sand | 240 s |
| cycleway | sett | 72 s |
| cycleway | sett | 80 s |
Scenario: Bicycle - Good surfaces on small paths
Then routability should be
| highway | surface | bothw |
| cycleway | | 48 s |
| path | | 59.9 s |
| path | | 55.3 s |
| track | | 60 s |
| track | asphalt | 60 s |
| path | asphalt | 60 s |
| path | asphalt | 55.4 s |
Scenario: Bicycle - Surfaces should not make unknown ways routable
Then routability should be

View File

@ -0,0 +1,31 @@
@routing @foot
Feature: Foot - Intersections
Background:
Given the profile "foot"
Given a grid size of 2 meters
# https://github.com/Project-OSRM/osrm-backend/issues/6218
Scenario: Foot - Handles non-planar intersections
Given the node map
"""
f
|
a
|
b---c---d
|
e
"""
And the ways
| nodes | highway | foot | layer |
| ac | footway | yes | 0 |
| bc | footway | yes | 0 |
| cd | footway | yes | 0 |
| cef | footway | yes | 1 |
When I route I should get
| from | to | route |
| a | d | ac,cd,cd |

View File

@ -28,6 +28,7 @@
#include "util/json_util.hpp"
#include <iterator>
#include <map>
#include <vector>
namespace osrm

View File

@ -32,6 +32,8 @@ namespace api
class TableAPI final : public BaseAPI
{
public:
virtual ~TableAPI() = default;
struct TableCellRef
{
TableCellRef(const std::size_t &row, const std::size_t &column) : row{row}, column{column}

View File

@ -31,6 +31,8 @@ template <> class AlgorithmDataFacade<CH>
using EdgeData = contractor::QueryEdge::EdgeData;
using EdgeRange = util::filtered_range<EdgeID, util::vector_view<bool>>;
virtual ~AlgorithmDataFacade() = default;
// search graph access
virtual unsigned GetNumberOfNodes() const = 0;
@ -66,6 +68,8 @@ template <> class AlgorithmDataFacade<MLD>
using EdgeData = customizer::EdgeBasedGraphEdgeData;
using EdgeRange = util::range<EdgeID>;
virtual ~AlgorithmDataFacade() = default;
// search graph access
virtual unsigned GetNumberOfNodes() const = 0;

View File

@ -6,6 +6,7 @@
#include "engine/guidance/route_leg.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/internal_route_result.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/typedefs.hpp"
#include <boost/algorithm/string/join.hpp>

View File

@ -54,6 +54,7 @@ struct PhantomNode
forward_distance_offset(0), reverse_distance_offset(0),
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0),
component({INVALID_COMPONENTID, 0}),
fwd_segment_position(0), is_valid_forward_source{false}, is_valid_forward_target{false},
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)

View File

@ -19,6 +19,8 @@ namespace engine
class RoutingAlgorithmsInterface
{
public:
virtual ~RoutingAlgorithmsInterface() = default;
virtual InternalManyRoutesResult
AlternativePathSearch(const PhantomEndpointCandidates &endpoint_candidates,
unsigned number_of_alternatives) const = 0;

View File

@ -1,107 +0,0 @@
#ifndef OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES
#define OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES
#include <algorithm>
#include <vector>
#include "extractor/query_node.hpp"
#include "util/coordinate.hpp"
#include "util/json_container.hpp"
#include "util/node_based_graph.hpp"
#include "util/typedefs.hpp"
#include "guidance/coordinate_extractor.hpp"
#include "guidance/intersection.hpp"
#include "util/coordinate.hpp"
#include "util/geojson_debug_policy_toolkit.hpp"
#include <boost/optional.hpp>
namespace osrm
{
namespace extractor
{
// generate a visualisation of an intersection, printing the coordinates used for angle calculation
template <typename IntersectionType> struct IntersectionPrinter
{
IntersectionPrinter(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<extractor::QueryNode> &node_coordinates,
const extractor::guidance::CoordinateExtractor &coordinate_extractor);
// renders the used coordinate locations for all entries/as well as the resulting
// intersection-classification
util::json::Array operator()(const NodeID intersection_node,
const IntersectionType &intersection,
const boost::optional<util::json::Object> &node_style = {},
const boost::optional<util::json::Object> &way_style = {}) const;
const util::NodeBasedDynamicGraph &node_based_graph;
const std::vector<extractor::QueryNode> &node_coordinates;
const extractor::guidance::CoordinateExtractor &coordinate_extractor;
};
// IMPLEMENTATION
template <typename IntersectionType>
IntersectionPrinter<IntersectionType>::IntersectionPrinter(
const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<extractor::QueryNode> &node_coordinates,
const extractor::guidance::CoordinateExtractor &coordinate_extractor)
: node_based_graph(node_based_graph), node_coordinates(node_coordinates),
coordinate_extractor(coordinate_extractor)
{
}
template <typename IntersectionType>
util::json::Array IntersectionPrinter<IntersectionType>::operator()(
const NodeID intersection_node,
const IntersectionType &intersection,
const boost::optional<util::json::Object> &node_style,
const boost::optional<util::json::Object> &way_style) const
{
// request the number of lanes. This process needs to be in sync with what happens over at
// intersection analysis
const auto intersection_lanes =
intersection.FindMaximum(guidance::makeExtractLanesForRoad(node_based_graph));
std::vector<util::Coordinate> coordinates;
coordinates.reserve(intersection.size());
coordinates.push_back(node_coordinates[intersection_node]);
const auto road_to_coordinate = [&](const auto &road) {
const constexpr auto FORWARD = false;
const auto to_node = node_based_graph.GetTarget(road.eid);
return coordinate_extractor.GetCoordinateAlongRoad(
intersection_node, road.eid, FORWARD, to_node, intersection_lanes);
};
std::transform(intersection.begin(),
intersection.end(),
std::back_inserter(coordinates),
road_to_coordinate);
util::json::Array features;
features.values.push_back(
util::makeFeature("MultiPoint", makeJsonArray(coordinates), node_style));
if (coordinates.size() > 1)
{
std::vector<util::Coordinate> line_coordinates(2);
line_coordinates[0] = coordinates.front();
const auto coordinate_to_line = [&](const util::Coordinate coordinate) {
line_coordinates[1] = coordinate;
return util::makeFeature("LineString", makeJsonArray(line_coordinates), way_style);
};
std::transform(std::next(coordinates.begin()),
coordinates.end(),
std::back_inserter(features.values),
coordinate_to_line);
}
return features;
}
} /* namespace extractor */
} /* namespace osrm */
#endif /* OSRM_EXTRACTOR_GEOJSON_DEBUG_POLICIES */

View File

@ -135,7 +135,8 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
inline NodeBasedEdgeClassification::NodeBasedEdgeClassification()
: forward(false), backward(false), is_split(false), roundabout(false), circular(false),
startpoint(false), restricted(false)
startpoint(false), restricted(false), highway_turn_classification(0),
access_turn_classification(0)
{
}

View File

@ -58,7 +58,7 @@ class RasterGrid
for (unsigned int y = 0; y < ydim; y++)
{
// read one line from file.
file_reader.ReadLine(&buffer[0], xdim * 11);
file_reader.ReadLine(buffer.data(), xdim * 11);
boost::algorithm::trim(buffer);
std::vector<std::string> result;

View File

@ -28,7 +28,7 @@ struct TurnRestriction
// The turn sequence that the restriction applies to.
TurnPath turn_path;
// Indicates if the restriction turn *must* or *must not* be taken.
bool is_only;
bool is_only = false;
// We represent conditional and unconditional restrictions with the same structure.
// Unconditional restrictions will have empty conditions.
std::vector<util::OpeningHours> condition;

View File

@ -5,6 +5,8 @@
#include <boost/optional/optional.hpp>
#include <osmium/tags/filter.hpp>
#include <set>
#include <string>
#include <vector>
@ -43,7 +45,7 @@ class RestrictionParser
public:
RestrictionParser(bool use_turn_restrictions,
bool parse_conditionals,
std::vector<std::string> &restrictions);
const std::vector<std::string> &restrictions);
std::vector<InputTurnRestriction> TryParse(const osmium::Relation &relation) const;
private:
@ -51,7 +53,8 @@ class RestrictionParser
bool use_turn_restrictions;
bool parse_conditionals;
std::vector<std::string> restrictions;
std::set<std::string> restrictions;
osmium::tags::KeyFilter filter;
};
} // namespace extractor
} // namespace osrm

View File

@ -1,14 +1,14 @@
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
#define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
#include "extractor/intersection/constants.hpp"
#include <algorithm>
#include <boost/assert.hpp>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <string>
#include "extractor/intersection/constants.hpp"
namespace osrm
{
namespace extractor

View File

@ -38,17 +38,17 @@ struct LuaScriptingContext final
RasterContainer raster_sources;
sol::state state;
bool has_turn_penalty_function;
bool has_node_function;
bool has_way_function;
bool has_segment_function;
bool has_turn_penalty_function = false;
bool has_node_function = false;
bool has_way_function = false;
bool has_segment_function = false;
sol::function turn_function;
sol::function way_function;
sol::function node_function;
sol::function segment_function;
int api_version;
int api_version = 4;
sol::table profile_table;
// Reference to immutable location dependent data and locations memo

View File

@ -231,7 +231,7 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
protected:
Vector<EdgeOffset> node_to_edge_offset;
std::uint32_t connectivity_checksum;
std::uint32_t connectivity_checksum = 0;
};
using MultiLevelEdgeBasedGraph =

View File

@ -125,13 +125,13 @@ template <typename NodeEntryT, typename EdgeEntryT> class RemappableGraph
NodeID GetID(const NodeT &node) const
{
BOOST_ASSERT(&node >= &nodes[0] && &node <= &nodes.back());
return (&node - &nodes[0]);
BOOST_ASSERT(&node >= nodes.data() && &node <= &nodes.back());
return (&node - nodes.data());
}
EdgeID GetID(const EdgeT &edge) const
{
BOOST_ASSERT(&edge >= &edges[0] && &edge <= &edges.back());
return (&edge - &edges[0]);
BOOST_ASSERT(&edge >= edges.data() && &edge <= &edges.back());
return (&edge - edges.data());
}
NodeIterator Begin() { return nodes.begin(); }
@ -142,7 +142,7 @@ template <typename NodeEntryT, typename EdgeEntryT> class RemappableGraph
// removes the edges from the graph that return true for the filter, returns new end
template <typename FilterT> auto RemoveEdges(NodeT &node, FilterT filter)
{
BOOST_ASSERT(&node >= &nodes[0] && &node <= &nodes.back());
BOOST_ASSERT(&node >= nodes.data() && &node <= &nodes.back());
// required since we are not on std++17 yet, otherwise we are missing an argument_type
const auto negate_filter = [&](const EdgeT &edge) { return !filter(edge); };
const auto center = std::stable_partition(BeginEdges(node), EndEdges(node), negate_filter);

View File

@ -107,11 +107,11 @@ class Server
}
}
RequestHandler request_handler;
unsigned thread_pool_size;
boost::asio::io_context io_context;
boost::asio::ip::tcp::acceptor acceptor;
std::shared_ptr<Connection> new_connection;
RequestHandler request_handler;
};
} // namespace server
} // namespace osrm

View File

@ -211,7 +211,7 @@ struct SharedRegion
char name[MAX_NAME_LENGTH + 1];
std::uint64_t timestamp;
std::uint16_t shm_key;
std::uint16_t shm_key = 0;
};
// Keeps a list of all shared regions in a fixed-sized struct

View File

@ -36,9 +36,6 @@
#include "util/vector_view.hpp"
#include "util/filtered_graph.hpp"
#include "util/packed_vector.hpp"
#include "util/vector_view.hpp"
namespace osrm
{
namespace storage

View File

@ -66,7 +66,7 @@ struct UpdaterConfig final : storage::IOConfig
IOConfig::UseDefaultOutputNames(base);
}
double log_edge_updates_factor;
double log_edge_updates_factor = 0.0;
std::time_t valid_now;
std::vector<std::string> segment_speed_lookup_paths;

View File

@ -25,7 +25,7 @@ template <typename T> class DistTableWrapper
DistTableWrapper(std::vector<T> table, std::size_t number_of_nodes)
: table_(std::move(table)), number_of_nodes_(number_of_nodes)
{
BOOST_ASSERT_MSG(table.size() == 0, "table is empty");
BOOST_ASSERT_MSG(!table_.empty(), "table is empty");
BOOST_ASSERT_MSG(number_of_nodes_ * number_of_nodes_ <= table_.size(),
"number_of_nodes_ is invalid");
}

View File

@ -126,8 +126,8 @@ class FilteredGraphImpl<util::StaticGraph<EdgeDataT, Ownership>, Ownership>
FilteredGraphImpl() = default;
FilteredGraphImpl(Graph graph, Vector<bool> edge_filter_)
: graph(std::move(graph)), edge_filter(std::move(edge_filter_))
FilteredGraphImpl(Graph graph_, Vector<bool> edge_filter_)
: graph(std::move(graph_)), edge_filter(std::move(edge_filter_))
{
BOOST_ASSERT(edge_filter.empty() || edge_filter.size() == graph.GetNumberOfEdges());
}

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include <assert.h>
#include <math.h>
#include <memory.h>
#if defined(_MSC_VER)
#include "rapidjson/msinttypes/stdint.h"

2733
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,10 +4,10 @@
"private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.1",
"@mapbox/node-pre-gyp": "^1.0.9",
"cheap-ruler": "^3.0.2",
"mkdirp": "^0.5.5",
"nan": "^2.14.2",
"mkdirp": "^0.5.6",
"nan": "^2.16.0",
"node-cmake": "^2.5.1",
"rimraf": "^2.7.1"
},
@ -39,18 +39,18 @@
"node": ">=4.0.0"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"acorn": "^8.4.0",
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"acorn": "^8.8.0",
"ansi-escape-sequences": "^5.1.2",
"aws-sdk": "~2.0.31",
"babel-plugin-transform-class-properties": "^6.24.1",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"chalk": "^1.1.3",
"command-line-args": "^5.1.1",
"command-line-args": "^5.2.1",
"command-line-usage": "^5.0.4",
"csv-stringify": "^3.0.0",
"cucumber": "^1.2.1",
@ -59,13 +59,13 @@
"documentation": "^4.0.0",
"eslint": "^5.16.0",
"faucet": "^0.0.1",
"jsonpath": "^1.1.0",
"jsonpath": "^1.1.1",
"node-timeout": "0.0.4",
"polyline": "^0.2.0",
"request": "^2.88.2",
"tape": "^4.13.3",
"tape": "^4.16.0",
"turf": "^3.0.14",
"uglify-js": "^3.13.9",
"uglify-js": "^3.17.0",
"xmlbuilder": "^4.2.1"
},
"bundleDependencies": [

View File

@ -133,7 +133,7 @@ function setup()
road = default_speed,
service = default_speed,
track = 12,
path = 12
path = 13
},
pedestrian_speeds = {
@ -174,21 +174,25 @@ function setup()
surface_speeds = {
asphalt = default_speed,
chipseal = default_speed,
concrete = default_speed,
concrete_lanes = default_speed,
wood = 10,
["cobblestone:flattened"] = 10,
paving_stones = 10,
compacted = 10,
cobblestone = 6,
cobblestone = 7,
unpaved = 6,
fine_gravel = 6,
fine_gravel = 10,
gravel = 6,
pebblestone = 6,
ground = 6,
dirt = 6,
ground = 10,
dirt = 8,
earth = 6,
grass = 6,
mud = 3,
sand = 3,
sett = 10
sett = 9
},
classes = Sequence {

View File

@ -7,13 +7,16 @@ echo "node version is:"
which node
node -v
if [[ ${PUBLISH} == 'On' ]]; then
echo "PUBLISH is set to '${PUBLISH}', publishing!"
NPM_FLAGS=''
if [[ ${BUILD_TYPE} == "Debug" ]]; then
NPM_FLAGS='--debug'
fi
# append --target_arch in order to handle cross-compilation for Apple Silicon
if [[ "$ENABLE_APPLE_SILICON" == "ON" ]]; then
NPM_FLAGS="${NPM_FLAGS} --target_arch=arm64"
fi
echo "dumping binary meta..."
./node_modules/.bin/node-pre-gyp reveal $NPM_FLAGS
@ -32,6 +35,3 @@ if [[ ${PUBLISH} == 'On' ]]; then
fi
./node_modules/.bin/node-pre-gyp package testpackage $NPM_FLAGS
else
echo "PUBLISH is set to '${PUBLISH}', skipping."
fi

View File

@ -11,7 +11,7 @@ mkdir build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cmake -DENABLE_CONAN=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DBUILD_TOOLS=ON -G "Visual Studio 17 2022" ..
cmake -DENABLE_CONAN=ON -DENABLE_NODE_BINDINGS=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "Visual Studio 17 2022" ..
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
msbuild OSRM.sln ^
@ -25,10 +25,6 @@ msbuild OSRM.sln ^
/nologo
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
dir C:\Users\runneradmin\.conan\
dir C:\Users\runneradmin\.conan\data\tbb\2020.3\_\_\package\e9a552ebe8f994398de9ceee972f0ad207df0658\lib\
SET PATH=C:\Users\runneradmin\.conan\data\tbb\2020.3\_\_\package\e9a552ebe8f994398de9ceee972f0ad207df0658\lib\;%PATH%
CD %PROJECT_DIR%\build
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

View File

@ -39,7 +39,7 @@ MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config)
// prior to C++17 (which we're not using), those return a `const char *`,
// which isn't compatible with the `char *` that AllocatedRegion expects
// for it's memory_ptr
allocated_regions.push_back({&(rtree_filename[0]), std::move(fake_layout)});
allocated_regions.push_back({rtree_filename.data(), std::move(fake_layout)});
}
auto files = storage.GetStaticFiles();

View File

@ -15,8 +15,6 @@
#include <boost/numeric/conversion/cast.hpp>
#include <boost/range/iterator_range.hpp>
#include "engine/guidance/collapsing_utility.hpp"
#include <algorithm>
#include <cmath>
#include <cstddef>

View File

@ -641,10 +641,8 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting
{
storage::tar::FileWriter writer(config.GetPath(".osrm").string(),
storage::tar::FileWriter::GenerateFingerprint);
storage::serialization::write(
writer, "/extractor/nodes", extraction_containers.used_nodes);
storage::serialization::write(
writer, "/extractor/edges", extraction_containers.used_edges);
storage::serialization::write(writer, "/extractor/nodes", extraction_containers.used_nodes);
storage::serialization::write(writer, "/extractor/edges", extraction_containers.used_edges);
}
return ParsedOSMData{std::move(turn_lane_map),

View File

@ -11,8 +11,6 @@
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
using osrm::util::angularDeviation;
namespace osrm
{
namespace extractor

View File

@ -617,12 +617,13 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
std::vector<IntersectionViewDataWithAngle> pre_intersection_view;
IntersectionViewData uturn{{SPECIAL_EDGEID, 0., 0., 0.}, false, 0.};
std::size_t allowed_uturns_number = 0;
for (const auto &outgoing_edge : outgoing_edges)
{
const auto is_uturn = [](const auto angle) {
return std::fabs(angle) < std::numeric_limits<double>::epsilon();
};
for (const auto &outgoing_edge : outgoing_edges)
{
const auto edge_it = findEdge(edge_geometries, outgoing_edge.edge);
const auto is_merged = merged_edges.count(outgoing_edge.edge) != 0;
const auto is_turn_allowed = intersection::isTurnAllowed(graph,
@ -678,6 +679,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
BOOST_ASSERT(uturn.eid != SPECIAL_EDGEID);
if (uturn.entry_allowed || allowed_uturns_number == 0)
{ // Add the true U-turn if it is allowed or no other U-turns found
BOOST_ASSERT(uturn.angle == 0.);
pre_intersection_view.insert(pre_intersection_view.begin(), {uturn, 0});
}
@ -706,6 +708,22 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
}
}
auto no_uturn = std::none_of(pre_intersection_view.begin(),
pre_intersection_view.end(),
[&is_uturn](const IntersectionViewDataWithAngle &road) {
return is_uturn(road.first.angle);
});
// After all of this, if we now don't have a u-turn, let's add one to the intersection.
// This is a hack to fix the triggered assertion ( see:
// https://github.com/Project-OSRM/osrm-backend/issues/6218 ). Ideally we would fix this more
// robustly, but this will require overhauling all of the intersection logic.
if (no_uturn)
{
BOOST_ASSERT(!uturn.entry_allowed && allowed_uturns_number > 0);
BOOST_ASSERT(uturn.angle == 0.);
pre_intersection_view.insert(pre_intersection_view.begin(), {uturn, 0});
}
// Copy intersection view data
IntersectionView intersection_view;
intersection_view.reserve(pre_intersection_view.size());

View File

@ -2,6 +2,7 @@
#include "extractor/profile_properties.hpp"
#include "util/conditional_restrictions.hpp"
#include "util/integer_range.hpp"
#include "util/log.hpp"
#include <boost/algorithm/string/predicate.hpp>
@ -9,7 +10,6 @@
#include <boost/ref.hpp>
#include <osmium/osm.hpp>
#include <osmium/tags/regex_filter.hpp>
#include <algorithm>
@ -20,9 +20,9 @@ namespace extractor
RestrictionParser::RestrictionParser(bool use_turn_restrictions_,
bool parse_conditionals_,
std::vector<std::string> &restrictions_)
const std::vector<std::string> &restrictions_)
: use_turn_restrictions(use_turn_restrictions_), parse_conditionals(parse_conditionals_),
restrictions(restrictions_)
restrictions(restrictions_.begin(), restrictions_.end()), filter(false)
{
if (use_turn_restrictions)
{
@ -40,11 +40,28 @@ RestrictionParser::RestrictionParser(bool use_turn_restrictions_,
util::Log() << "Found no turn restriction tags";
}
}
filter.add(true, "restriction");
if (parse_conditionals)
{
filter.add(true, "restriction:conditional");
for (const auto &namespaced : restrictions_)
{
filter.add(true, "restriction:" + namespaced + ":conditional");
}
}
// Not only use restriction= but also e.g. restriction:motorcar=
// Include restriction:{mode}:conditional if flagged
for (const auto &namespaced : restrictions_)
{
filter.add(true, "restriction:" + namespaced);
}
}
/**
* Tries to parse a relation as a turn restriction. This can fail for a number of
* reasons. The return type is a boost::optional<T>.
* reasons. The return type is a std::vector<T>.
*
* Some restrictions can also be ignored: See the ```get_restrictions``` function
* in the corresponding profile. We use it for both namespacing restrictions, as in
@ -59,31 +76,13 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
return {};
}
osmium::tags::KeyFilter filter(false);
filter.add(true, "restriction");
if (parse_conditionals)
{
filter.add(true, "restriction:conditional");
for (const auto &namespaced : restrictions)
{
filter.add(true, "restriction:" + namespaced + ":conditional");
}
}
// Not only use restriction= but also e.g. restriction:motorcar=
// Include restriction:{mode}:conditional if flagged
for (const auto &namespaced : restrictions)
{
filter.add(true, "restriction:" + namespaced);
}
const osmium::TagList &tag_list = relation.tags();
osmium::tags::KeyFilter::iterator fi_begin(filter, tag_list.begin(), tag_list.end());
osmium::tags::KeyFilter::iterator fi_end(filter, tag_list.end(), tag_list.end());
// if it's not a restriction, continue;
if (std::distance(fi_begin, fi_end) == 0)
if (fi_begin == fi_end)
{
return {};
}
@ -99,18 +98,20 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
bool is_multi_from = false;
bool is_multi_to = false;
std::vector<util::OpeningHours> condition;
for (; fi_begin != fi_end; ++fi_begin)
{
const std::string key(fi_begin->key());
const std::string value(fi_begin->value());
auto value = fi_begin->value();
// documented OSM restriction tags start either with only_* or no_*;
// check and return on these values, and ignore no_*_on_red or unrecognized values
if (value.find("only_") == 0)
if (boost::algorithm::starts_with(value, "only_"))
{
is_only_restriction = true;
}
else if (value.find("no_") == 0 && !boost::algorithm::ends_with(value, "_on_red"))
else if (boost::algorithm::starts_with(value, "no_") &&
!boost::algorithm::ends_with(value, "_on_red"))
{
is_only_restriction = false;
if (boost::algorithm::starts_with(value, "no_exit"))
@ -126,76 +127,9 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
{
return {};
}
}
constexpr auto INVALID_OSM_ID = std::numeric_limits<std::uint64_t>::max();
std::vector<OSMWayID> from_ways;
auto via_node = INVALID_OSM_ID;
std::vector<OSMWayID> via_ways;
std::vector<OSMWayID> to_ways;
bool is_node_restriction = true;
for (const auto &member : relation.members())
{
const char *role = member.role();
if (strcmp("from", role) != 0 && strcmp("to", role) != 0 && strcmp("via", role) != 0)
{
continue;
}
switch (member.type())
{
case osmium::item_type::node:
{
// Make sure nodes appear only in the role if a via node
if (0 == strcmp("from", role) || 0 == strcmp("to", role))
{
continue;
}
BOOST_ASSERT(0 == strcmp("via", role));
via_node = static_cast<std::uint64_t>(member.ref());
is_node_restriction = true;
// set via node id
break;
}
case osmium::item_type::way:
BOOST_ASSERT(0 == strcmp("from", role) || 0 == strcmp("to", role) ||
0 == strcmp("via", role));
if (0 == strcmp("from", role))
{
from_ways.push_back({static_cast<std::uint64_t>(member.ref())});
}
else if (0 == strcmp("to", role))
{
to_ways.push_back({static_cast<std::uint64_t>(member.ref())});
}
else if (0 == strcmp("via", role))
{
via_ways.push_back({static_cast<std::uint64_t>(member.ref())});
is_node_restriction = false;
}
break;
case osmium::item_type::relation:
// not yet supported, but who knows what the future holds...
break;
default:
// shouldn't ever happen
break;
}
}
std::vector<util::OpeningHours> condition;
// parse conditional tags
if (parse_conditionals)
{
osmium::tags::KeyFilter::iterator fi_begin(filter, tag_list.begin(), tag_list.end());
osmium::tags::KeyFilter::iterator fi_end(filter, tag_list.end(), tag_list.end());
for (; fi_begin != fi_end; ++fi_begin)
{
const std::string key(fi_begin->key());
const std::string value(fi_begin->value());
// Parse condition and add independent value/condition pairs
const auto &parsed = osrm::util::ParseConditionalRestrictions(value);
@ -214,6 +148,66 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
}
}
constexpr auto INVALID_OSM_ID = std::numeric_limits<std::uint64_t>::max();
std::vector<OSMWayID> from_ways;
auto via_node = INVALID_OSM_ID;
std::vector<OSMWayID> via_ways;
std::vector<OSMWayID> to_ways;
bool is_node_restriction = true;
for (const auto &member : relation.members())
{
const char *role = member.role();
const bool is_from_role = strcmp("from", role) == 0;
const bool is_to_role = strcmp("to", role) == 0;
const bool is_via_role = strcmp("via", role) == 0;
if (!is_from_role && !is_to_role && !is_via_role)
{
continue;
}
switch (member.type())
{
case osmium::item_type::node:
{
// Make sure nodes appear only in the role if a via node
if (is_from_role || is_to_role)
{
continue;
}
BOOST_ASSERT(is_via_role);
via_node = static_cast<std::uint64_t>(member.ref());
is_node_restriction = true;
// set via node id
break;
}
case osmium::item_type::way:
BOOST_ASSERT(is_from_role || is_to_role || is_via_role);
if (is_from_role)
{
from_ways.push_back({static_cast<std::uint64_t>(member.ref())});
}
else if (is_to_role)
{
to_ways.push_back({static_cast<std::uint64_t>(member.ref())});
}
else if (is_via_role)
{
via_ways.push_back({static_cast<std::uint64_t>(member.ref())});
is_node_restriction = false;
}
break;
case osmium::item_type::relation:
// not yet supported, but who knows what the future holds...
break;
default:
// shouldn't ever happen
break;
}
}
std::vector<InputTurnRestriction> restriction_containers;
if (!from_ways.empty() && (via_node != INVALID_OSM_ID || !via_ways.empty()) && !to_ways.empty())
{
@ -270,17 +264,25 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st
return false;
}
// Be warned, this is quadratic work here, but we assume that
// only a few exceptions are actually defined.
const std::regex delimiter_re("[;][ ]*");
std::sregex_token_iterator except_tags_begin(
except_tag_string.begin(), except_tag_string.end(), delimiter_re, -1);
std::sregex_token_iterator except_tags_end;
return std::any_of(except_tags_begin, except_tags_end, [&](const std::string &current_string) {
return std::end(restrictions) !=
std::find(std::begin(restrictions), std::end(restrictions), current_string);
});
// split `except_tag_string` by semicolon and check if any of items is in `restrictions`
std::string current_string;
for (auto index : util::irange<size_t>(0, except_tag_string.size()))
{
const auto ch = except_tag_string[index];
if (ch != ';')
{
current_string += ch;
}
else
{
if (restrictions.find(current_string) != restrictions.end())
{
return true;
}
current_string.clear();
}
}
return restrictions.find(current_string) != restrictions.end();
}
} // namespace extractor
} // namespace osrm

View File

@ -7,13 +7,11 @@
#include "util/log.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
#include <algorithm>
#include <cstddef>
using EdgeData = osrm::util::NodeBasedDynamicGraph::EdgeData;
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm

View File

@ -11,7 +11,6 @@
#include <boost/assert.hpp>
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm

View File

@ -15,8 +15,6 @@
#include <boost/assert.hpp>
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace guidance

View File

@ -6,8 +6,6 @@
#include "util/coordinate_calculation.hpp"
#include <set>
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace guidance

View File

@ -12,7 +12,6 @@
#include <boost/assert.hpp>
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace osrm

View File

@ -10,8 +10,6 @@
#include <unordered_set>
#include <utility>
using osrm::guidance::getTurnDirection;
namespace osrm
{
namespace guidance

View File

@ -11,7 +11,6 @@
#include <boost/assert.hpp>
#include <boost/optional.hpp>
using osrm::guidance::getTurnDirection;
using osrm::util::angularDeviation;
namespace

View File

@ -14,7 +14,7 @@ nodejs_init()
message(STATUS "Configuring node_osrm bindings for NodeJs ${NODEJS_VERSION}")
add_nodejs_module(node_osrm node_osrm.cpp)
set_target_properties(node_osrm PROPERTIES CXX_STANDARD 14)
set_target_properties(node_osrm PROPERTIES CXX_STANDARD 17)
# TODO: we disable clang-tidy for this target, because it causes errors in third-party NodeJs related headers
set_target_properties(node_osrm PROPERTIES CXX_CLANG_TIDY "")

View File

@ -29,9 +29,6 @@
#include <boost/filesystem/operations.hpp>
#include <tbb/global_control.h>
#include "util/geojson_debug_logger.hpp"
#include "util/geojson_debug_policies.hpp"
#include "util/json_container.hpp"
#include "util/timing_util.hpp"
namespace osrm

View File

@ -239,7 +239,7 @@ std::vector<char> Connection::compress_buffers(const std::vector<char> &uncompre
boost::iostreams::filtering_ostream gzip_stream;
gzip_stream.push(boost::iostreams::gzip_compressor(compression_parameters));
gzip_stream.push(boost::iostreams::back_inserter(compressed_data));
gzip_stream.write(&uncompressed_data[0], uncompressed_data.size());
gzip_stream.write(uncompressed_data.data(), uncompressed_data.size());
boost::iostreams::close(gzip_stream);
return compressed_data;