Skip to content

Commit 4a7c3f0

Browse files
committed
EnBwAvailabilityDetector: try ungrouping markers multiple times
1 parent 3b76e8f commit 4a7c3f0

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

app/src/main/java/net/vonforst/evmap/api/availability/EnBwAvailabilityDetector.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,8 @@ class EnBwAvailabilityDetector(client: OkHttpClient, baseUrl: String? = null) :
136136
var markers =
137137
api.getMarkers(lng - coordRange, lng + coordRange, lat - coordRange, lat + coordRange)
138138

139-
markers = markers.flatMap {
140-
if (it.grouped) {
141-
api.getMarkers(
142-
it.viewPort.lowerLeftLon,
143-
it.viewPort.upperRightLon,
144-
it.viewPort.lowerLeftLat,
145-
it.viewPort.upperRightLat
146-
)
147-
} else {
148-
listOf(it)
149-
}
139+
repeat(3) {
140+
markers = ungroupMarkers(markers)
150141
}
151142
if (markers.any { it.grouped }) throw AvailabilityDetectorException("markers still grouped")
152143

@@ -241,6 +232,20 @@ class EnBwAvailabilityDetector(client: OkHttpClient, baseUrl: String? = null) :
241232
)
242233
}
243234

235+
private suspend fun ungroupMarkers(markers: List<EnBwApi.EnBwLocation>): List<EnBwApi.EnBwLocation> =
236+
markers.flatMap {
237+
if (it.grouped) {
238+
api.getMarkers(
239+
it.viewPort.lowerLeftLon,
240+
it.viewPort.upperRightLon,
241+
it.viewPort.lowerLeftLat,
242+
it.viewPort.upperRightLat
243+
)
244+
} else {
245+
listOf(it)
246+
}
247+
}
248+
244249
override fun isChargerSupported(charger: ChargeLocation): Boolean {
245250
val country = charger.chargepriceData?.country ?: charger.address?.country
246251

0 commit comments

Comments
 (0)