STRICT radius enforcement: never fall back to out-of-radius stations in list, cheapest reference, or widget
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user