Skip to content

Commit

Permalink
nigiri clasz filter (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling authored Feb 27, 2024
1 parent a24f9a9 commit df2bbfa
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
[nigiri]
[email protected]:motis-project/nigiri.git
branch=master
commit=4adc2c34fd09b13a7b3cad3a4b4a756b5d04c6b7
commit=bf9b9e98ef5ddf35a1d37defd0af55e459351f18
[osmium]
[email protected]:motis-project/libosmium.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
14571522376964160082
10322426052533489617
cista 49090f7891d069e6136efef1e730a4f24a190a81
zlib fe8e13ffca867612951bc6baf114e5ac8b00f305
boost be5235eb2258d2ec19e32546ab767a62311d9b46
Expand Down Expand Up @@ -29,7 +29,7 @@ abseil-cpp f2b3825f36e37fddd47c5c395096e9b1e99eca12
protobuf 690e03babf0963d3da9615a2dae0891777842719
unordered_dense 4f380fb1d64f1843ca2c993ed39a8342a8747e5d
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
nigiri 4adc2c34fd09b13a7b3cad3a4b4a756b5d04c6b7
nigiri bf9b9e98ef5ddf35a1d37defd0af55e459351f18
lua 6898e2902fa5b890e0384e437abeb16034c61ece
luabind 9223568bbcf818ecfb1001d49f567627ee10852a
tbb 2067af88257710d07253761655a802732a32496e
Expand Down
14 changes: 9 additions & 5 deletions modules/intermodal/src/intermodal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,15 @@ msg_ptr intermodal::route(msg_ptr const& msg) {

mc.create_and_finish(
MsgContent_RoutingRequest,
CreateRoutingRequest(mc, start.start_type_, start.start_, dest.station_,
req->search_type(), req->search_dir(),
mc.CreateVector(std::vector<Offset<Via>>{}),
mc.CreateVector(edges), true, true, true, 0,
timeout_)
CreateRoutingRequest(
mc, start.start_type_, start.start_, dest.station_,
req->search_type(), req->search_dir(),
mc.CreateVector(std::vector<Offset<Via>>{}), mc.CreateVector(edges),
true, true, true, 0, timeout_,
req->allowed_claszes() == nullptr
? 0
: mc.CreateVector(req->allowed_claszes()->Data(),
req->allowed_claszes()->size()))
.Union(),
router);

Expand Down
17 changes: 16 additions & 1 deletion modules/nigiri/src/routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ auto run_search(n::routing::search_state& search_state,
}
}

n::routing::clasz_mask_t to_clasz_mask(fbs::Vector<std::uint8_t> const* v) {
if (v == nullptr) {
return n::routing::all_clasz_allowed();
} else {
auto mask = n::routing::clasz_mask_t{0U};
for (auto const c : *v) {
utl::verify(c < static_cast<std::uint8_t>(n::clasz::kNumClasses),
"clasz {} does not exist", c);
mask |= (1U << c);
}
return mask;
}
}

motis::module::msg_ptr route(tag_lookup const& tags, n::timetable const& tt,
n::rt_timetable const* rtt,
motis::module::msg_ptr const& msg,
Expand Down Expand Up @@ -299,7 +313,8 @@ motis::module::msg_ptr route(tag_lookup const& tags, n::timetable const& tt,
.min_connection_count_ = min_connection_count,
.extend_interval_earlier_ = extend_interval_earlier,
.extend_interval_later_ = extend_interval_later,
.prf_idx_ = prf_idx};
.prf_idx_ = prf_idx,
.allowed_claszes_ = to_clasz_mask(req->allowed_claszes())};

utl::verify(!q.start_.empty(), "no start edges");
utl::verify(!q.destination_.empty(), "no destination edges");
Expand Down
1 change: 1 addition & 0 deletions protocol/intermodal/IntermodalRoutingRequest.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ table IntermodalRoutingRequest {
search_type: routing.SearchType;
search_dir: motis.SearchDir;
router: string (optional);
allowed_claszes: [ubyte] (optional);
}
1 change: 1 addition & 0 deletions protocol/routing/RoutingRequest.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ table RoutingRequest {
use_start_footpaths: bool = true;
schedule: ulong; // schedule id (0 = default)
timeout: int = 0; // 0 = none
allowed_claszes: [ubyte] (optional);
}

0 comments on commit df2bbfa

Please sign in to comment.