From 79762a0baf6ae1444c68ab85a51b1959e03210ff Mon Sep 17 00:00:00 2001 From: elpatron Date: Wed, 3 Jun 2026 17:57:11 +0200 Subject: [PATCH] fix(gps): Genauigkeitsanzeige unter und ab 100 m unterscheiden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der tote Ternär lieferte in beiden Zweigen dieselbe Rundung; ab 100 m wird jetzt auf 10 m gerundet, damit schwache Fixes nicht falsch präzise wirken. Co-authored-by: Cursor --- client/src/utils/geolocation.test.ts | 8 ++++++++ client/src/utils/geolocation.ts | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/utils/geolocation.test.ts b/client/src/utils/geolocation.test.ts index b50016c..cc12871 100644 --- a/client/src/utils/geolocation.test.ts +++ b/client/src/utils/geolocation.test.ts @@ -1,6 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { classifyGpsAccuracyMeters, + formatGpsAccuracyMeters, geolocationErrorI18nKey, GEOLOCATION_LIVE_INTRO_STORAGE_KEY, getCurrentPosition, @@ -81,6 +82,13 @@ describe('geolocation helpers', () => { }) }) + it('formats GPS accuracy for display', () => { + expect(formatGpsAccuracyMeters(12.4)).toBe('12') + expect(formatGpsAccuracyMeters(87)).toBe('87') + expect(formatGpsAccuracyMeters(105)).toBe('110') + expect(formatGpsAccuracyMeters(247)).toBe('250') + }) + it('classifies GPS accuracy into signal quality', () => { expect(classifyGpsAccuracyMeters(8)).toBe('excellent') expect(classifyGpsAccuracyMeters(30)).toBe('good') diff --git a/client/src/utils/geolocation.ts b/client/src/utils/geolocation.ts index d260dd3..7ac6025 100644 --- a/client/src/utils/geolocation.ts +++ b/client/src/utils/geolocation.ts @@ -30,8 +30,11 @@ export function gpsQualityI18nKey(quality: GpsSignalQuality): string { return `logs.gps_quality_${quality}` } +/** Formats accuracy for i18n (±{{accuracy}} m): 1 m below 100 m, 10 m from 100 m upward. */ export function formatGpsAccuracyMeters(accuracyM: number): string { - return accuracyM < 100 ? String(Math.round(accuracyM)) : String(Math.round(accuracyM)) + return accuracyM < 100 + ? String(Math.round(accuracyM)) + : String(Math.round(accuracyM / 10) * 10) } export type GeolocationPermissionState = PermissionState | 'unsupported'