Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelled trips #19

Closed
hildwin opened this issue Dec 5, 2017 · 24 comments
Closed

Cancelled trips #19

hildwin opened this issue Dec 5, 2017 · 24 comments
Labels

Comments

@hildwin
Copy link

hildwin commented Dec 5, 2017

First of all: Thank you for your service.
I'm trying to build a display which shows the next departure at my favorite S-Bahn station. Your API is a great help to realize it.

Regarding the output I have a question:
How can I recognize that a trip has been canceled?

Example:

Response from http://mobile.bahn.de/:
S 85 >> Berlin-Schöneweide (S)
10:08 Fahrt fällt aus, Gl. 2

Response from the API:
{'direction': 'S Schöneweide', 'station': {'products': {'suburban': True, 'regional': False, 'express': False, 'tram': False, 'bus': False, 'ferry': False, 'subway': False}, 'name': 'S+U Wittenau', 'coordinates': {'longitude': 13.335479, 'latitude': 52.596388}, 'id': '900000096101', 'type': 'station'}, 'remarks': [None, None], 'trip': 43004, 'line': {'class': 1, 'productCode': 0, 'nr': 85, 'productName': 'S-5', 'name': 'S85', 'symbol': 'S', 'product': 'suburban', 'express': False, 'metro': False, 'night': False, 'id': 's85', 'type': 'line', 'mode': 'train'}, 'ref': '1|43004|2|86|5122017', 'when': '2017-12-05T10:08:00+01:00', 'delay': None}

Thanks in advance!

@derhuerst
Copy link
Owner

AFAIK my API doesn't support it yet. There's more information about how to tell if a trip has been canceled in public-transport/hafas-client#2 and I'm currently rewriting the package that queries the VBB API. So you have to be patient for now. 😉

@hildwin
Copy link
Author

hildwin commented Dec 5, 2017

Thank you. It is possible that delay = None is a hint for a cancelled trip?

@derhuerst
Copy link
Owner

it may also mean that there's currently no realtime info available, so no, not reliably.

@derhuerst
Copy link
Owner

In public-transport/vbb-hafas@6bf3531, i have set up logging to collect possible values for dProgType and aProgType (the VBB fields for the type of realtime information). Hopefully I'll get some insights from that an be able to support canceled trips soon.

@derhuerst
Copy link
Owner

Note to myself: isRchbl may also convey wether the departure/trip has been canceled.

@derhuerst
Copy link
Owner

Found it! It is dep.dCncl: true and arr.aCncl: true. Will expose them with the next release of vbb-hafas.

@derhuerst derhuerst added the bug label Dec 6, 2017
@deg0nz
Copy link

deg0nz commented Dec 6, 2017

Nice! That is useful. I‘m gonna integrate it in my MagicMirror module.

@derhuerst
Copy link
Owner

Sry, with the next release after the one I just released. 😛

derhuerst added a commit to public-transport/hafas-client that referenced this issue Dec 6, 2017
@derhuerst
Copy link
Owner

hafas-client@1.3.0 will expose cancelled: true on a journey leg.

My rewrite (which will likely become hafas-client@2) will also mark the journey as cancelled: true and set departure/arrival, departurePlatform/arrivalPlatform and delay to null.

@derhuerst
Copy link
Owner

The changes should be live at vbb.transport.rest now. It's hard to test wether everything works though, as only very few departures get canceled.

@hildwin
Copy link
Author

hildwin commented Dec 8, 2017

I‘ll look into it! Thanks a lot.

@hildwin
Copy link
Author

hildwin commented Dec 8, 2017

When I do a simple departure request
curl 'https://vbb.transport.rest/stations/900000096101/departures?nextStation=900000084101&results=1'
at a specific station I get this:

{"ref":"1|40079|0|86|8122017", "station":{"type":"station","name":"S+U Wittenau", "coordinates":{"latitude":52.596388,"longitude":13.335479}, "id":"900000096101", "products":{"suburban":true,"subway":false,"tram":false,"bus":false,"ferry":false,"express":false,"regional":false}}, "when":"2017-12-08T07:36:00+01:00", "direction":"S Wannsee", "line":{"type":"line","name":"S1","class":1,"productCode":0,"productName":"S-7","product":"suburban","mode":"train","public":true,"id":"s1","symbol":"S","nr":1,"metro":false,"express":false,"night":false}, "remarks":[{"type":"A","code":"bf","prio":2,"icoX":3,"txtN":"barrier-free"},{"type":"A","code":"FB","prio":350,"icoX":6,"txtN":"Bicycle conveyance"}], "trip":40079, "delay":60},

Is the new "cancelled" key only available when a trip is cancelled?

@derhuerst
Copy link
Owner

Is the new cancelled key only available when a trip is cancelled?

Yup. Wasn't sure what's the best way to specify this. Because there are many keys that are not being used all the time, I implemented cancelled in the same way. If the field exists and is true, the journey (part) has been cancelled.

@hildwin
Copy link
Author

hildwin commented Dec 8, 2017

IMHO: I think that is an important information for everyone. One should be able to see it at a glance. I strongly suggest to show the key all the time. Furthemore I found nothing in the API Docs. Did I miss something? As you said, there are only a few cancelled trips a day. It is (for me) quite challenging to test an application without it.

@derhuerst
Copy link
Owner

