Skip to content

Commit cd1f2cf

Browse files
Fix nullptr error
1 parent da5f08f commit cd1f2cf

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/routing/one_to_all.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ day_idx_t make_base(timetable const& tt, unixtime_t start_time) {
2323
.count()};
2424
}
2525

26-
template <direction SearchDir>
27-
void run_raptor(raptor<SearchDir, true, kVias, search_mode::kOneToAll>&& algo,
26+
template <direction SearchDir, bool Rt>
27+
void run_raptor(raptor<SearchDir, Rt, kVias, search_mode::kOneToAll>&& algo,
2828
unixtime_t const& start_time,
2929
query const& q) {
3030
auto results = pareto_set<journey>{};
@@ -47,7 +47,7 @@ void run_raptor(raptor<SearchDir, true, kVias, search_mode::kOneToAll>&& algo,
4747
results);
4848
}
4949

50-
template <direction SearchDir>
50+
template <direction SearchDir, bool Rt>
5151
raptor_state one_to_all(timetable const& tt,
5252
rt_timetable const* rtt,
5353
query const& q) {
@@ -66,7 +66,7 @@ raptor_state one_to_all(timetable const& tt,
6666
auto const base = make_base(tt, start_time);
6767
auto const is_wheelchair = true;
6868

69-
auto r = raptor<SearchDir, true, kVias, search_mode::kOneToAll>{
69+
auto r = raptor<SearchDir, Rt, kVias, search_mode::kOneToAll>{
7070
tt,
7171
rtt,
7272
state,
@@ -87,6 +87,17 @@ raptor_state one_to_all(timetable const& tt,
8787
return state;
8888
}
8989

90+
template <direction SearchDir>
91+
raptor_state one_to_all(timetable const& tt,
92+
rt_timetable const* rtt,
93+
query const& q) {
94+
if (rtt == nullptr) {
95+
return one_to_all<SearchDir, false>(tt, rtt, q);
96+
} else {
97+
return one_to_all<SearchDir, true>(tt, rtt, q);
98+
}
99+
}
100+
90101
template <direction SearchDir>
91102
fastest_offset get_fastest_offset(timetable const& tt,
92103
raptor_state const& state,

test/rt/frun_shape_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ TEST(
836836
}
837837
}
838838

839-
// One-to-All search for time point
839+
// One-to-All search for time point and without Rt
840840
{
841841
// Exact start time
842842
{
@@ -850,7 +850,7 @@ TEST(
850850
.start_ = to_offsets("A"),
851851
.max_travel_time_ = 4_hours,
852852
};
853-
auto state = nigiri::routing::one_to_all<kSearchDir>(tt, &rtt, q);
853+
auto state = nigiri::routing::one_to_all<kSearchDir>(tt, nullptr, q);
854854

855855
ASSERT_TRUE(is_reachable(state, to_location_idx("I"),
856856
kUnreachable)); // 122 minutes

0 commit comments

Comments
 (0)