Hi, I am confused that how do I get Cardinal directions (Eastbound, Westbound, etc) in API responses for the Journey endpoint?
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)
Sorry, no. Itâs rather assumed that if you can do API programming that you can manage a little maths.
Your assumption is right. Unfortunately, API documentation isnât explanatory about it but I got it now.
Cheers
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.
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.
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
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.
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. .