BUG: Trackernet wrong data for train

The trackernet feed for the jubilee line
Jubilee Line

Train 331 is shown a number of times but as well as it’s actual location it also seems to be stuck showing duplicated as “out of service”

Reports are that it’s been that way for a while.

@ryan.forsyth

When I use Trackernet to display data, I find that it’s often necessary to pick out the best lines and filter out those that don’t make sense. This is especially true of terminal stations.

In the example you have I only allow the code to pick up one train ID per read of the data, but I would also reject the one that’s out of service.

My PHP code runs like this

        $arrUsedTrainIDs = [];
       foreach ($element->S->P as $P) {
                if (isset($P->T)) {
                    foreach ($P->T as $T) {
                        $this->setTrainsIntoData($T, $WhenCreated, $strLineName, $P, $arrUsedTrainIDs);
                    }
                } else {
                    if (isset($element->S->P->T)) {
                        foreach ($element->S->P->T as $T) {
                            $this->setTrainsIntoData($T, $WhenCreated, $strLineName, $element->S->P, $arrUsedTrainIDs);

                        }
                    }

                }
            }

Then

private function setTrainsIntoData(&$T, &$WhenCreated, &$strLineName, &$P, &$arrUsedTrainIDs)
{
    $atttribute = (self::extractAttributs($T));
    $strNote = "";
    $strTime = "";


    if (isset($atttribute)) {
        if (isset($atttribute->DepartTime)) { 
            $strTime = $atttribute->DepartTime;
            $strNote = "using DepartTime ";
        }
        if (isset($atttribute->SecondsTo)) {
            $strTime = date("H:i:s", strtotime($WhenCreated) + $atttribute->SecondsTo);
            $strNote = "using SecondsTo " . $atttribute->SecondsTo;
        }
        $strDestination = "";
        if (isset($atttribute->Destination)) {
            $strDestination = $atttribute->Destination;
        }
        $arrSplitPlatform = [0 => "", 1 => self::extractAttributs($P)->Num];
        $strLocation = "";
        if (isset($atttribute->Location)) {
            $strLocation = $atttribute->Location;
        }
        if (isset($atttribute->TrainId)) {
            $strNote = "TrainId" . $atttribute->TrainId;
            if (true) {
                $strLineName = strtr($strLineName, ["Circle, " => ""]);
                $strKey = $strTime . "_" . $arrSplitPlatform[1];
                if (!isset($arrUsedTrainIDs[$atttribute->TrainId])) {
                    $this->arrOut[$strKey] = ["Due" => PrettyDateTimeFormats::makeFormatCorrect($strTime, $strTime),
                        "All stops to" => $strDestination . html::div($strDoesThisStop, "notCallingAt"),
                        "Platform" => self::platform($arrSplitPlatform[1]),
                        "Headcode" => html::span($strLineName, strtolower($strLineName) . " displayblock"),
                        "Status" => $strLocation]; //  "," . $strNote . "," . $strKey
                }
                $arrUsedTrainIDs[$atttribute->TrainId] = $atttribute->TrainId;
            }
        }
    }
}

Yeah I do the same only pick up it’s first instance. However sometimes I will need to know when a train is out of service as I’m a train driver. So can’t disregard it as your example.
The data is clearly wrong and hopefully someone from TfL can amend it.

@ryan.forsyth

Let’s ask @jamesevans to confirm, but as far as I know the trackernet system is an “as is” system. It is up to the developer to interpret the results. The documentation for the system - http://content.tfl.gov.uk/trackernet-data-services-guide-beta.pdf - is all there is an it’s not 100% right (some station codes are wrong).

The idea is that the new Unified API should be used - https://api.tfl.gov.uk/StopPoint/490005183E/arrivals - but it has a big flaw in that it doesn’t work at terminals of the lines.

It interesting to find out-of-service trains. I’m always working with customer services so I need to filter these out.

But yes, the general principle of GIGO applies, so I’m not sure if an out of service marker, as you have shown, overrides the in-service detail.

I’m not sure your expectation of TfL changing the output is likely to be met.

1 Like

There’s your “out of service” train 331. It looks to me like it’s been reversed into the depot at Neasden some time ago but TrackerNet hasn’t ‘disappeared’ it properly, and is continuing to add it to southbound arrival lists downstream.

1 Like