Skip to content

Commit 81ec7a1

Browse files
authored
Merge branch 'Project-OSRM:master' into master
2 parents f193b7c + becfd8a commit 81ec7a1

File tree

582 files changed

+1642
-25881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+1642
-25881
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
- ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839)
8181
- Profiles:
8282
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
83+
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
8384
- Routing:
8485
- FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419)
8586
- FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724)

include/engine/datafacade/contiguous_internalmem_datafacade.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
603603
auto found_range = std::equal_range(
604604
m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{});
605605

606+
results.reserve(std::distance(found_range.first, found_range.second));
607+
606608
std::for_each(found_range.first,
607609
found_range.second,
608610
[&](const auto &override)

include/util/bit_range.hpp

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,13 @@
22
#define OSRM_UTIL_BIT_RANGE_HPP
33

44
#include "util/msb.hpp"
5-
5+
#include <bit>
66
#include <boost/iterator/iterator_facade.hpp>
77
#include <boost/range/iterator_range.hpp>
88

99
namespace osrm::util
1010
{
1111

12-
namespace detail
13-
{
14-
template <typename T> std::size_t countOnes(T value)
15-
{
16-
static_assert(std::is_unsigned<T>::value, "Only unsigned types allowed");
17-
std::size_t number_of_ones = 0;
18-
while (value > 0)
19-
{
20-
auto index = msb(value);
21-
value = value & ~(T{1} << index);
22-
number_of_ones++;
23-
}
24-
return number_of_ones;
25-
}
26-
27-
#if (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__))
28-
inline std::size_t countOnes(std::uint8_t value)
29-
{
30-
return __builtin_popcount(std::uint32_t{value});
31-
}
32-
inline std::size_t countOnes(std::uint16_t value)
33-
{
34-
return __builtin_popcount(std::uint32_t{value});
35-
}
36-
inline std::size_t countOnes(unsigned int value) { return __builtin_popcount(value); }
37-
inline std::size_t countOnes(unsigned long value) { return __builtin_popcountl(value); }
38-
inline std::size_t countOnes(unsigned long long value) { return __builtin_popcountll(value); }
39-
#endif
40-
} // namespace detail
41-
4212
// Investigate if we can replace this with
4313
// http://www.boost.org/doc/libs/1_64_0/libs/dynamic_bitset/dynamic_bitset.html
4414
template <typename DataT>
@@ -70,7 +40,7 @@ class BitIterator : public boost::iterator_facade<BitIterator<DataT>,
7040

7141
difference_type distance_to(const BitIterator &other) const
7242
{
73-
return detail::countOnes(m_value) - detail::countOnes(other.m_value);
43+
return std::popcount(m_value) - std::popcount(other.m_value);
7444
}
7545

7646
bool equal(const BitIterator &other) const { return m_value == other.m_value; }

include/util/msb.hpp

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,24 @@
11
#ifndef OSRM_UTIL_MSB_HPP
22
#define OSRM_UTIL_MSB_HPP
33

4+
#include <bit>
45
#include <boost/assert.hpp>
5-
6-
#include <climits>
76
#include <cstdint>
8-
#include <utility>
7+
#include <limits>
98

109
namespace osrm::util
1110
{
1211

13-
// get the msb of an integer
14-
// return 0 for integers without msb
1512
template <typename T> std::size_t msb(T value)
1613
{
14+
BOOST_ASSERT(value > 0);
15+
1716
static_assert(std::is_integral<T>::value && !std::is_signed<T>::value, "Integer required.");
18-
std::size_t msb = 0;
19-
while (value > 0)
20-
{
21-
value >>= 1u;
22-
msb++;
23-
}
24-
BOOST_ASSERT(msb > 0);
25-
return msb - 1;
26-
}
17+
constexpr auto MSB_INDEX = std::numeric_limits<unsigned char>::digits * sizeof(T) - 1;
2718

28-
#if (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__))
29-
inline std::size_t msb(unsigned long long v)
30-
{
31-
BOOST_ASSERT(v > 0);
32-
constexpr auto MSB_INDEX = CHAR_BIT * sizeof(unsigned long long) - 1;
33-
return MSB_INDEX - __builtin_clzll(v);
34-
}
35-
inline std::size_t msb(unsigned long v)
36-
{
37-
BOOST_ASSERT(v > 0);
38-
constexpr auto MSB_INDEX = CHAR_BIT * sizeof(unsigned long) - 1;
39-
return MSB_INDEX - __builtin_clzl(v);
40-
}
41-
inline std::size_t msb(unsigned int v)
42-
{
43-
BOOST_ASSERT(v > 0);
44-
constexpr auto MSB_INDEX = CHAR_BIT * sizeof(unsigned int) - 1;
45-
return MSB_INDEX - __builtin_clz(v);
19+
return MSB_INDEX - std::countl_zero(value);
4620
}
47-
#endif
21+
4822
} // namespace osrm::util
4923

5024
#endif

profiles/bicycle.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ function setup()
3737
turn_bias = 1.4,
3838
use_public_transport = true,
3939

40+
-- Exclude narrow ways, in particular to route with cargo bike
41+
width = nil, -- Cargo bike could 0.5 width, in meters
42+
exclude_cargo_bike = false,
43+
4044
allowed_start_modes = Set {
4145
mode.cycling,
4246
mode.pushing_bike
@@ -251,6 +255,27 @@ function process_node(profile, node, result)
251255
end
252256
end
253257

258+
if profile.exclude_cargo_bike then
259+
local cargo_bike = node:get_value_by_key("cargo_bike")
260+
if cargo_bike and cargo_bike == "no" then
261+
result.barrier = true
262+
end
263+
end
264+
265+
-- width
266+
if profile.width then
267+
-- From barrier=cycle_barrier or other barriers
268+
local maxwidth_physical = node:get_value_by_key("maxwidth:physical")
269+
local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99
270+
local opening = node:get_value_by_key("opening")
271+
local opening_meter = opening and Measure.parse_value_meters(opening) or 99
272+
local width_meter = math.min(maxwidth_physical_meter, opening_meter)
273+
274+
if width_meter and width_meter < profile.width then
275+
result.barrier = true
276+
end
277+
end
278+
254279
-- check if node is a traffic light
255280
result.traffic_lights = TrafficSignal.get_value(node)
256281
end
@@ -307,6 +332,8 @@ function handle_bicycle_tags(profile,way,result,data)
307332

308333
bike_push_handler(profile,way,result,data)
309334

335+
-- width should be after bike_push
336+
width_handler(profile,way,result,data)
310337

311338
-- maxspeed
312339
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
@@ -479,6 +506,27 @@ function cycleway_handler(profile,way,result,data)
479506
end
480507
end
481508

509+
function width_handler(profile,way,result,data)
510+
if profile.exclude_cargo_bike then
511+
local cargo_bike = way:get_value_by_key("cargo_bike")
512+
if cargo_bike and cargo_bike == "no" then
513+
result.forward_mode = mode.inaccessible
514+
result.backward_mode = mode.inaccessible
515+
end
516+
end
517+
518+
if profile.width then
519+
local width = way:get_value_by_key("width")
520+
if width then
521+
local width_meter = Measure.parse_value_meters(width)
522+
if width_meter and width_meter < profile.width then
523+
result.forward_mode = mode.inaccessible
524+
result.backward_mode = mode.inaccessible
525+
end
526+
end
527+
end
528+
end
529+
482530
function bike_push_handler(profile,way,result,data)
483531
-- pushing bikes - if no other mode found
484532
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or

scripts/update_dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set -o nounset
1010
# http://git.661346.n2.nabble.com/subtree-merges-lose-prefix-after-rebase-td7332850.html
1111

1212
OSMIUM_PATH="osmcode/libosmium"
13-
OSMIUM_TAG=v2.14.0
13+
OSMIUM_TAG=v2.20.0
1414

1515
SOL_PATH="ThePhD/sol2"
1616
SOL_TAG=v3.3.0
@@ -22,7 +22,7 @@ MICROTAR_PATH="rxi/microtar"
2222
MICROTAR_TAG=v0.1.0
2323

2424
PROTOZERO_PATH="mapbox/protozero"
25-
PROTOZERO_TAG=v1.6.2
25+
PROTOZERO_TAG=v1.7.1
2626

2727
VTZERO_PATH="mapbox/vtzero"
2828
VTZERO_TAG=v1.1.0

third_party/libosmium/.clang-tidy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: '*,-abseil-string-find-str-contains,-altera-*,-android-cloexec-*,-bugprone-branch-clone,-bugprone-easily-swappable-parameters,-bugprone-macro-parentheses,-cert-dcl21-cpp,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-invalid-access-moved,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-vararg,-llvmlibc-*,-llvm-qualified-auto,-misc-macro-parentheses,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-unused-parameters,-modernize-avoid-c-arrays,-modernize-make-unique,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-readability-avoid-const-params-in-decls,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-implicit-bool-cast,-readability-implicit-bool-conversion,-readability-magic-numbers,-readability-qualified-auto'
2+
Checks: '*,-abseil-string-find-str-contains,-altera-*,-android-cloexec-*,-bugprone-branch-clone,-bugprone-easily-swappable-parameters,-bugprone-macro-parentheses,-cert-dcl21-cpp,-cert-err58-cpp,-clang-analyzer-optin.cplusplus.VirtualCall,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-invalid-access-moved,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-vararg,-llvmlibc-*,-llvm-qualified-auto,-misc-macro-parentheses,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-unused-parameters,-modernize-avoid-c-arrays,-modernize-make-unique,-modernize-raw-string-literal,-modernize-use-trailing-return-type,-readability-avoid-const-params-in-decls,-readability-convert-member-functions-to-static,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-implicit-bool-cast,-readability-implicit-bool-conversion,-readability-magic-numbers,-readability-qualified-auto'
33
#
44
# For a list of check options, see:
55
# https://clang.llvm.org/extra/clang-tidy/checks/list.html
@@ -137,6 +137,9 @@ Checks: '*,-abseil-string-find-str-contains,-altera-*,-android-cloexec-*,-bugpro
137137
# This is header only library, so the declaration and implementation are
138138
# often the same and we want to have the const in implementations.
139139
#
140+
# readability-convert-member-functions-to-static
141+
# Reports too many false positives
142+
#
140143
# readability-function-cognitive-complexity
141144
# Sometimes the large functions are needed.
142145
#

third_party/libosmium/.github/actions/cmake-windows/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ runs:
77
run: mkdir build
88
shell: bash
99
- name: Configure
10-
run: cmake -LA .. -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_HEADERS=OFF -DBUILD_BENCHMARKS=ON -DOsmium_DEBUG=TRUE -DPROTOZERO_INCLUDE_DIR=${GITHUB_WORKSPACE}/../protozero/include
10+
run: |
11+
cmake -LA .. \
12+
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
13+
-DBUILD_HEADERS=OFF \
14+
-DBUILD_BENCHMARKS=ON \
15+
-DOsmium_DEBUG=TRUE \
16+
-DPROTOZERO_INCLUDE_DIR=${GITHUB_WORKSPACE}/../protozero/include
1117
shell: bash
1218
working-directory: build
1319

third_party/libosmium/.github/actions/install-ubuntu/action.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runs:
55
steps:
66
- name: Install packages
77
run: |
8-
sudo apt-get update -q
8+
sudo apt-get update -qq
99
sudo apt-get install -yq \
1010
doxygen \
1111
libboost-dev \
@@ -16,8 +16,5 @@ runs:
1616
libsparsehash-dev \
1717
ruby-json \
1818
spatialite-bin
19-
test "$CC" = clang-6.0 && sudo apt-get install -yq --no-install-suggests --no-install-recommends clang-6.0
20-
test "$CC" = clang-8 && sudo apt-get install -yq --no-install-suggests --no-install-recommends clang-8
21-
test "$CC" = clang-13 && sudo apt-get install -yq --no-install-suggests --no-install-recommends clang-13
2219
shell: bash
2320

0 commit comments

Comments
 (0)