From 989f114cc4a5a0455d359723a8bbf34111ac1d2e Mon Sep 17 00:00:00 2001 From: whidix Date: Sun, 8 Mar 2026 18:18:27 +0100 Subject: [PATCH] feat: add detailed GPS sample tracking with accuracy, speed, and timestamp --- .../game/play/[sessionCode]/+page.svelte | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/routes/(game)/game/play/[sessionCode]/+page.svelte b/src/routes/(game)/game/play/[sessionCode]/+page.svelte index 5f56402..3d30008 100644 --- a/src/routes/(game)/game/play/[sessionCode]/+page.svelte +++ b/src/routes/(game)/game/play/[sessionCode]/+page.svelte @@ -43,8 +43,18 @@ event: string; details?: Record; }; + type GpsSample = { + lat: number; + lon: number; + accuracy: number; + speed: number | null; + altitude: number | null; + headFromGps: number | null; + timestamp: number; + }; let debugLogs = $state([]); let lastOrientationEvent = $state(null); + let lastGpsSample = $state(null); function addDebug(event: string, details?: Record) { const entry: DebugLogEntry = { @@ -219,6 +229,15 @@ userLon = position.coords.longitude; locationError = null; locationPermission = 'granted'; + lastGpsSample = { + lat: position.coords.latitude, + lon: position.coords.longitude, + accuracy: position.coords.accuracy, + speed: position.coords.speed, + altitude: position.coords.altitude, + headFromGps: position.coords.heading, + timestamp: position.timestamp + }; addDebug('watch_position_success', { lat: userLat, lon: userLon, @@ -226,6 +245,9 @@ speed: position.coords.speed, headFromGps: position.coords.heading }); + console.log( + `[gps] lat=${position.coords.latitude.toFixed(6)} lon=${position.coords.longitude.toFixed(6)} acc=${Math.round(position.coords.accuracy)}m speed=${position.coords.speed ?? 'null'} alt=${position.coords.altitude ?? 'null'} heading=${position.coords.heading ?? 'null'}` + ); // Try to get device heading if available from GPS if (position.coords.heading !== null && position.coords.heading >= 0) { @@ -662,6 +684,9 @@
watchId: {watchId ?? 'null'}
userLat: {userLat ?? 'null'}
userLon: {userLon ?? 'null'}
+
lastGpsSample: {lastGpsSample ? `${lastGpsSample.lat.toFixed(6)}, ${lastGpsSample.lon.toFixed(6)}` : 'null'}
+
lastGpsAccuracy: {lastGpsSample ? `${Math.round(lastGpsSample.accuracy)}m` : 'null'}
+
lastGpsTimestamp: {lastGpsSample ? new Date(lastGpsSample.timestamp).toISOString() : 'null'}
stepLat: {currentStep.latitude ?? 'null'}
stepLon: {currentStep.longitude ?? 'null'}
proximityRadius: {currentStep.proximityRadius ?? 'null'}