fix(gps): Genauigkeitsanzeige unter und ab 100 m unterscheiden
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 <cursoragent@cursor.com>
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user