Skip to content

Commit e1f933f

Browse files
committed
stop_schedule: Add headsign and trip_short_name on display informations
1 parent acbed14 commit e1f933f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

source/jormungandr/tests/departure_board_tests.py

+22
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,28 @@ def test_display_informations_in_routes_schedule(self):
683683
assert display_information_route['name'] == 'line:A'
684684
assert display_information_route['code'] == 'A'
685685

686+
def test_display_informations_in_stop_schedule(self):
687+
"""
688+
verify some attributs in display_informations of a stop_schedule
689+
"""
690+
response = self.query_region(
691+
"stop_areas/stop1/stop_schedules?from_datetime=20120615T080000&disable_geojson=true"
692+
)
693+
schedules = get_not_null(response, 'stop_schedules')
694+
assert len(schedules) == 1, "there should be only one elt"
695+
schedule = schedules[0]
696+
is_valid_stop_schedule(response["stop_schedules"], self.tester, only_time=False)
697+
698+
display_information_route = get_not_null(schedule, 'display_informations')
699+
assert display_information_route['direction'] == 'stop2'
700+
assert display_information_route['label'] == 'A'
701+
assert display_information_route['color'] == '289728'
702+
assert display_information_route['text_color'] == 'FFD700'
703+
assert display_information_route['name'] == 'line:A'
704+
assert display_information_route['code'] == 'A'
705+
assert display_information_route['headsign'] == 'week'
706+
assert display_information_route['trip_short_name'] == 'week'
707+
686708
def test_terminus_schedules(self):
687709
"""
688710
terminus_schedules for a given date

source/time_tables/departure_boards.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,16 @@ static void render(PbCreator& pb_creator,
132132
auto pt_display_information = schedule->mutable_pt_display_informations();
133133
pb_creator.fill(route, pt_display_information, 0);
134134

135+
bool vj_found = false;
136+
135137
// Now we fill the date_times
136138
for (auto dt_st : id_vec.second) {
139+
if (!vj_found && dt_st.second != nullptr) {
140+
auto vj = dt_st.second->vehicle_journey;
141+
pt_display_information->set_trip_short_name(vj->name);
142+
pt_display_information->set_headsign(pb_creator.data->pt_data->headsign_handler.get_headsign(vj));
143+
vj_found = true;
144+
}
137145
fill_date_times(pb_creator, schedule, dt_st, calendar_id);
138146
}
139147

source/time_tables/tests/departure_boards_test.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ BOOST_AUTO_TEST_CASE(departureboard_test1) {
8888
BOOST_REQUIRE_EQUAL(resp.stop_schedules_size(), 2);
8989
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).date_times_size(), 1);
9090
BOOST_REQUIRE_EQUAL(resp.stop_schedules(1).date_times_size(), 1);
91+
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).pt_display_informations().headsign(), "headsign_vj1");
92+
BOOST_REQUIRE_EQUAL(resp.stop_schedules(0).pt_display_informations().trip_short_name(), "vj1");
9193
}
9294

9395
// comparing terminus_schedule with above stop_schedules (function "departure_board")

0 commit comments

Comments
 (0)