Current Location tube formatting

over the past couple days ive collected some data to understand better the API, when it comes to tube (not tested this on the other modes yet) there is a clear theme with how current location is presented with the main ones obviously being: At, Between, Aproaching, Left, Leaving. However ive spotted a number of current locations that seem irregular, if anyone could shed some light on any of these different types of current locations, and also if anyone knows of any other types of irregularities that current location can have that i have missed off please let me know as this is only a day or two worth of looking. They are as follows:

does departed and left (also departing and leaving) mean the same thing?

0: seemingly only on victoria line?

What is the North and South prefix for? its used even when the tube is approaching the next station from a different direction i.e. North if Queenā€™s Park, is it implied diection from route? and where do they fit in with the other states such as between, approaching, etc

What is meant by the area and Area postfix?

Finchley Central Platform 3: anyone know why this is returned next station can be several north northernline stations

In between Goldhawk Road and Hammersmith (also In between Wood Lane and Latimer Road): Is it only in these places In between is used over Between?

In the vicinity of Hammersmith Platform 3: weird response with this sometimes wood lane or latimeer road rather than goldhawk road

Kennington Loop: not sure on this

Lillie Bridge Depot and Stonebridge Park Depot: assuming just a depot for trains and not relevant to live service?

What is meant by the Siding and Sidings prefix and postfix?

What is meant by On P[some int] crossover / how many crossovers are there?

Queenā€™s Park Reversing Berth

WOO RD21

Woodford Junction

Any help appreciated! :slight_smile:

@fraser

Hereā€™s a valid but quite old ā€œRailway Junctions diagramā€ that shows the sidings and loops.

If no-one else can answer the rest of the questions, Iā€™ve been thought this recently and itā€™s a little complicated? Have you watched the ā€œSecrets of the Undergroundā€ show on the Yesterday Channel?

Hi, I donā€™t have answers to these questions as these fields come from a upstream system. That said, Iā€™d be interested in hearing what youā€™re trying to accomplish (as this may help us improve our open data offering). Are you trying to parse these strings? What information are you trying to get from them that isnā€™t available from the other fields?

Thanks for the diagrams! and Iā€™ve not but Iā€™ll be sure to check it out :slight_smile:

Iā€™m making a live map not too dissimilar to Live map of London Underground trains and initally thought that stationName and timeToStation would server the purpose of positioning but as sometimes stationName is not the next station the train will pass through, using currentLocation is most likely needed.
Do you know if the trains that have stationName not as the next station theyā€™ll pass through are just trains not in service and therefore should be ignored? If so is there any identifiers on those veichles to be able to filter them out? With regards to currentLocation I was usuing it mainly to identify if its either at a station or between two.
Any help would be appreciated

@fraser

Iā€™ve got a system which can show live line diagrams for tube departures, to match those we do for National Rail services. When it says ā€œCheck Front of Trainā€ it can even show complex multi-destination diagramsā€¦

So, the brief I have is to show the live locations of the tube trains, so that you can have ā€œconfidenceā€ that the line is running. The main problem at the moment is that as we normally show ā€œfrom this station to the end of the lineā€ the trains you can show here are ones that have already departed!

Anyway, I started with a cron job that collects all the line data in a single call (multi_curl) and stuff the results in a Postgres table and it doesnā€™t use many of my calls limit! This means I can separate the logic of the display from the data collection.

image

Looking at my code, Iā€™m not using the textual representation of the location. Instead Iā€™m mapping $item->vehicleId and $item->timestamp to work out the location for myself.

Iā€™m also decoding $item->timeToStation as this allows me to calculate the current (rather than data collected time).

I was just comparing my computations with the text to check it was working.

This task has been put on the back-burner for a while, but it looked like it was workingā€¦

You say that your cron job collects all the line data in a single call, currently the call i was planning on using was the mode call that returns all vehicles for that mode (in this case tube) that would work in the same way correct? Also thanks for the response just attempting to process all you wrote :sweat_smile:

Also not quite sure how that mapping of vehicleId and timestamp to location would work?

@fraser

The basis of the code to get everythingā€¦

  • public const URLTOCALL = ā€˜https://api.tfl.gov.uk/line/_____/arrivalsā€™;
  • $parallelApiCalls = new ParallelApiCalls();
  • foreach ($toDo as $strLineName => $strTrackernetCode) {
  • $filenames[$strLineName] = $parallelApiCalls->addURL($strURL);
  • }
  • $parallelApiCalls->multisynch();

Itā€™s more useful to have the data per line. Some lines are odd (the met has data for at least one non-served station in it)

Youā€™ll need to look at the data for vehicleId, timestamp and timeToStation to get it work. Just needs a bit of logic. :slightly_smiling_face:

1 Like