Compare commits
2 commits
802c9398d5
...
c55d572ec4
Author | SHA1 | Date | |
---|---|---|---|
c55d572ec4 | |||
87a0d95435 |
3 changed files with 53 additions and 6 deletions
|
@ -29,10 +29,7 @@ class Kernel extends ConsoleKernel
|
|||
});
|
||||
|
||||
$schedule->command('digest:send --fortnightly')
|
||||
->weeklyOn(5, '00:01')
|
||||
->when(function () {
|
||||
return (time() / 604800 % 2);
|
||||
})
|
||||
->twiceMonthly(1,16,'13:00')
|
||||
->onFailure(function () {
|
||||
Log::error("Fortnightly email digest send failed");
|
||||
});
|
||||
|
|
|
@ -141,7 +141,7 @@ class TrackerController extends Controller
|
|||
|
||||
$client = new Client([
|
||||
'base_uri' => 'https://app.wayward.travel/',
|
||||
'timeout' => 10.0
|
||||
'timeout' => 20.0
|
||||
]);
|
||||
$response = $client->get('trip/'.($tripId ?? config('app.current_trip_id')).'/user/zmld8ko6qy7d9j3xvq10/json');
|
||||
|
||||
|
@ -173,10 +173,60 @@ class TrackerController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$data->trip->locations = $this->decode_polyline($data->trip->route);
|
||||
|
||||
return $data->trip;
|
||||
default:
|
||||
// TODO: Add proper error handling.
|
||||
return "Something went wrong";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode route polyline.
|
||||
*
|
||||
* Source: https://github.com/dyaaj/polyline-encoder
|
||||
*
|
||||
* @param object $value
|
||||
* @return object
|
||||
*/
|
||||
public function decode_polyline($value)
|
||||
{
|
||||
$index = 0;
|
||||
$points = array();
|
||||
$lat = 0;
|
||||
$lng = 0;
|
||||
$id = 0;
|
||||
|
||||
while ($index < strlen($value)) {
|
||||
$b;
|
||||
$shift = 0;
|
||||
$result = 0;
|
||||
do {
|
||||
$b = ord(substr($value, $index++, 1)) - 63;
|
||||
$result |= ($b & 0x1f) << $shift;
|
||||
$shift += 5;
|
||||
} while ($b > 31);
|
||||
$dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1));
|
||||
$lat += $dlat;
|
||||
|
||||
$shift = 0;
|
||||
$result = 0;
|
||||
do {
|
||||
$b = ord(substr($value, $index++, 1)) - 63;
|
||||
$result |= ($b & 0x1f) << $shift;
|
||||
$shift += 5;
|
||||
} while ($b > 31);
|
||||
$dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1));
|
||||
$lng += $dlng;
|
||||
|
||||
array_push($points, (object)[
|
||||
'id' => $id++,
|
||||
'latitude' => $lat/100000,
|
||||
'longitude'=> $lng/100000
|
||||
]);
|
||||
}
|
||||
|
||||
return $points;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
var routePoints = L.polyline([
|
||||
@foreach($trip->locations as $location)
|
||||
@if(!in_array($location->id, config('app.current_trip_ignore')))
|
||||
[{{ $location->latitude }}, {{ $location->longitude }}],
|
||||
[{{ $location->latitude }}, {{ $location->longitude }}], // {{$location->id}}
|
||||
@endif
|
||||
@endforeach
|
||||
], {
|
||||
|
|
Loading…
Reference in a new issue