From f41a39417f3cc38da98ad78c6c6691077995978b Mon Sep 17 00:00:00 2001 From: meusinfirmary Date: Fri, 20 Jun 2025 14:59:38 +0800 Subject: [PATCH] update --- app/Models/Tracks.php | 62 ++----------------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-) diff --git a/app/Models/Tracks.php b/app/Models/Tracks.php index 05d2601..3cdec4b 100755 --- a/app/Models/Tracks.php +++ b/app/Models/Tracks.php @@ -355,71 +355,13 @@ class Tracks extends Model usort($rawTracks, fn($a, $b) => $a->lst_loc_crt <=> $b->lst_loc_crt); // Filter loncatan - $filtered = self::filterJumps($rawTracks, 1000, 5, 300); + $filtered = self::filterJumps($rawTracks, 3000, 5, 300); return $filtered; // return array_reverse($filtered); } - // public static function filterJumps($points, $maxDistance = 1000, $maxTimeGap = 5, $maxSpeed = 300) - // { - // $filtered = []; - // $last = null; - - // foreach ($points as $p) { - // // 🛡️ 1. Validasi data koordinat - // if (!is_numeric($p->latitude) || !is_numeric($p->longitude)) { - // continue; - // } - - // if (strlen((string) abs($p->latitude)) < 8 || strlen((string) abs($p->longitude)) < 8) { - // // Buang lat/lon kurang dari 8 digit desimal (umumnya noise) - // continue; - // } - - // if (!$last) { - // $filtered[] = $p; - // $last = $p; - // continue; - // } - - // // 2. Hitung jarak dan waktu - // $distance = self::haversineDistance( - // $last->latitude, - // $last->longitude, - // $p->latitude, - // $p->longitude - // ); - // $timeGap = $p->lst_loc_crt - $last->lst_loc_crt; - - // if ($timeGap <= 0) { - // continue; - // } - - // $speed = ($distance / $timeGap) * 3.6; // m/s to km/h - - // // 🧠 3. Validasi kombinasi logis - // if ($speed <= $maxSpeed && ($distance <= $maxDistance || $timeGap >= $maxTimeGap)) { - // $filtered[] = $p; - // $last = $p; - // } else { - // // Optional debug: - // // Log::info("LONCAT: speed={$speed}, dist={$distance}, timeGap={$timeGap}, pointID={$p->master_id}"); - // } - // } - - // // ⏳ Tambahkan titik terakhir jika tidak masuk - // if (!empty($points)) { - // $lastPoint = end($points); - // if (empty($filtered) || end($filtered)->lst_loc_crt !== $lastPoint->lst_loc_crt) { - // $filtered[] = $lastPoint; - // } - // } - - // return $filtered; - // } - - public static function filterJumps($points, $maxDistance = 2000, $maxTimeGap = 5, $maxSpeed = 150) + public static function filterJumps($points, $maxDistance = 3000, $maxTimeGap = 5, $maxSpeed = 150) { $filtered = []; $last = null;