From becfd8a56d15bc30d472e08d1d94d00854c58cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Rodrigo?= Date: Tue, 1 Oct 2024 14:19:44 +0200 Subject: [PATCH 1/2] Add optional support of cargo bike exclusion and width to bicyle profile (#7044) --- CHANGELOG.md | 1 + profiles/bicycle.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 614601a6c..954dcc627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ - ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839) - Profiles: - FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615) + - ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044) - Routing: - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) - FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724) diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 19202768e..2c701e218 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -35,6 +35,10 @@ function setup() turn_bias = 1.4, use_public_transport = true, + -- Exclude narrow ways, in particular to route with cargo bike + width = nil, -- Cargo bike could 0.5 width, in meters + exclude_cargo_bike = false, + allowed_start_modes = Set { mode.cycling, mode.pushing_bike @@ -243,6 +247,27 @@ function process_node(profile, node, result) end end + if profile.exclude_cargo_bike then + local cargo_bike = node:get_value_by_key("cargo_bike") + if cargo_bike and cargo_bike == "no" then + result.barrier = true + end + end + + -- width + if profile.width then + -- From barrier=cycle_barrier or other barriers + local maxwidth_physical = node:get_value_by_key("maxwidth:physical") + local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99 + local opening = node:get_value_by_key("opening") + local opening_meter = opening and Measure.parse_value_meters(opening) or 99 + local width_meter = math.min(maxwidth_physical_meter, opening_meter) + + if width_meter and width_meter < profile.width then + result.barrier = true + end + end + -- check if node is a traffic light result.traffic_lights = TrafficSignal.get_value(node) end @@ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data) bike_push_handler(profile,way,result,data) + -- width should be after bike_push + width_handler(profile,way,result,data) -- maxspeed limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward ) @@ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data) end end +function width_handler(profile,way,result,data) + if profile.exclude_cargo_bike then + local cargo_bike = way:get_value_by_key("cargo_bike") + if cargo_bike and cargo_bike == "no" then + result.forward_mode = mode.inaccessible + result.backward_mode = mode.inaccessible + end + end + + if profile.width then + local width = way:get_value_by_key("width") + if width then + local width_meter = Measure.parse_value_meters(width) + if width_meter and width_meter < profile.width then + result.forward_mode = mode.inaccessible + result.backward_mode = mode.inaccessible + end + end + end +end + function bike_push_handler(profile,way,result,data) -- pushing bikes - if no other mode found if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or From 48e8382785f3db82852bb8f37567e866bf83251a Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sun, 20 Oct 2024 19:46:49 +0200 Subject: [PATCH 2/2] Remove unused bearing::get function (#7040) * Remove unused bearing::get function * Remove unused bearing::get function * Remove unused bearing::get function * Remove unused bearing::get function --- .github/workflows/osrm-backend.yml | 7 ++++++ include/util/bearing.hpp | 40 ------------------------------ unit_tests/util/io.cpp | 1 - 3 files changed, 7 insertions(+), 41 deletions(-) diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index fe4ee3248..abbe09245 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -502,6 +502,13 @@ jobs: conan config init yq eval '.compiler.clang.version += ["18"]' -i "$HOME/.conan/settings.yml" + - name: Add Apple-clang 16 to list of Conan compilers # workaround for the issue that Conan 1.x doesn't know about Apple-clang 16 + if: ${{ matrix.ENABLE_CONAN == 'ON' && matrix.runs-on == 'macos-14' }} + run: | + sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_darwin_arm64 -O /usr/local/bin/yq && sudo chmod +x /usr/local/bin/yq + + conan config init + yq eval '.compiler.apple-clang.version += ["16.0"]' -i "$HOME/.conan/settings.yml" - name: Prepare build run: | mkdir ${OSRM_BUILD_DIR} diff --git a/include/util/bearing.hpp b/include/util/bearing.hpp index cc2cdfda4..431878695 100644 --- a/include/util/bearing.hpp +++ b/include/util/bearing.hpp @@ -11,46 +11,6 @@ namespace osrm::util namespace bearing { -inline std::string get(const double heading) -{ - BOOST_ASSERT(heading >= 0); - BOOST_ASSERT(heading <= 360); - - if (heading <= 22.5) - { - return "N"; - } - if (heading <= 67.5) - { - return "NE"; - } - if (heading <= 112.5) - { - return "E"; - } - if (heading <= 157.5) - { - return "SE"; - } - if (heading <= 202.5) - { - return "S"; - } - if (heading <= 247.5) - { - return "SW"; - } - if (heading <= 292.5) - { - return "W"; - } - if (heading <= 337.5) - { - return "NW"; - } - return "N"; -} - // Checks whether A is between B-range and B+range, all modulo 360 // e.g. A = 5, B = 5, range = 10 == true // A = -6, B = 5, range = 10 == false diff --git a/unit_tests/util/io.cpp b/unit_tests/util/io.cpp index 4cc3a688b..d9f86d0e7 100644 --- a/unit_tests/util/io.cpp +++ b/unit_tests/util/io.cpp @@ -17,7 +17,6 @@ const static std::string IO_TOO_SMALL_FILE = "file_too_small_test_io.tmp"; const static std::string IO_CORRUPT_FINGERPRINT_FILE = "corrupt_fingerprint_file_test_io.tmp"; const static std::string IO_INCOMPATIBLE_FINGERPRINT_FILE = "incompatible_fingerprint_file_test_io.tmp"; -const static std::string IO_TEXT_FILE = "plain_text_file.tmp"; using namespace osrm;