leoetlino / ratp-api

A modern API to get information from the RATP
GNU Affero General Public License v3.0
13 stars 4 forks source link

Output a GTFS-RT feed of the network #1

Open kalon33 opened 8 years ago

kalon33 commented 8 years ago

As this is a big leak of the current RATP feeds and API to be able to use the real time data in OpenTripPlanner and soon Navitia (and many other apps), being able to produce a GTFS-RT feed from the API would be awesome to make RATP Opendata really useful.

leoetlino commented 8 years ago

This does sound quite useful! Unfortunately, I'm not familiar with GTFS-RT feeds and don't have an idea on how to implement them, but I'll be happy to get a pull request merged.

kalon33 commented 8 years ago

Just to give you an overview of it: https://developers.google.com/transit/gtfs-realtime/?hl=en .

Basically, it's a structured feed that contains all vehicle RT positions on all lines at a given time, plus service outages and so.

leoetlino commented 8 years ago

I did have a look at the Google Developers docs on GTFS-RT yesterday -- while service outages should be easy to implement, vehicle positions are a bit more difficult to add, since we would need the latitude and the longitude of the current trains/busses, which the remote API doesn't provide.

kalon33 commented 8 years ago

Maybe we could start by placing a given vehicle at the stop, and update its position at each stop (when it arrives at this stop), as stop positions (long. and lat.) are properly defined in GTFS. It is an approximative approach, but should give nice initial info to work with. Then, after implementing that, we could enhance this by extrapolating positions between stops on the straight line that links the previous and the next stop, depending on the needed timing between stops, and the next vehicle waiting time at the next stop. For example, when 3 minutes are needed between two stops, and 1 minute is the next vehicle waiting time at the next stop, we could extrapolate the vehicle position at the two thirds of the straight line between the previous and the next stops. This is a better approximation, without the need to calculate this kind of things on the line's shapes files, which would be harder on lines that are not straight.

leoetlino commented 8 years ago

Right. Do you have a database which contains all stations on a line, ordered, and with an approximate number of minutes needed between stops? As you might have realised, the DB station table doesn't have the stations ordered (it actually has a x and y field but I'm unsure as to what they are), and it does not have the number of minutes between stations.

leoetlino commented 8 years ago

The RATP actually has released GTFS feeds, so maybe we could complete those feeds with our real-time info.

kalon33 commented 8 years ago

That's my point. It would be very nice to complete those GTFS feeds with real-time info as it can be significantly different than only theorical info.

leoetlino commented 8 years ago

After 2 months of looking at the data returned by the RATP's internal real-time API (and spending time commuting), I've found that even those can sometimes be quite different from the "real" situation (what actually happens in real life), and very often the train arrives one minute early or one minute later. Also, new train stops sometimes get added just all of a sudden.

It is just hard to match the real-time info with the theoretical info, especially when the real-time API returns no identifier for the trains (or vehicles if you prefer).

If you have a solution for this, I'd love to hear it. Otherwise, this is simply hard, if not impossible to do well.

kalon33 commented 7 years ago

@leoetlino I worked on that GTFS-RT feed these days, but on the trip-updates point of view. Without identifier for the vehicles, you could use theorical departure/arrival time. And without it, you could make a fuzzy matching, matching vehicle to theorical trip_id using its current departure time, matching it to the nearest theorical departure time. That's what I do for some other STIF real time data (from their beta real time API), but in that API RATP vehicles are not specification compliant at all, so I can't use them for now. That's why it would be great to have GTFS-RT using RATP API directly.