Skip to content

Commit a463bbb

Browse files
Merge branch 'master' into sf-conan2
2 parents df5da66 + 48e8382 commit a463bbb

File tree

3 files changed

+49
-40
lines changed

3 files changed

+49
-40
lines changed

CHANGELOG.md

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

include/util/bearing.hpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,6 @@ namespace osrm::util
1111
namespace bearing
1212
{
1313

14-
inline std::string get(const double heading)
15-
{
16-
BOOST_ASSERT(heading >= 0);
17-
BOOST_ASSERT(heading <= 360);
18-
19-
if (heading <= 22.5)
20-
{
21-
return "N";
22-
}
23-
if (heading <= 67.5)
24-
{
25-
return "NE";
26-
}
27-
if (heading <= 112.5)
28-
{
29-
return "E";
30-
}
31-
if (heading <= 157.5)
32-
{
33-
return "SE";
34-
}
35-
if (heading <= 202.5)
36-
{
37-
return "S";
38-
}
39-
if (heading <= 247.5)
40-
{
41-
return "SW";
42-
}
43-
if (heading <= 292.5)
44-
{
45-
return "W";
46-
}
47-
if (heading <= 337.5)
48-
{
49-
return "NW";
50-
}
51-
return "N";
52-
}
53-
5414
// Checks whether A is between B-range and B+range, all modulo 360
5515
// e.g. A = 5, B = 5, range = 10 == true
5616
// A = -6, B = 5, range = 10 == false

profiles/bicycle.lua

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

38+
-- Exclude narrow ways, in particular to route with cargo bike
39+
width = nil, -- Cargo bike could 0.5 width, in meters
40+
exclude_cargo_bike = false,
41+
3842
allowed_start_modes = Set {
3943
mode.cycling,
4044
mode.pushing_bike
@@ -243,6 +247,27 @@ function process_node(profile, node, result)
243247
end
244248
end
245249

250+
if profile.exclude_cargo_bike then
251+
local cargo_bike = node:get_value_by_key("cargo_bike")
252+
if cargo_bike and cargo_bike == "no" then
253+
result.barrier = true
254+
end
255+
end
256+
257+
-- width
258+
if profile.width then
259+
-- From barrier=cycle_barrier or other barriers
260+
local maxwidth_physical = node:get_value_by_key("maxwidth:physical")
261+
local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99
262+
local opening = node:get_value_by_key("opening")
263+
local opening_meter = opening and Measure.parse_value_meters(opening) or 99
264+
local width_meter = math.min(maxwidth_physical_meter, opening_meter)
265+
266+
if width_meter and width_meter < profile.width then
267+
result.barrier = true
268+
end
269+
end
270+
246271
-- check if node is a traffic light
247272
result.traffic_lights = TrafficSignal.get_value(node)
248273
end
@@ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data)
299324

300325
bike_push_handler(profile,way,result,data)
301326

327+
-- width should be after bike_push
328+
width_handler(profile,way,result,data)
302329

303330
-- maxspeed
304331
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
@@ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data)
453480
end
454481
end
455482

483+
function width_handler(profile,way,result,data)
484+
if profile.exclude_cargo_bike then
485+
local cargo_bike = way:get_value_by_key("cargo_bike")
486+
if cargo_bike and cargo_bike == "no" then
487+
result.forward_mode = mode.inaccessible
488+
result.backward_mode = mode.inaccessible
489+
end
490+
end
491+
492+
if profile.width then
493+
local width = way:get_value_by_key("width")
494+
if width then
495+
local width_meter = Measure.parse_value_meters(width)
496+
if width_meter and width_meter < profile.width then
497+
result.forward_mode = mode.inaccessible
498+
result.backward_mode = mode.inaccessible
499+
end
500+
end
501+
end
502+
end
503+
456504
function bike_push_handler(profile,way,result,data)
457505
-- pushing bikes - if no other mode found
458506
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or

0 commit comments

Comments
 (0)