-
Notifications
You must be signed in to change notification settings - Fork 4
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
How to show all active trains in Berlin on a map? #9
Comments
When I played around with it initially, I thought I might be able to use the Open API playground to go through the whole scenario, but I was not really successful at getting any information out of it without first knowing what to look for. My thought was something along the lines of:
This could be done effeciently by only doing 1. and 2. once on my side (maybe updating it every month or so, whenever the lines change). And after playing around more, I am easily able to get the IDs from the
This already seems ideal. About the shapes I will have to see because I also saw https://github.com/derhuerst/vbb-shapes and I am not currently sure how it is connected. And the realtime fetching is likely the biggest question - also how that works with the 100 request per minutes rate limit. Edit: so I just realized that shapes are actually not connected to lines but to trips (https://github.com/derhuerst/vbb-trips). Thinking about it, this makes a lot of sense. But I guess it shows that it does make sense to ask this question to get a wholistic idea of how to best solve this before attempting to do it myself and struggling for too long :) |
Note that, as of fall 2021, these are not actual measured realtime positions; The positions are estimated (in a really dumb way, someone should improve upon this!) based on the realtime delay of the trip. So there's sone truth to that, but it's far from being as accurate as e.g. in Finland. Someone told me that the BVG buses only send a ping whenever they stop at a stop/station, so the current delay is a (very dumb, someone should improve upon this!) estimation. I assume, but don't know, that for trains, the backend system knows at least the track section it's in and uses that.
As you noted below, a line usually has >1 shape, for several reasons:
So it's up to you:
Correct!
Yes, the latter helps you in a significant way: It is designed to always give you the position of all trips within the Berlin area at once. It is in the GTFS-Realtime format, which is intended to answer "Which vehicles/trips are running in the network right now?". With the former, you'd have to determine this by yourself:
The software behind
The best way to go depends on
|
What is it that you would have needed? A guide like this one, bit focused on the "what is running right now and where?" use case?
That's the one you're looking for! Underneath, its exactly what the VBB app does in your screenshot, and it's also what
Now that I've thought about it, going entirely with static/plan data as the base is also an option. In this case,
vbb-shapes is built from the official static/plan data, but I think it's a bit outdated. |
@derhuerst After thinking about it, the using the static shapes might be the less fragile and more efficient way of doing things, but if I understand the shapes API correctly, it should be way easier for me to poll each shape for every trip. Now, I am just slightly worried it will get very messy. But I will see about that. Thanks a lot for the estimation insights! That is super useful. Since I am only doing trains for now, I hope that they will be accurate enough to be able to work with them. But I think the only way to really test that is actually going outside and trying it :) I will stick with Berlin for now - not because that is the ultimate goal, but because it seems like the only reasonable choice from a project management perspective ;) |
Which shapes API are you referring to here? The Since both of these use the static/plan (GTFS) data's shape IDs anyways, and since I likely didn't update both to the latest static/plan (GTFS) dataset, it's probably best for you right now to use Sorry for the confusion, there are just too many half-maintained projects. 😅 |
@derhuerst Okay - I see. So the shapes are not pulled live according to e.g. current construction sites but static and need to be updated manually? |
All of these work with static shapes so they, while being trip-specific, only take planned construction work into account. If you want "realtime shapes", use the shapes returned by |
Just stumbled upon another project that visualises GTFS Static data (and claims to ingest GTFS Realtime too) on a live map: https://github.com/vasile/transit-map |
@derhuerst That looks awesome! Do they use the same data structure (given that it is not for Germany)? |
There are GTFS (-Static) datasets for Berlin, Germany & Switzerland; All 3 datasets have the same structure & semantics, given that they follow the same spec (they might have a different level of details, and make use of different parts of GTFS, but the shapes part should be compatible). So, yes, if you build a GTFS-based (optionally GTFS-Realtime support) solution, it will work for all regions where there's a GTFS (-Static) feed (and optionally a GTFS-Realtime feed) available. |
Description
What I want to do essentially is find out both where all trains (U-Bahn, S-Bahn, & Tram) are currently located and ideally also know all of the shapes of the train lines.
I do not care about regional trains and busses for now (although I would assume they would not differ much).
Examples
I found this view in the VBB app that pretty much fulfills the first of the criteria (i.e. knowing the current location of all active trains in Berlin):
It updates the position of all trains in realtime (and also shows the direction they are heading in).
I would ideally want to combine that with the line map in order to get all of the shapes of the train lines:
APIs to use
It seems that this should be possible with the
transport.rest
APIs (given this is possible in the DB / VBB apps).Initially, I thought I would have to handle U-Bahn & Tram separately from the S-Bahn (since the S is DB-operated and the U & Tram are BVG-operated). However, given that the VBB app seems to have all of the information, I am thinking I might be able to use just
https://v5.vbb.transport.rest/
instead ofhttps://v5.bvg.transport.rest/
andhttps://v5.db.transport.rest/
separately.I have not yet explored the APIs enough to make an informed decision here and it does seem overwhelming to me as well. I also do not know if
https://v0.berlin-gtfs-rt.transport.rest/
would be any use to me.@derhuerst do you have insights on how to break down this problem to figure out how to (best) do this?
The text was updated successfully, but these errors were encountered: