Open danito opened 4 years ago
The line_ids+ direction are strongly tied to the stop_id. A stop_id corresponds to a "physical" stop for example with Scherdemael, stop_id 3755 corresponds to the line 46 in the direction of Glibert and the stop_id 3713 is the line 46 going to Moortebeek.
I used the stop_names to abstract the concept of stop_id. The lambda user knows about the stop name and the line numbers and the directions (terminus). he doesn't know the technical stop_id and, in my opinion, shouldn't use it...
I found out that filter_lines(line_id,dir) actually does give all the next passages for the stop_id where the line passes (and not only for the given line):
print(await service.get_passages("DE BROUCKERE",line_filters = [(1,1)], lang_message="fr", max_passages=44))
[
{'stop_id': '8012', 'line_id': '5', 'destination': 'HERRMANN-DEBROUX', 'line_color': '#E6B012', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T14:12:00+02:00', 'arriving_in': {'min': 2, 'sec': 5}},
{'stop_id': '8012', 'line_id': '1', 'destination': 'STOCKEL', 'line_color': '#C4008F', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T14:17:00+02:00', 'arriving_in': {'min': 7, 'sec': 5}},
{'stop_id': '8012', 'line_id': '5', 'destination': 'HERRMANN-DEBROUX', 'line_color': '#E6B012', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T14:22:00+02:00', 'arriving_in': {'min': 12, 'sec': 5}},
{'stop_id': '8012', 'line_id': '1', 'destination': 'STOCKEL', 'line_color': '#C4008F', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T14:27:00+02:00', 'arriving_in': {'min': 17, 'sec': 5}}
]
I expected line_filters() to actually give only results for the submitted lines, but this is ok for me :-)
But on the other hand, this example doesn't work as expected (getting both directions for line 1 and all other lines that passes there):
print(await service.get_passages("DE BROUCKERE",line_filters = [(4,1),(4,0)], lang_message="fr", max_passages=44))
[
{'stop_id': '8012', 'line_id': '1', 'destination': 'STOCKEL', 'line_color': '#C4008F', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T15:29:00+02:00', 'arriving_in': {'min': 0, 'sec': 19}},
{'stop_id': '8012', 'line_id': '5', 'destination': 'HERRMANN-DEBROUX', 'line_color': '#E6B012', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T15:33:00+02:00', 'arriving_in': {'min': 4, 'sec': 19}},
{'stop_id': '8012', 'line_id': '1', 'destination': 'STOCKEL', 'line_color': '#C4008F', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T15:38:00+02:00', 'arriving_in': {'min': 9, 'sec': 19}},
{'stop_id': '8012', 'line_id': '5', 'destination': 'HERRMANN-DEBROUX', 'line_color': '#E6B012', 'line_text_color': '#FFFFFF', 'line_type': 'M', 'message': '', 'expected_arrival_time': '2020-06-07T15:42:00+02:00', 'arriving_in': {'min': 13, 'sec': 19}}
]
Edit: shame on me, direction are 1 or 2 (not 0), so with line_filters([(4,1),(4,2)]) it works as expected.
You are right, the line_filter needs some adjustments, i saw that behavior happen once but never took the time to fix it. It's in my to-do list.
Why not add a stop_filter(stop_ids) so that when you know the stop_id, you can get only the passages for the direction you want.
You can directly use STIBAPIClient.api_call_passingTimeByPoint_for_stop_id(stop_id) and STIBAPIClient.api_call_passingTimeByPoint_for_stop_ids(list(stop_ids)) for this purpose. This is a "low level" call but won't return Passage objects
Hi, When using the stop name, you get the next passages for both directions, but what if you just want to have the next passages for a particular direction? Why not add a stop_filter(stop_ids) so that when you know the stop_id, you can get only the passages for the direction you want.