Public Transit Schedule Encoding

The VeryFurryFerryFairy in action

For want of a schedule API from the Amsterdam public transit authority GVB, I came up with a simple encoding for one schedule, which is a combination of stop, route and direction. For example, to describe the entire ferry schedulefor Amsterdam Central Station to Buiksloterweg, you would need two endoded schedule objects (ESOs):

  1. From Centraal Station to Buiksloterweg
  2. From Buiksloterweg to Centraal Station

For a route with more than two stops, you would need one ESO per stop and direction.

The ESO for Centraal Station to Buiksloterweg looks like this:


This is an array that consists of:

  • One object for every schedule (Sunday and weekdays in this example)
  • One string describing the route

The objects describing the schedule  themselves consist of  a few parts:

  • Exacly one day scope identifier, which is a string of length 7 and indicates the days on which that particular schedule is valid. A plus-sign says the schedule is valid for that day, a minus means invalid. The position in the string indicates the day, following the ECMA-262 standard where 0=Sunday, 1=Monday, etc.  The first schedule object in our example has “+——“, so this is a schedule for Sundays.
  • One or more interval arrays, consisting of exactly four non-negative integers. These indicate the start of a new schedule regime on the day(s) indicated by the day scope identifier, as follows:
    • The first integer indicates the hour on which this interval starts.
    • The second integerindicates the minute on which this interval starts.
    • The third integer indicates the second on which this interval starts.
    • The final integer indicates the ride frequency in seconds.

In our example, the first interval array reads [0,6,0,720], so the schedule for the ferry from Centraal Station to Buiksloterweg on Sundays starts at 12:06AM with an interval of 720 seconds or 12 minutes. It is superseded at 11:06AM with an interval of 360 seconds or 6 minutes. And so on.

There are some situations that are difficult to capture in the current setup, I am sure. I did not give this a whole lot of thought yet, and it serves my purposes for now. I would like to change the format to comply to the JSON standard that everyone is so hot on these days. Any other suggestions are welcome!

Take a look at the VFFF source code to see the full schedules for the ferries from and to Centraal Station.



      One thought on “Public Transit Schedule Encoding

      Comments are closed.