Journey Planner

Hi, I am confused that how do I get Cardinal directions (Eastbound, Westbound, etc) in API responses for the Journey endpoint?

@haristauqir

Welcome.

You use the longitude to work out the direction…

    public function getEastOrWest($strFirstTLA = "LST", $strSecondTLA = "SRA")
{
    $strSQL = "SELECT if(fpEasting<(SELECT fpEasting FROM tblStaticLocations WHERE strTLA='{$strFirstTLA}'), 'Westbound','Eastbound') as strEastOrWest FROM `tblStaticLocations` WHERE strTLA='{$strSecondTLA}'";
    return $this->getOne($strSQL, "strEastOrWest");

You can use ATAN2 to get the “compass” direction from two co-ords

		$dir_angle = atan2(($y0 - $y1), ($x0 - $x1));

Hi @briantist,

Thank you.

You have shared a code which has a function to calculate the directions based on co-ordinates. Is there any API which gives me this information just by passing the tube station names.

For ex: I get all the journey information from Journey Planner API by passing ‘from’ and ‘to’ parameters. I just want to show the directions with the the lines. Central (EastBound), Piccadilly (WestBound)

@haristauqir

Sorry, no. It’s rather assumed that if you can do API programming that you can manage a little maths.

@briantist

Your assumption is right. Unfortunately, API documentation isn’t explanatory about it but I got it now.

Cheers

1 Like

And having calculated that the difference is northbound or southbound, it’s likely that you’ll arrive at a platform sign that gives you only a choice eastbound or westbound – because on many routes, the answer depends whether you calculate it for only the next stop or for the end of the line. And often you’ll find there’s no map at that point, and frequently still no map until you arrive at the wrongly guessed platform.

Properly implemented, the journey planner API should at every step:

  • be saying “Victoria Line, Eastbound” or whatever
  • when the next step is by bus or train, confirm the possible termination destinations (eg "towards Seven Sisters or Walthamstow). The journey planner always did when first implemented, until somebody messed it up with a negative improvement that supposedly improved the visual appearance but made it very much more difficult to use in practice.
  • when changing from train to bus, should say “leave by exit 4 and turn right” because nobody ever knows which way they are facing when they come up from the underground.

But don’t hold your breath. Taking into account we’ve never had even so much as a progress report on actually implementing freedom pass journeys, which were requested more than 3 years ago, it’s going to be at least four years before anybody even starts work on any of the above.

@harry

It’s worth remembering that local signs may never actually tell you the real direction. To travel from due east from Euston to King’s Cross, it’s Southbound on the Northern Line but Northbound on the Victoria Line. Or, walk westwards to Euston Square station. :smiley:

All Victoria Line trains run the length of the line (as drivers “step back” at each end) so there are no longer any Seven Sisters trains to get muddled up by,.

That’s all the more reason why the journey planner API needs to include statements that say exactly what the signs say, even when the signs are wrong :grinning:

And although are certainly less trains terminating at Seven Sisters than there used to be, some still do – because that’s the last station before the depot. Presumably it happens at the end of the peak period, if that particular train is going out of service rather than making a return journey.

But Victoria line was probably a bad example, because it doesn’t have branches. It’s lines with branches and platforms which serve more than one line where it’s particularly important to know from what it says on the front of the train whether it’s an appropriate train to take.

@harry

I must admit that I did get a bit confused at Acton Town a week or so ago. It’s not very clear, at platform level, if the station is divided by direction, or divided by service. I was going from South Harrow to Northfields and it wasn’t very clear, when you get off the central-London bound Piccadilly Line train if you need to go up and down the stairs, or just cross the platform.

And the answer is: even Carto Metro is unclear. .