Journey Planner gives same results

I’ve noticed that I sometimes receive the same journey planner results.

For example, if I use the “Goodmayes, Goodmayes Station” to “Canary Wharf, Canary Wharf DLR Station” locations, I receive these results:

However, earlier on I was receiving 3 different results.

The code for this is below:

print(" ")
print("Starting Locations:")
for i in range(0,len(FromArray)):
    print(FromArray[i])
print(" ")
FromInput = input("Please enter the name of your chosen starting location exactly as shown above:")
print("Chosen location: " + FromInput)

print(" ")
print("Destination Locations:")
for i in range(0,len(ToArray)):
    print(ToArray[i])
print(" ")
ToInput = input("Please enter the name of your chosen destination location exactly as shown above:")
print("Chosen destination: " + ToInput)

for i in range(0,len(FromArray)):
    for j in range(0,len(ToArray)):
        if FromInput == FromArray[i] and ToInput == ToArray[j]:
            url = "https://api.tfl.gov.uk/journey/journeyresults/"+FromInput+"/to/"+ToInput+"?app_id="+pk+"&app_key="+sk # enter your own keys in a seperate file and import them here

try:
    response = requests.get(url)
except NameError:
        print("One or both of your location names were incorrect")
        sys.exit(1)

responseJson = response.json()

for i in range(0,10):
    try:
        selectedRoute = responseJson["journeys"][i]["legs"]
        print(" ")
        for detail in selectedRoute:
            print("From", detail["departurePoint"]["commonName"])
            print(detail["instruction"]["detailed"])
            print("Arrive at", detail["arrivalPoint"]["commonName"])
    except IndexError:
           pass

@Ari Welcome

I think if you printed the times on your output you might find that you’re getting different time options in the output.

Ah ok, I assume as it’s time sensitive that it’s going to pick the fastest route there? Even if that route is the same?

hi @Ari

Journey Planner will alway return the first 3 quickest options, which can be the same.

You can call the API with different parameters to get different results (i.e. mode-specific, walking parameters, step free etc).

Thanks,
James

1 Like

Two problems I’ve found, with particular searches:

  • by clicking the earlier or later links, JP will sometimes continue returning the same 3 journeys (without ever getting any earlier or later) unless you manually edit the arrival or departure time

  • and sometimes, especially when searching with an arrival time, JP will give 3 journeys that are all a long time (ie, more than 15 minutes) before the chosen time slot. Hence the need to click on later journeys, but this will often trigger the previous problem.

If this isn’t a known problem, I’ll keep a look out and post an example here when I next see it.

In part, the reason for both of our problems is that JP only gives a choice of the “fastest” or the “least changes” with only a few variations, such as Step Free.

Often, the requirements aren’t that simple:

  • maybe the traveller needs a mid journey interchange at a station with toilets
  • or which only uses trains that Freedom Passes are valid on (an important requirement we requested more than 5 years ago, but nobody has ever properly acknowledged)
  • or one that avoids Zone 1 (or, costs less for possibly other reasons)

So it might be useful to show 3 unique routes to compare, rather than 3 identical journeys at different times. And presumably JP must initially find all such routes in order to identify those which are fastest or have least changes, so it shouldn’t be impossible to filter the results to show unique journeys too.

Incidentally, it seems a bit daft that this forum lets you edit a post, but then says “forbidden” when you try to post the edit. So you then have to post it as a new message and delete the previous post. That’s not in itself a problem, but it would be more user-friendly to do that from the outset rather than being allowed to edit, but not post.