Skip to content

Commit

Permalink
✨ Locate nearby station with database as fallback (#3140)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
HerrLevin and dependabot[bot] authored Jan 13, 2025
1 parent 3797448 commit f27836a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
13 changes: 12 additions & 1 deletion app/Http/Controllers/API/v1/TransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,18 @@ public function getNextStationByCoordinates(Request $request): JsonResponse {
results: 1
)->first();
} catch (HafasException) {
return $this->sendError(__('messages.exception.generalHafas', [], 'en'), 503);
$upperLeft = [
'latitude' => $validated['latitude'] + 0.0015,
'longitude' => $validated['longitude'] + 0.0015
];
$lowerRight = [
'latitude' => $validated['latitude'] - 0.0015,
'longitude' => $validated['longitude'] - 0.0015
];

$nearestStation = Station::whereBetween('latitude', [$lowerRight['latitude'], $upperLeft['latitude']])
->whereBetween('longitude', [$lowerRight['longitude'], $upperLeft['longitude']])
->first();
}

if ($nearestStation === null) {
Expand Down
11 changes: 5 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.7.1",
"@vuepic/vue-datepicker": "^10.0.0",
"@vuepic/vue-datepicker": "^11.0.1",
"apexcharts": "^4.1.0",
"autoprefixer": "^10.4.20",
"awesomplete": "^1.1.5",
Expand Down

0 comments on commit f27836a

Please sign in to comment.