Skip to content

Commit 7e22c36

Browse files
committed
Balance worldwide panorama sampling
1 parent f0f3977 commit 7e22c36

3 files changed

Lines changed: 322 additions & 85 deletions

File tree

Sources/StreetViewWander/WanderModel.swift

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,15 @@ final class WanderModel: ObservableObject {
146146
continentId: selectedContinentId,
147147
countryId: selectedCountryId
148148
)
149+
let recentContinents = recentContinentLabels()
149150
let metadataAPIKey = metadataAPIKey
150151

151152
Task {
152153
do {
153154
let next = try await panoramaFinder.findRandomPanorama(
154155
metadataAPIKey: metadataAPIKey,
155-
selection: selection
156+
selection: selection,
157+
recentContinents: recentContinents
156158
)
157159
panorama = next
158160
history = try historyStore.append(next)
@@ -167,6 +169,63 @@ final class WanderModel: ObservableObject {
167169
}
168170
}
169171

172+
private func recentContinentLabels() -> [String] {
173+
history.prefix(60).compactMap {
174+
$0.continentLabel ?? legacyContinentLabel(for: $0.areaLabel)
175+
}
176+
}
177+
178+
private func legacyContinentLabel(for areaLabel: String) -> String? {
179+
[
180+
"Alaska and Yukon": "North America",
181+
"Canada West": "North America",
182+
"Canada East": "North America",
183+
"United States": "North America",
184+
"Mexico": "North America",
185+
"Central America": "North America",
186+
"Caribbean": "North America",
187+
"Greenland and North Atlantic": "North America",
188+
"Iceland": "Europe",
189+
"British Isles": "Europe",
190+
"Iberia": "Europe",
191+
"Western Europe": "Europe",
192+
"Central Europe": "Europe",
193+
"Nordics": "Europe",
194+
"Baltics and Poland": "Europe",
195+
"Italy and Malta": "Europe",
196+
"Balkans": "Europe",
197+
"Eastern Europe": "Europe",
198+
"Greece and Cyprus": "Europe",
199+
"Turkey and Caucasus": "Asia",
200+
"Western Russia": "Europe",
201+
"Middle East": "Asia",
202+
"Central Asia": "Asia",
203+
"Northern Asia West": "Asia",
204+
"Northern Asia East": "Asia",
205+
"Mongolia and Northern China": "Asia",
206+
"Eastern China": "Asia",
207+
"South Asia": "Asia",
208+
"Mainland Southeast Asia": "Asia",
209+
"Maritime Southeast Asia": "Asia",
210+
"Japan and Korea": "Asia",
211+
"Taiwan Hong Kong and Macau": "Asia",
212+
"Australia and New Zealand": "Oceania",
213+
"Pacific Islands West": "Oceania",
214+
"Pacific Islands East": "Oceania",
215+
"Northern South America": "South America",
216+
"Brazil": "South America",
217+
"Andes": "South America",
218+
"Southern Cone": "South America",
219+
"North Africa": "Africa",
220+
"West Africa": "Africa",
221+
"East Africa": "Africa",
222+
"Southern Africa": "Africa",
223+
"Indian Ocean Islands": "Africa",
224+
"Antarctic Peninsula": "Antarctica",
225+
"Ross Island Antarctica": "Antarctica"
226+
][areaLabel]
227+
}
228+
170229
func importEnvFile() {
171230
let panel = NSOpenPanel()
172231
panel.canChooseDirectories = false

0 commit comments

Comments
 (0)