|
@ -72,9 +72,9 @@ class Api extends BaseController |
|
|
} else { |
|
|
} else { |
|
|
#$record->date->format('U.u');
|
|
|
#$record->date->format('U.u');
|
|
|
// Ignore super inaccurate locations
|
|
|
// Ignore super inaccurate locations
|
|
|
if(!property_exists($record->data->properties, 'horizontal_accuracy') |
|
|
|
|
|
|
|
|
if(!property_exists($record->data->properties, 'horizontal_accuracy') |
|
|
|| $record->data->properties->horizontal_accuracy <= 5000) { |
|
|
|| $record->data->properties->horizontal_accuracy <= 5000) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$locations[] = $record->data; |
|
|
$locations[] = $record->data; |
|
|
$props = $record->data->properties; |
|
|
$props = $record->data->properties; |
|
|
$date = $record->date; |
|
|
$date = $record->date; |
|
@ -264,11 +264,23 @@ class Api extends BaseController |
|
|
$date = new DateTime($loc['properties']['timestamp']); |
|
|
$date = new DateTime($loc['properties']['timestamp']); |
|
|
|
|
|
|
|
|
if($date) { |
|
|
if($date) { |
|
|
$cacheKey = 'compass::'.$db->name.'::'.$date->format('U'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$shouldAdd = true; |
|
|
|
|
|
|
|
|
// Skip adding if the timestamp is already in the cache.
|
|
|
// Skip adding if the timestamp is already in the cache.
|
|
|
// Helps prevent writing duplicate data when the HTTP request is interrupted.
|
|
|
// Helps prevent writing duplicate data when the HTTP request is interrupted.
|
|
|
if(!env('CACHE_DRIVER') || !Cache::has($cacheKey)) { |
|
|
|
|
|
|
|
|
$cacheKey = 'compass::'.$db->name.'::'.$date->format('U'); |
|
|
|
|
|
if(env('CACHE_DRIVER') && Cache::has($cacheKey)) |
|
|
|
|
|
$shouldAdd = false; |
|
|
|
|
|
|
|
|
|
|
|
// Ignore points at 0,0
|
|
|
|
|
|
// Around November 2019, Overland on iOS started reporting 0,0 points pretty frequently, several
|
|
|
|
|
|
// times per day, and sometimes for a whole hour in a row. Not sure whether the
|
|
|
|
|
|
// real data from iOS was null,null or actually 0,0 but we'll ignore it here anyway
|
|
|
|
|
|
if($loc['geometry']['coordinates'][0] == 0 && $loc['geometry']['coordinates'][1] == 0) |
|
|
|
|
|
$shouldAdd = false; |
|
|
|
|
|
|
|
|
|
|
|
if($shouldAdd) { |
|
|
$num++; |
|
|
$num++; |
|
|
$qz->add($date, $loc); |
|
|
$qz->add($date, $loc); |
|
|
if(env('CACHE_DRIVER')) |
|
|
if(env('CACHE_DRIVER')) |
|
@ -303,8 +315,8 @@ class Api extends BaseController |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$response = [ |
|
|
$response = [ |
|
|
'result' => 'ok', |
|
|
|
|
|
'saved' => $num, |
|
|
|
|
|
|
|
|
'result' => 'ok', |
|
|
|
|
|
'saved' => $num, |
|
|
'trips' => $trips |
|
|
'trips' => $trips |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|