-
Notifications
You must be signed in to change notification settings - Fork 0
Public Transit Speed and Stop Timing Calibration
Using roughly 3-5 hard-coded pairs of locations (source and destination), the approximate speeds and stop times of buses, MRTs and LRTs can be obtained.
For each source-destination pair, a route using only a specific bus/train service is found using the Google Maps Directions API. The Directions API returns the number of stops, time taken to travel, distance traveled and a polyline descriptor which can be decoded to form a list of coordinates taken by the bus/train. This single set of variables - time taken, distance travelled and number of stops - only allow us to find the average speed of a bus/train and does not factor in stop times which are significant in trains.
To get another set of variables, the polyline can be used. A point along the polyline located at the 95% mark of the initial route can be used as the destination. A query can then be made to the Direction API from the source to this 2nd destination, ensuring the same service is used.
The mathematical calculation can be found here
If the API returns a route not using the same service, or there is no difference in number of stops taken (ie the same destination node was used), the destination can be changed to 90% of the initial route, decreasing the percentage in increments of 5% until 50%. After 50%, the variables are significantly smaller, making timings more volatile, hence, reducing precision.
The 3-5 data points found are then averaged to increase accuracy. In the event that mathematically invalid values are returned, default values retrieved from the config file are used.
Each type of service (bus, MRT and LRT) also has a speed factor obtained from application.yml
to account for trains using straight line distance rather than route distance to generate the graph.