Finding the middle station between two stations (in terms of time)

Hi!

I want to find the middle station (in terms of time) between two stations, I’m currently trying to use the Journey API to get the distance between two stations as a first step but I’m having trouble with that too.

Could anyone point me in the right direction? Is this available in the API? If not, how could I work it out?

Thanks

No idea how but just out of interest - what’s the purpose? Apart from helping to answer the question “Are we nearly there?”!

I can think of two approaches:

Using /Line/Route/Sequence, you could take the latitude/longitude for the two stops, work out the mid-point between them and then iterate through the stops in between to see which one is nearest to that point. It’s not exact as it assumes straight-line travel and a constant speed, but should give a reasonable approximation.

Alternatively you could look at /Line/Timetable and use stopInterval times to work out the nearest to a mid-journey point.

Welcome @russjohnhop

If you stuff the data from the route into a directed graph, the computation of time is a computationally simple matter.

Just use a sample timetable to work out the timings, or see the WTTs if you don’t mind doing them by hand (for a demo). Working Timetables (WTT) - Transport for London

image

Your question is easily answered by web UI and eyeball:

  • Select your start stop
  • Select route and direction
  • View route timetable
  • Select a time period to get a list of journey times in minutes
  • Note journey time to your end stop
  • Your answer is the stop with a journey time of about half.

I used bus stops as an example as I am familiar with it but tube stations are much the same.

If there is an API call to generate that listing one of the experts on here should be able to tell you what it is.

@misar @russjohnhop

The API is APIs: Details - Transport for London - API

so the above is found in the API as https://api.tfl.gov.uk/Line/northern/Timetable/940GZZLUCND?direction=inbound

@mjcarchive I’m putting together an app that helps set a meeting location in-between users, then does a bit more on top of that.

@nickp thanks! I’ll look into this

@misar thank you, this helps!

@briantist amazing thanks! This looks to be it.

Thanks everyone - this gives me a few options.

1 Like

@russjohnhop
Thanks for the reply. For me it would usually be a matter of what we want to do after meeting but I suppose it would minimise time if exchanging presents, or other unspecified merchandise!