What does the value "ts_delta" represent in the zone transit data?


  By: edward on Oct. 20, 2017, 8:14 p.m.

What is the significance of the ts_delta value in the data?

Edward Leigh Smarter Cambridge Transport

 Last edited by: ijl20 on Nov. 1, 2017, 9:23 a.m., edited 1 time in total.

Re: ts_delta  

  By: ijl20 on Oct. 21, 2017, 11:17 a.m.

thanks - good question... I'll answer it within the broader context of calculations the Zone is doing in real-time:

TL;DR: ts_delta is the sum of the lengths in seconds of the entry vector and exit vector of the vehicle that successfully transited the Zone. It provides a particular 'confidence factor' (or the opposite) that enables you to mistrust some 'transit times' which rely on points that could be minutes apart due to probably missing intermediate points.

Each 'Zone' can be thought of as an independent agent that is tracking all vehicles for which we are receiving real-time data. Wrt image below, each 'Zone' has a defined arbitrary polygon with one specified 'Start' edge and another 'Finish' edge.

Each 'Vehicle' for these purposes can be though of as regularly sending its position in the form of { 'unique identifier', 'latitude', 'longitude', 'timestamp', 'other stuff that the Zone ignores' } Note that the 'timestamp' is the time the Vehicle associated with its position - our platform could receive this data a considerable time later, introducing the additional concepts of a 'received timestamp' and data 'latency'. Vehicles we are tracking are expected to transmit their location approximately every 30 seconds, and with the current data displayed on smartcambridge.org that data is collected and sent to us at a polling interval of every 30 seconds (so you can know what 'latency' might be considered 'normal'). There is significant work going on to both reduce the latency and improve the relevance of the 'other stuff' that is associated with the bus data.

The image below illustrates a Zone, with a single vehicle moving on the map. While a vehicle is 'outside' this zone, the agent remembers the timestamp and position of that particular vehicle, but that's all.

zone image for timestamp calculations

When the Zone's calculated state of a given vehicle changes from OUTSIDE the zone to INSIDE, e.g. as between points 'a' and 'b' in the diagram, the Zone:

  • Calculates a 'start time' for the vehicle, using a geometric calculation of what that would be assuming the bus moved at a constant speed between 'a' and 'b' (that's a slight improvement on simply using the timestamp at 'b').
  • Records the time difference between the points i.e. 'timestamp_b - timestamp_a' (this is in part a 'confidence factor' as it is easily possible that numerous data points have been missed between 'a' and 'b', possibly for hours). Let's call this the 'start time delta'
  • Tracks that vehicle to take note when it eventually leaves the zone

When the same vehicle (i.e. one which entered the Zone across the 'start' line) moves from INSIDE the zone to OUTSIDE, then the Zone does a similar calculation,

  • calculating a 'finish time' at an intersect with the finish line,
  • ignoring vehicles that have left the zone without crossing the finish line,
  • and recording the time difference between the points of the exit vector i.e. 'timestamp_n - timestamp_m' (let's call this the 'finish time delta')

If the vehicle entered the zone by crossing the start line, and exitted the zone by crossing the finish line, and a few basic error checks are passed, then the Zone generates a new message for a successful 'zone_completion'.

The time difference between the calculated start and finish times is reported as the duration.

The sum of the 'start time delta' and 'finish time delta' are reported in ts_delta.

 Last edited by: ijl20 on Oct. 21, 2017, 11:33 a.m., edited 2 times in total.