Skip to content

Commit

Permalink
🐛 Fix UK trains (#3142)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheubuch authored Jan 13, 2025
1 parent b213195 commit f73ae81
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/DataProviders/Bahn.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private function getStationFromHalt(array $rawHalt) {
//urgh, there is no lat/lon - extract it from id
// example id: A=1@O=Druseltal, Kassel@X=9414484@Y=51301106@U=81@L=714800@
$matches = [];
preg_match('/@X=(\d+)@Y=(\d+)/', $rawHalt['id'], $matches);
preg_match('/@X=(-?\d+)@Y=(-?\d+)/', $rawHalt['id'], $matches);
$latitude = $matches[2] / 1000000;
$longitude = $matches[1] / 1000000;

Expand Down Expand Up @@ -205,18 +205,22 @@ public function getDepartures(
$departureStation = $station;
}

// Cache data used for trip creation since another endpoints do not provide them
Cache::add($journeyId, [
'category' => $hafasTravelType,
'lineName' => $tripLineName
], now()->addMinutes(30));

preg_match('/#ZE#(\d+)/', $journeyId, $matches);
$journeyNumber = 0;
if (count($matches) > 1) {
$journeyNumber = $matches[1];

if (empty($tripLineName)) {
$tripLineName = $matches[1];
}
}

// Cache data used for trip creation since another endpoints do not provide them
Cache::add($journeyId, [
'category' => $hafasTravelType,
'lineName' => $tripLineName
], now()->addMinutes(30));

$departure = new Departure(
station: $departureStation,
plannedDeparture: Carbon::parse($rawDeparture['zeit'], $timezone),
Expand Down

0 comments on commit f73ae81

Please sign in to comment.