Skip to content

Commit f73ae81

Browse files
authored
🐛 Fix UK trains (#3142)
1 parent b213195 commit f73ae81

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

app/DataProviders/Bahn.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function getStationFromHalt(array $rawHalt) {
119119
//urgh, there is no lat/lon - extract it from id
120120
// example id: A=1@O=Druseltal, Kassel@X=9414484@Y=51301106@U=81@L=714800@
121121
$matches = [];
122-
preg_match('/@X=(\d+)@Y=(\d+)/', $rawHalt['id'], $matches);
122+
preg_match('/@X=(-?\d+)@Y=(-?\d+)/', $rawHalt['id'], $matches);
123123
$latitude = $matches[2] / 1000000;
124124
$longitude = $matches[1] / 1000000;
125125

@@ -205,18 +205,22 @@ public function getDepartures(
205205
$departureStation = $station;
206206
}
207207

208-
// Cache data used for trip creation since another endpoints do not provide them
209-
Cache::add($journeyId, [
210-
'category' => $hafasTravelType,
211-
'lineName' => $tripLineName
212-
], now()->addMinutes(30));
213-
214208
preg_match('/#ZE#(\d+)/', $journeyId, $matches);
215209
$journeyNumber = 0;
216210
if (count($matches) > 1) {
217211
$journeyNumber = $matches[1];
212+
213+
if (empty($tripLineName)) {
214+
$tripLineName = $matches[1];
215+
}
218216
}
219217

218+
// Cache data used for trip creation since another endpoints do not provide them
219+
Cache::add($journeyId, [
220+
'category' => $hafasTravelType,
221+
'lineName' => $tripLineName
222+
], now()->addMinutes(30));
223+
220224
$departure = new Departure(
221225
station: $departureStation,
222226
plannedDeparture: Carbon::parse($rawDeparture['zeit'], $timezone),

0 commit comments

Comments
 (0)