Harden findmydevice GPS jitter filtering
This commit is contained in:
+10
-1
@@ -358,12 +358,19 @@ if ($historySets) {
|
||||
foreach ($historyData[0] as $item) {
|
||||
$lat = $item['attributes']['latitude'] ?? null;
|
||||
$lng = $item['attributes']['longitude'] ?? null;
|
||||
$accuracy = $item['attributes']['gps_accuracy'] ?? $item['attributes']['accuracy'] ?? null;
|
||||
$time = $item['last_changed'] ?? null;
|
||||
if ($lat && $lng && $time) {
|
||||
$timeKey = (string)(strtotime((string)$time) ?: $time);
|
||||
$key = $timeKey . ':' . round((float)$lat, 5) . ':' . round((float)$lng, 5);
|
||||
if (!isset($pathByKey[$key])) {
|
||||
$pathByKey[$key] = ['lat' => $lat, 'lng' => $lng, 'time' => $time, 'source' => $profile];
|
||||
$pathByKey[$key] = [
|
||||
'lat' => $lat,
|
||||
'lng' => $lng,
|
||||
'time' => $time,
|
||||
'accuracy' => is_numeric($accuracy) ? (float)$accuracy : null,
|
||||
'source' => $profile,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,6 +464,8 @@ function smoothPath(array $path): array
|
||||
'lat' => ((float)$prev['lat'] + ((float)$cur['lat'] * 2) + (float)$next['lat']) / 4,
|
||||
'lng' => ((float)$prev['lng'] + ((float)$cur['lng'] * 2) + (float)$next['lng']) / 4,
|
||||
'time' => $cur['time'],
|
||||
'accuracy' => $cur['accuracy'] ?? null,
|
||||
'source' => $cur['source'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user