derhuerst commented Dec 8, 2017

Fair point! You're welcome do discuss this with us over at public-transport/friendly-public-transport-format#27

Regarding testing: Yeah, this is extremely annoying. I have the same problem all the time. Currently, my tests mainly check if the parsed response looks reasonable, but they can't tell if the values are actually correct. For now, I've refrained to mock the API for two reasons: a) It's significantly more work to constantly adapt the mock and b) because I don't test against the real API anymore, which might change underneath at any time.

@hildwin
Copy link
Author

hildwin commented Dec 8, 2017

Despite the general question I'm happy to discuss with you in the other thread, I've found a cancelled trip without the cancelled key:

Information auf mobile.bahn,de

S 85 >> Berlin-Waidmannslust
16:08 Fahrt fällt aus, Gl. 1

The API result is:

{"ref":"1|42484|5|86|8122017","station":{"type":"station","name":"S+U Wittenau","coordinates":{"latitude":52.596388,"longitude":13.335479},"id":"900000096101","products":{"suburban":true,"subway":false,"tram":false,"bus":false,"ferry":false,"express":false,"regional":false}},"when":"2017-12-08T16:08:00+01:00","direction":"S Waidmannslust","line":{"type":"line","name":"S85","class":1,"productCode":0,"productName":"S-5","product":"suburban","mode":"train","public":true,"id":"s85","symbol":"S","nr":85,"metro":false,"express":false,"night":false},"remarks":[{"type":"A","code":"bf","prio":2,"icoX":4,"txtN":"barrier-free"},{"type":"A","code":"FB","prio":350,"icoX":7,"txtN":"Bicycle conveyance"}],"trip":42484,"delay":null},

@derhuerst
Copy link
Owner

derhuerst commented Dec 8, 2017

Interesting. When I first loaded the departures page for S+U Wittenau (Wilhelmsruher Damm), there was an alert "Zug fällt aus". After I had reloaded, it said "Disruption" and only the details told me that there departure has been cancelled. And now, the page doesn't say anything about cancellations anymore.

Please check against the VBB website in the future, as bahn.de might give different data. Also, it would be really helpful for me if you gave me the URL you queried.

@hildwin
Copy link
Author

hildwin commented Dec 18, 2017

The departure from Wittenau at 07:32 this morning with line S26 was cancelled. The result from the API was:

{'station': {'products': {'tram': False, 'subway': False, 'regional': False, 'ferry': False, 'express': False, 'bus': False, 'suburban': True}, 'name': 'S+U Wittenau', 'type': 'station', 'id': '900000096101', 'coordinates': {'latitude': 52.596388, 'longitude': 13.335479}}, 'remarks': None, 'trip': 30311, 'when': '2017-12-18T07:32:00+01:00', 'direction': 'S Teltow Stadt', 'line': {'product': 'suburban', 'class': 1, 'type': 'line', 'public': True, 'night': False, 'express': False, 'productCode': 0, 'productName': 'S-5', 'metro': False, 'mode': 'train', 'id': 's26', 'symbol': 'S', 'name': 'S26', 'nr': 26}, 'ref': '1|30311|5|86|18122017', 'delay': None}

The VBB-Website shows the following:

07:32
Ausfall | S26 | S Teltow Stadt | Gleis 2  | Störung.: Der Zug fällt aus betrieblichen Gründen aus. (Letzte Aktualisierung 04:29)

The URL was

https://vbb.transport.rest/stations/900000096101/departures?nextStation=900000084101&results=3

@hildwin
Copy link
Author

hildwin commented Dec 18, 2017

Another answer from the API without the "cancelled trip" key:

{"ref":"1|30311|29|86|18122017","station":{"type":"station","name":"S+U Wittenau","coordinates":{"latitude":52.596388,"longitude":13.335479},"id":"900000096101","products":{"suburban":true,"subway":false,"tram":false,"bus":false,"ferry":false,"express":false,"regional":false}},"when":"2017-12-18T15:32:00+01:00","direction":"S Teltow Stadt","line":{"type":"line","name":"S26","class":1,"productCode":0,"productName":"S-5","product":"suburban","mode":"train","public":true,"id":"s26","symbol":"S","nr":26,"metro":false,"express":false,"night":false},"remarks":null,"trip":30311,"delay":null}

15:32  Ausfall | S26 | S Teltow Stadt Zwischenhalte | Gleis 2 | Störung.: Der Zug fällt aus betrieblichen Gründen aus. (Letzte Aktualisierung 14:33) via this site

s26-ausfall

@derhuerst
Copy link
Owner

Will look into this, thanks!

@derhuerst
Copy link
Owner

I had only added the cancelled flag to journey legs. 🙄 Added it to departures and passed stations now. Please check again.

@derhuerst
Copy link
Owner

I will close this for now. Please reopen if this issue still persists.

@derhuerst
Copy link
Owner

FYI the discussion has been taken further in #26 and then in public-transport/friendly-public-transport-format#27. Our decision:

  • Cancelled departures & arrivals will have null as value.
  • A cancelled: true flag will be exposed.
  • In formerScheduledWhen/formerScheduledDeparture/formerScheduledArrival, the previous scheduled (not realtime) value can be found.

@derhuerst
Copy link
Owner

This has been published as hafas-client@2.4.0. 🎉 Will update 2.vbb.transport.rest now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants