Skip to content

Commit 29bbad5

Browse files
TheMarexCopilot
andauthored
Limit max exclude classes to 7 (#7322)
* Limit max exclude classes to 7 * Add changelog * Update include/extractor/class_data.hpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b69d940 commit 29bbad5

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
- CHANGED: Upgrade Cucumber-js to v12 [#7221](https://github.com/Project-OSRM/osrm-backend/pull/7221)
2222
- CHANGED: Add libcap-setcap to alpine dockerfile [#7241](https://github.com/Project-OSRM/osrm-backend/issues/7241)
2323
- FIXED: Minor misspellings found in source code, comments and documents [#7215](https://github.com/Project-OSRM/osrm-backend/pull/7215)
24+
- Profile:
2425
- FIXED: Use `cycleway:both` if available. [#6179](https://github.com/Project-OSRM/osrm-backend/issues/6179)
26+
- FIXED: Correctly limit exclude classes to 7. [#7322](https://github.com/Project-OSRM/osrm-backend/pull/7322)
2527

2628
# 6.0.0
2729
- Changes from 6.0.0 RC2: None

include/extractor/class_data.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ namespace osrm::extractor
1313
{
1414

1515
using ClassData = std::uint8_t;
16-
constexpr ClassData INAVLID_CLASS_DATA = std::numeric_limits<ClassData>::max();
17-
static const std::uint8_t MAX_CLASS_INDEX = 8 - 1;
18-
static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 8;
16+
constexpr ClassData INVALID_CLASS_DATA = std::numeric_limits<ClassData>::max();
17+
static const std::uint8_t MAX_CLASS_INDEX = 7 - 1;
18+
// We can allow for 7 classes, so 0b0111_1111 when all would be set on an edge.
19+
// Setting the MSB would mark it invalid.
20+
static const std::uint8_t MAX_EXCLUDABLE_CLASSES = 7;
1921

2022
inline bool isSubset(const ClassData lhs, const ClassData rhs) { return (lhs & rhs) == lhs; }
2123

include/extractor/profile_properties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ProfileProperties
3030
weight_name{"duration"}, class_names{{}}, excludable_classes{{}},
3131
call_tagless_node_function(true)
3232
{
33-
std::fill(excludable_classes.begin(), excludable_classes.end(), INAVLID_CLASS_DATA);
33+
std::fill(excludable_classes.begin(), excludable_classes.end(), INVALID_CLASS_DATA);
3434
BOOST_ASSERT(weight_name[MAX_WEIGHT_NAME_LENGTH] == '\0');
3535
}
3636

include/util/exclude_flag.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ excludeFlagsToNodeFilter(const NodeID number_of_nodes,
1515
std::vector<std::vector<bool>> filters;
1616
for (auto mask : properties.excludable_classes)
1717
{
18-
if (mask != extractor::INAVLID_CLASS_DATA)
18+
if (mask != extractor::INVALID_CLASS_DATA)
1919
{
2020
std::vector<bool> allowed_nodes(number_of_nodes);
2121
for (const auto node : util::irange<NodeID>(0, number_of_nodes))

unit_tests/extractor/intersection_analysis_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ using Graph = util::NodeBasedDynamicGraph;
1919
BOOST_AUTO_TEST_CASE(simple_intersection_connectivity)
2020
{
2121
std::vector<NodeBasedEdgeAnnotation> annotations{
22-
{EMPTY_NAMEID, 0, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false},
23-
{EMPTY_NAMEID, 1, INAVLID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}};
22+
{EMPTY_NAMEID, 0, INVALID_CLASS_DATA, TRAVEL_MODE_DRIVING, false},
23+
{EMPTY_NAMEID, 1, INVALID_CLASS_DATA, TRAVEL_MODE_DRIVING, false}};
2424
std::vector<TurnRestriction> restrictions{TurnRestriction{{ViaNodePath{0, 2, 1}}, false}};
2525
CompressedEdgeContainer container;
2626
test::MockScriptingEnvironment scripting_environment;

0 commit comments

Comments
 (0)