STRICT radius enforcement: never fall back to out-of-radius stations in list, cheapest reference, or widget

This commit is contained in:
FuelBoard Contributor
2026-08-11 18:36:08 +01:00
parent e0a5bb3d5d
commit 6eae42ff3d
2 changed files with 12 additions and 13 deletions
+3 -2
View File
@@ -91,10 +91,11 @@ struct FuelPriceTimelineProvider: TimelineProvider {
if stations.isEmpty { stations = SampleFuelProvider.sampleStations }
let radiusKM = Double(FuelStore.loadStationLimit()) * 1.60934 // miles km
if let location {
let within = stations.filter {
// STRICT: cached data fetched around another location must never
// leak out-of-radius stations into the widget.
stations = stations.filter {
$0.distanceKM(to: location.lat, lng2: location.lng) <= radiusKM
}
if !within.isEmpty { stations = within }
}
let filtered = stations.filter { $0.prices[fuel] != nil }
let sorted: [FuelStation]