Skip to content

Commit

Permalink
make code style of overlaysmodule and questsmodule consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Sep 26, 2023
1 parent 2bd3207 commit 4734274
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package de.westnordost.streetcomplete.overlays

import de.westnordost.countryboundaries.CountryBoundaries
import de.westnordost.osmfeatures.Feature
import de.westnordost.osmfeatures.FeatureDictionary
import de.westnordost.streetcomplete.data.meta.CountryInfos
import de.westnordost.streetcomplete.data.overlays.OverlayRegistry
import de.westnordost.streetcomplete.overlays.address.AddressOverlay
import de.westnordost.streetcomplete.overlays.cycleway.CyclewayOverlay
Expand All @@ -17,16 +20,29 @@ import java.util.concurrent.FutureTask
/* Each overlay is assigned an ordinal. This is used for serialization and is thus never changed,
* even if the order of overlays is changed. */
val overlaysModule = module {
single { OverlayRegistry(listOf(
0 to WayLitOverlay(),
6 to SurfaceOverlay(),
1 to SidewalkOverlay(),
5 to CyclewayOverlay(get(), get(named("CountryBoundariesFuture"))),
2 to StreetParkingOverlay(),
3 to AddressOverlay(get(named("CountryBoundariesFuture"))),
4 to ShopsOverlay { tags ->
get<FutureTask<FeatureDictionary>>(named("FeatureDictionaryFuture"))
single {
overlaysRegistry(
get(),
get(named("CountryBoundariesFuture")),
{ tags ->
get<FutureTask<FeatureDictionary>>(named("FeatureDictionaryFuture"))
.get().getFeature(tags)
},
)) }
}
)
}
}

fun overlaysRegistry(
countryInfos: CountryInfos,
countryBoundariesFuture: FutureTask<CountryBoundaries>,
getFeature: (tags: Map<String, String>) -> Feature?,
) = OverlayRegistry(listOf(

0 to WayLitOverlay(),
6 to SurfaceOverlay(),
1 to SidewalkOverlay(),
5 to CyclewayOverlay(countryInfos, countryBoundariesFuture),
2 to StreetParkingOverlay(),
3 to AddressOverlay(countryBoundariesFuture),
4 to ShopsOverlay(getFeature),
))
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,11 @@ val questsModule = module {
get(),
get(named("CountryBoundariesFuture")),
get(),
) { tags ->
get<FutureTask<FeatureDictionary>>(named("FeatureDictionaryFuture"))
.get().getFeature(tags)
}
{ tags ->
get<FutureTask<FeatureDictionary>>(named("FeatureDictionaryFuture"))
.get().getFeature(tags)
}
)
}
}

Expand Down Expand Up @@ -252,7 +253,7 @@ fun questTypeRegistry(
9 to AddCarWashType(),

10 to AddBenchBackrest(),
11 to AddAmenityCover { getFeature(it) },
11 to AddAmenityCover(getFeature),

12 to AddBridgeStructure(),

Expand Down Expand Up @@ -328,7 +329,7 @@ fun questTypeRegistry(
/* pulled up in priority to be before CheckExistence because this is basically the check
whether the postbox is still there in countries in which it is enabled */
48 to AddPostboxCollectionTimes(),
49 to CheckExistence { getFeature(it) },
49 to CheckExistence(getFeature),
155 to AddGritBinSeasonal(),

50 to AddBoardType(),
Expand Down Expand Up @@ -378,9 +379,9 @@ fun questTypeRegistry(
157 to AddHairdresserCustomers(), // almost always marked on sign outside
78 to SpecifyShopType(), // above add place name as some brand presets will set the name too
79 to CheckShopType(),
80 to AddPlaceName { getFeature(it) },
77 to CheckOpeningHoursSigned { getFeature(it) },
81 to AddOpeningHours { getFeature(it) },
80 to AddPlaceName(getFeature),
77 to CheckOpeningHoursSigned(getFeature),
81 to AddOpeningHours(getFeature),
83 to AddBicyclePump(), // visible from the outside, but only during opening hours

84 to AddAtmOperator(),
Expand Down Expand Up @@ -465,7 +466,7 @@ fun questTypeRegistry(
132 to AddAcceptsCash(),

133 to AddFuelSelfService(),
156 to CheckShopExistence { getFeature(it) }, // after opening hours and similar so they will be preferred if enabled
156 to CheckShopExistence(getFeature), // after opening hours and similar so they will be preferred if enabled

/* ↓ 5.quests that are very numerous ---------------------------------------------------- */

Expand Down

0 comments on commit 4734274

Please sign in to comment.