Combine arrival predictions of a tube and over-ground stoppoint


#1

I’m trying to make a live departure board for a station that has both a tube and an over-ground stoppoints.

This is how I subscribed to signalR’s arrival prediction hub for Kew Gardens station:

var lineRooms = [{ “LineId”: “district”, “NaptanId”: “940GZZLUKWG” }, { “LineId”: “london-overground”, “NaptanId”: “910GKEWGRDN” }];

But because it receives the data in separate parts, I can’t tell which stoppoint subscription is giving me the data when it is empty. Could somebody suggest the best way to create a live departure board using the Unified API? Or is it better to use National Rail’s Live Departure Boards Web Service?


#2

You may need to know that you can’t get live departures for stations that are a terminus from the unified API, because it doesn’t know about them, and you get poor data at stations close to the start as only running trains are shown in the arrivals data.

NRE Darwin has a push-port system which you can use to track everything and then self-filter for the stuff you want. The data part of the RESTful API has to-the-second arrival times which you can cache locally.

So, yes NRE Darwin will give you the most usable data for London Overground at Kew Gardens, because it loads up the working timetable into the data: a train at a terminus will show for the full route of the next part of it’s plan.

The solution

https://api.tfl.gov.uk/TrackerNet/PredictionDetailed/

Works for stations at or near terminus including the outgoing TUBE trains…

const CALLFORDETAILSINFO = "https://api.tfl.gov.uk/TrackerNet/PredictionDetailed/"; $strNewCall = self::CALLFORDETAILSINFO . "{$strTflLineFirstLetter}/{$this->strTFlThreeLetterStatioName}?" . disruptionViews::TFLAPISUFFIX;

The Line letter is the first one of the tube line name

        switch ($strPlace) {
        case "LST":
            $tflStationInfo = new tflStationInfo($strPlace);_
            $tflStationInfo->makeView(false);_
            $arrShowInformation = $tflStationInfo->showFilteredTubeDataForDisruption();_
            break;
        case "PAD":
            $TrackerNetPredictionDetailedFromTfl->getDataFor("H");
                    $TrackerNetPredictionDetailedFromTfl->getDataFor("B");
                    $TrackerNetPredictionDetailedFromTfl->getDataFor("D");
            break;
        case "EAL":
            $TrackerNetPredictionDetailedFromTfl->getDataFor("C");
            $TrackerNetPredictionDetailedFromTfl->getDataFor("D");
            break;
        case "HXX":
        case "HAF":
        case "HWV":
            $TrackerNetPredictionDetailedFromTfl->getDataFor("P");
            break;
        case "SRA":
            $TrackerNetPredictionDetailedFromTfl->getDataFor("C");
            $TrackerNetPredictionDetailedFromTfl->getDataFor("J");
            break;
        default:
    }

Also, you will need to use TFL’s three-letter codes not the NRE three letter codes

    private $arrConvert = ["SRA" => "SFD", "HWV" => "HR5", "HAF" => "HTF", "HXX" => "HRC", "EAL" => "EBY",
    "ZWL" => "WCL", "ZCZ" => "CWF",];

#3

