How do I uniquely identify a vehicle?


#1

I’m looking for a way to distinguish different vehicles from one another. On the face of it vehcileId looks like a good candidate. Buses’ IDs are based on registration plates, so guaranteed to be unique. River buses are simple as they’re quite lower integers which aren’t zero padded. DLR trains don’t have vehicleIds, so we can safely ignore them. But I’m having trouble handling tube trains. I made the silly assumption that they’d also be unique, but then I was displaying weird routes (like a train that goes from Hampstead to South Kengsington via Grange Hill)
Looking at the API call: https://api.tfl.gov.uk/Vehicle/017/Arrivals, I’m seeing northern, district and central line trains all mixed together there, which really isn’t any use at all.

Is there a better identifier I can use? Or do a have to mangle my own together, combining several different fields together? I’d really rather not do that - I don’t even know which combination of fields will guarantee uniqueness…


#2

Yes. This is an ongoing problem with terminal stations.


#3

I don’t think this is related to the terminal station issue. That one is due to the use of arrival times instead of departure times. My question is around identifying vehicles, and occurs regardless of how far along the route they’ve travelled.


#4

Luke,

The only uniquely identifiable vehicles are the buses (inc. boats) and trams.

What you are seeing for the Underground are the ‘set’ numbers which identify what trips that train should make on that day on that line as opposed to vehicle numbers. That’s why you are seeing multiple of the same ‘vehicle’ on different lines.

Maybe @davidtan or his colleagues could arrange for the documentation at https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Vehicle/Vehicle_Get to be updated to clarify this?

Simon


#5

As an aside, I can think of a few users who would like the running number (the equivalent of the set number) to be visible for buses. I don’t think it is now.

It does seem strange that one field appears to be used for quite different purposes, depending on mode.


#6

It only seems strange if you’re new to the “unified” API. :wink:
The more I use it, the more I realise it’s actually a handful of different APIs (combined with data screenscrapped from the DLR website) and that my dream of a mode-neutral implementation is a long way off…