Skip to content

Commit f27836a

Browse files
✨ Locate nearby station with database as fallback (#3140)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 3797448 commit f27836a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

app/Http/Controllers/API/v1/TransportController.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,18 @@ public function getNextStationByCoordinates(Request $request): JsonResponse {
319319
results: 1
320320
)->first();
321321
} catch (HafasException) {
322-
return $this->sendError(__('messages.exception.generalHafas', [], 'en'), 503);
322+
$upperLeft = [
323+
'latitude' => $validated['latitude'] + 0.0015,
324+
'longitude' => $validated['longitude'] + 0.0015
325+
];
326+
$lowerRight = [
327+
'latitude' => $validated['latitude'] - 0.0015,
328+
'longitude' => $validated['longitude'] - 0.0015
329+
];
330+
331+
$nearestStation = Station::whereBetween('latitude', [$lowerRight['latitude'], $upperLeft['latitude']])
332+
->whereBetween('longitude', [$lowerRight['longitude'], $upperLeft['longitude']])
333+
->first();
323334
}
324335

325336
if ($nearestStation === null) {

package-lock.json

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@fortawesome/fontawesome-free": "^6.7.1",
24-
"@vuepic/vue-datepicker": "^10.0.0",
24+
"@vuepic/vue-datepicker": "^11.0.1",
2525
"apexcharts": "^4.1.0",
2626
"autoprefixer": "^10.4.20",
2727
"awesomplete": "^1.1.5",

0 commit comments

Comments
 (0)