TFL station codes are

    public static function getTFLcodes()
{
    return [
        'BST' => 'Baker Street',
        'CHX' => 'Charing Cross',
        'ERB' => 'Edgware Road (Bakerloo)',
        'ELE' => 'Elephant & Castle (Underground)',
        'EMB' => 'Embankment',
        'HSD' => 'Harlesden',
        'HAW' => 'Harrow & Wealdstone',
        'KGN' => 'Kensal Green',
        'KNT' => 'Kenton',
        'KPK' => 'Kilburn Park',
        'LAM' => 'Lambeth North',
        'MDV' => 'Maida Vale',
        'MYB' => 'Marylebone',
        'NWM' => 'North Wembley',
        'OXC' => 'Oxford Circus',
        'PAD' => 'Paddington',
        'PIC' => 'Piccadilly Circus',
        'QPK' => 'Queens Park',
        'RPK' => 'Regents Park',
        'SKT' => 'South Kenton',
        'SPK' => 'Stonebridge Park',
        'WAR' => 'Warwick Avenue',
        'WLO' => 'Waterloo',
        'WEM' => 'Wembley Central',
        'WJN' => 'Willesden Junction',
        'BNK' => 'Bank',
        'BDE' => 'Barkingside',
        'BNG' => 'Bethnal Green',
        'BDS' => 'Bond Street',
        'BHL' => 'Buckhurst Hill',
        'CYL' => 'Chancery Lane',
        'CHG' => 'Chigwell',
        'DEB' => 'Debden',
        'EBY' => 'Ealing Broadway',
        'EAC' => 'East Acton',
        'EPP' => 'Epping',
        'FLP' => 'Fairlop',
        'GHL' => 'Gants Hill',
        'GRH' => 'Grange Hill',
        'GFD' => 'Greenford',
        'HAI' => 'Hainault',
        'HLN' => 'Hanger Lane',
        'HOL' => 'Holborn',
        'HPK' => 'Holland Park',
        'LAN' => 'Lancaster Gate',
        'LEY' => 'Leyton',
        'LYS' => 'Leytonstone',
        'LST' => 'Liverpool Street',
        'LTN' => 'Loughton',
        'MAR' => 'Marble Arch',
        'MLE' => 'Mile End',
        'NEP' => 'Newbury Park',
        'NAC' => 'North Acton',
        'NHT' => 'Northolt',
        'NHG' => 'Notting Hill Gate',
        'PER' => 'Perivale',
        'QWY' => 'Queensway',
        'RED' => 'Redbridge',
        'ROD' => 'Roding Valley',
        'RUG' => 'Ruislip Gardens',
        'SBC' => 'Shepherd\'s Bush',
        'SNB' => 'Snaresbrook',
        'SRP' => 'South Ruislip',
        'SWF' => 'South Woodford',
        'STP' => 'St Pauls',
        'SFD' => 'Stratford',
        'THB' => 'Theydon Bois',
        'TCR' => 'Tottenham Court Road',
        'WAN' => 'Wanstead',
        'WAC' => 'West Acton',
        'WRP' => 'West Ruislip',
        'WCT' => 'White City',
        'WFD' => 'Woodford',
        'ACT' => 'Acton Town',
        'ALE' => 'Aldgate East',
        'BKG' => 'Barking',
        'BCT' => 'Barons Court',
        'BEC' => 'Becontree',
        'BLF' => 'Blackfriars',
        'BWR' => 'Bow Road',
        'BBB' => 'Bromley-by-Bow',
        'CST' => 'Cannon Street',
        'CHP' => 'Chiswick Park',
        'DGE' => 'Dagenham East',
        'DGH' => 'Dagenham Heathway',
        'ECM' => 'Ealing Common',
        'ECT' => 'Earls Court',
        'EHM' => 'East Ham',
        'EPY' => 'East Putney',
        'ERD' => 'Edgware Road (Circle)',
        'EPK' => 'Elm Park',
        'FBY' => 'Fulham Broadway',
        'GRD' => 'Gloucester Road',
        'GUN' => 'Gunnersbury',
        'HMD' => 'Hammersmith (District and Piccadilly)',
        'HST' => 'High Street Kensington',
        'HCH' => 'Hornchurch',
        'OLY' => 'Kensington Olympia',
        'KEW' => 'Kew Gardens',
        'MAN' => 'Mansion House',
        'MON' => 'Monument',
        'PGR' => 'Parsons Green',
        'PLW' => 'Plaistow',
        'PUT' => 'Putney Bridge',
        'RCP' => 'Ravenscourt Park',
        'RMD' => 'Richmond',
        'SSQ' => 'Sloane Square',
        'SKN' => 'South Kensington',
        'SFS' => 'Southfields',
        'SJP' => 'St Jamess Park',
        'STB' => 'Stamford Brook',
        'STG' => 'Stepney Green',
        'TEM' => 'Temple',
        'THL' => 'Tower Hill',
        'TGR' => 'Turnham Green',
        'UPM' => 'Upminster',
        'UPB' => 'Upminster Bridge',
        'UPY' => 'Upney',
        'UPK' => 'Upton Park',
        'VIC' => 'Victoria',
        'WBT' => 'West Brompton',
        'WHM' => 'West Ham',
        'WKN' => 'West Kensington',
        'WMS' => 'Westminster',
        'WCL' => 'Whitechapel',
        'WDN' => 'Wimbledon',
        'WMP' => 'Wimbledon Park',
        'ALD' => 'Aldgate',
        'BAR' => 'Barbican',
        'ESQ' => 'Euston Square',
        'FAR' => 'Farringdon',
        'GPS' => 'Great Portland Street',
        'HMS' => 'Hammersmith',
        'KXX' => 'Kings Cross',
        'MGT' => 'Moorgate',
        'BER' => 'Bermondsey',
        'CWR' => 'Canada Water',
        'CWF' => 'Canary Wharf',
        'CNT' => 'Canning Town',
        'CPK' => 'Canons Park',
        'DHL' => 'Dollis Hill',
        'FRD' => 'Finchley Road',
        'GPK' => 'Green Park',
        'KIL' => 'Kilburn',
        'KBY' => 'Kingsbury',
        'LON' => 'London Bridge',
        'NEA' => 'Neasden',
        'NGW' => 'North Greenwich',
        'QBY' => 'Queensbury',
        'SWK' => 'Southwark',
        'SJW' => 'St Johns Wood',
        'STA' => 'Stanmore',
        'SWC' => 'Swiss Cottage',
        'WPK' => 'Wembley Park',
        'WHD' => 'West Hampstead',
        'WLG' => 'Willesden Green',
        'AME' => 'Amersham',
        'CLF' => 'Chalfont & Latimer',
        'CWD' => 'Chorleywood',
        'CLW' => 'Colliers Wood',
        'CRX' => 'Croxley',
        'ETE' => 'Eastcote',
        'HOH' => 'Harrow-on-the-Hill',
        'HDN' => 'Hillingdon',
        'ICK' => 'Ickenham',
        'MPK' => 'Moor Park',
        'NHR' => 'North Harrow',
        'NWP' => 'Northwick Park',
        'NWD' => 'Northwood',
        'NWH' => 'Northwood Hills',
        'PIN' => 'Pinner',
        'RLN' => 'Rayners Lane',
        'RKY' => 'Rickmansworth',
        'RUI' => 'Ruislip',
        'RUM' => 'Ruislip Manor',
        'UXB' => 'Uxbridge',
        'WAT' => 'Watford',
        'WHR' => 'West Harrow',
        'ANG' => 'Angel',
        'ARC' => 'Archway',
        'BAL' => 'Balham',
        'BPK' => 'Belsize Park',
        'BOR' => 'Borough',
        'BTX' => 'Brent Cross',
        'BUR' => 'Burnt Oak',
        'CTN' => 'Camden Town',
        'CHF' => 'Chalk Farm',
        'CPC' => 'Clapham Common',
        'CPN' => 'Clapham North',
        'CPS' => 'Clapham South',
        'COL' => 'Colindale',
        'EFY' => 'East Finchley',
        'EDG' => 'Edgware',
        'EUS' => 'Euston',
        'FYC' => 'Finchley Central',
        'GGR' => 'Golders Green',
        'GST' => 'Goodge Street',
        'HMP' => 'Hampstead',
        'HND' => 'Hendon Central',
        'HBT' => 'High Barnet',
        'HIG' => 'Highgate',
        'KEN' => 'Kennington',
        'KTN' => 'Kentish Town',
        'LSQ' => 'Leicester Square',
        'MHE' => 'Mill Hill East',
        'MOR' => 'Morden',
        'MCR' => 'Mornington Crescent',
        'OLD' => 'Old Street',
        'OVL' => 'Oval',
        'SWM' => 'South Wimbledon',
        'STK' => 'Stockwell',
        'TBE' => 'Tooting Bec',
        'TBY' => 'Tooting Broadway',
        'TOT' => 'Totteridge & Whetstone',
        'TPK' => 'Tufnell Park',
        'WST' => 'Warren Street',
        'WFY' => 'West Finchley',
        'WSP' => 'Woodside Park',
        'ALP' => 'Alperton',
        'AGR' => 'Arnos Grove',
        'ARL' => 'Arsenal',
        'BOS' => 'Boston Manor',
        'BGR' => 'Bounds Green',
        'CRD' => 'Caledonian Road',
        'CFS' => 'Cockfosters',
        'COV' => 'Covent Garden',
        'FPK' => 'Finsbury Park',
        'HTX' => 'Hatton Cross',
        'HTF' => 'Heathrow Terminal 4',
        'HRV' => 'Heathrow Airport Terminal 5',
        'HRC' => 'Heathrow Airport Terminals 1, 2 and 3',
        'HRD' => 'Holloway Road',
        'HNC' => 'Hounslow Central',
        'HNE' => 'Hounslow East',
        'HNW' => 'Hounslow West',
        'HPC' => 'Hyde Park Corner',
        'KNB' => 'Knightsbridge',
        'MNR' => 'Manor House',
        'NEL' => 'North Ealing',
        'NFD' => 'Northfields',
        'OAK' => 'Oakwood',
        'OST' => 'Osterley',
        'PRY' => 'Park Royal',
        'RSQ' => 'Russell Square',
        'SEL' => 'South Ealing',
        'SHR' => 'South Harrow',
        'SGT' => 'Southgate',
        'SHL' => 'Sudbury Hill',
        'STN' => 'Sudbury Town',
        'TPL' => 'Turnpike Lane',
        'WGN' => 'Wood Green',
        'BHR' => 'Blackhorse Road',
        'BRX' => 'Brixton',
        'HBY' => 'Highbury & Islington',
        'PIM' => 'Pimlico',
        'SVS' => 'Seven Sisters',
        'TTH' => 'Tottenham Hale',
        'VUX' => 'Vauxhall',
        'WAL' => 'Walthamstow Central',
    ];

#4

Thank you for the detailed reply. I’ll take some time to look into this, TrackerNet is something new to me and I’m glad you mentioned it too, I would have been spending too much time focusing on the wrong data.

This is a great starting point. I am glad to understand more about this API!