Real Time Data on Charlottetown Bus Locations

Charlottetown’s buses are now equipped with GPS devices that send real time location data to a server where it can be used by the ReadyPass transit app for iOS and Android.

There’s also a web version of the map, and, by looking under the hood of it, you can see that there’s a simple public API endpoint that provides the same real time location data.

To watch this for yourself, just open the web map in your browser, and open up the developer console, switch to the Network tab, and filter for XHR requests:

Screen shot of the developer console in Firefox while watching ReadyPass Charlottetown map

What you’ll see happening there is a regular call to get the position of the buses on the route you’ve selected, in the form:

http://charlottetown.readypass.ca/api/bus/route/ROUTE

For example:

http://charlottetown.readypass.ca/api/bus/route/1

The returns a JSON object with data for all of the buses currently on that route, like this:

[
  {
    "busNumber":"62",
    "routeNumber":"1",
    "lat":46.264949798583984,
    "long":-63.14606475830078,
    "cellStrength":0.017,
    "speed":0,
    "updateTime":"2018-05-03T20:47:10.342189124Z",
    "maxBump":0,
    "avgBump":0,
    "bumpSamples":0,
    "accuracy":100,
    "battery":255
  },
  {
    "busNumber":"60",
    "routeNumber":"1",
    "lat":46.239139556884766,
    "long":-63.13039779663086,
    "cellStrength":0.007,
    "speed":5.4,
    "updateTime":"2018-05-03T20:47:10.401472557Z",
    "maxBump":0,
    "avgBump":0,
    "bumpSamples":0,
    "accuracy":100,
    "battery":255
  }
]

So that tells us that, right now, there are two buses, #62 and #60, and they are at the latitude and longitude given. Also available, it seems, is the call strength of the data connection in the bus, its battery level and the accuracy of the position.

This is great data to have access to and, as has happened in other jurisdictions, will enable the creation of useful transit information services and data visualizations.

Comments