From 8cda97a2f0272e0189c9916ef5d07502676b4739 Mon Sep 17 00:00:00 2001 From: whidix Date: Sun, 8 Mar 2026 18:41:29 +0100 Subject: [PATCH] feat: remove unused GPS sample and debug information to streamline location tracking --- .../game/play/[sessionCode]/+page.svelte | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/src/routes/(game)/game/play/[sessionCode]/+page.svelte b/src/routes/(game)/game/play/[sessionCode]/+page.svelte index a8dbc12..a23ec43 100644 --- a/src/routes/(game)/game/play/[sessionCode]/+page.svelte +++ b/src/routes/(game)/game/play/[sessionCode]/+page.svelte @@ -38,18 +38,6 @@ let locationPermission = $state<'prompt' | 'granted' | 'denied' | 'checking'>('prompt'); let distance = $state(null); let arrowRotation = $state(0); - type GpsSample = { - lat: number; - lon: number; - accuracy: number; - speed: number | null; - altitude: number | null; - headFromGps: number | null; - timestamp: number; - }; - let lastOrientationEvent = $state(null); - let lastGpsSample = $state(null); - let debugNow = $state(Date.now()); // Calculate distance between two coordinates in meters (Haversine formula) function calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number { @@ -192,15 +180,6 @@ 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 - }; // Try to get device heading if available from GPS if (position.coords.heading !== null && position.coords.heading >= 0) { @@ -244,10 +223,8 @@ if (hasAbsoluteOrientation) { window.addEventListener('deviceorientationabsolute', handleOrientation as EventListener); - lastOrientationEvent = 'deviceorientationabsolute'; } else if (hasOrientation) { window.addEventListener('deviceorientation', handleOrientation as EventListener); - lastOrientationEvent = 'deviceorientation'; } } } @@ -268,10 +245,6 @@ // Initialize location tracking onMount(() => { - const timerId = window.setInterval(() => { - debugNow = Date.now(); - }, 1000); - if (currentStep?.type === 'location' && isCurrentActiveStep) { checkLocationPermission().then(() => { startAllTracking(); @@ -279,7 +252,6 @@ } return () => { - window.clearInterval(timerId); stopLocationTracking(); }; }); @@ -297,7 +269,6 @@ function handleOrientation(event: Event) { const e = event as DeviceOrientationEvent; - lastOrientationEvent = event.type; if (e.absolute && e.alpha !== null) { heading = 360 - e.alpha; // Convert to compass heading } else if (e.alpha !== null) { @@ -573,38 +544,6 @@ {/if} {/if} - -
- Client Debug Info -
-
currentTime: {new Date(debugNow).toLocaleTimeString()}
-
step.id: {currentStep.id}
-
step.type: {currentStep.type}
-
isCurrentActiveStep: {String(isCurrentActiveStep)}
-
locationPermission: {locationPermission}
-
locationError: {locationError ?? 'null'}
-
watchId: {watchId ?? 'null'}
-
longitude: {userLon ?? 'null'}
-
latitude: {userLat ?? 'null'}
-
orientation(heading): {heading ?? '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'}
-
distance: {distance ?? 'null'}
-
arrowRotation: {arrowRotation}
-
lastOrientationEvent: {lastOrientationEvent ?? 'null'}
-
debugArrow:
-
-
-
-
-
{distance !== null ? `${distance}m` : '--'}
-
-
-
{#if currentStep.hint}