Skip to content

Commit

Permalink
allow adding housenumbers on entrances, disallow adding housenumbers …
Browse files Browse the repository at this point in the history
…on buildings in Italy (#4801, #4823)
  • Loading branch information
westnordost committed Mar 10, 2023
1 parent 836741b commit b31da1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val overlaysModule = module {
0 to WayLitOverlay(),
1 to SidewalkOverlay(),
2 to StreetParkingOverlay(),
3 to AddressOverlay(),
3 to AddressOverlay(get(named("CountryBoundariesFuture"))),
4 to ShopsOverlay(get(named("FeatureDictionaryFuture"))),
5 to CyclewayOverlay(get(), get(named("CountryBoundariesFuture"))),
)) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.westnordost.streetcomplete.overlays.address

import de.westnordost.countryboundaries.CountryBoundaries
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.mapdata.Element
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry
Expand All @@ -11,8 +12,12 @@ import de.westnordost.streetcomplete.overlays.PointStyle
import de.westnordost.streetcomplete.overlays.PolygonStyle
import de.westnordost.streetcomplete.quests.address.AddHousenumber
import de.westnordost.streetcomplete.util.getShortHouseNumber
import de.westnordost.streetcomplete.util.ktx.getIds
import java.util.concurrent.FutureTask

class AddressOverlay : Overlay {
class AddressOverlay(
private val countryBoundaries: FutureTask<CountryBoundaries>
) : Overlay {

override val title = R.string.overlay_addresses
override val icon = R.drawable.ic_quest_housenumber
Expand All @@ -28,16 +33,26 @@ class AddressOverlay : Overlay {
"layers.buildings.draw.buildings-outline-style.extrude" to "false"
)

private val noAddressesOnBuildings = setOf(
"IT" // https://github.com/streetcomplete/StreetComplete/issues/4801
)

override fun getStyledElements(mapData: MapDataWithGeometry) =
mapData.filter("""
nodes with
addr:housenumber or addr:housename or addr:conscriptionnumber or addr:streetnumber
""").map { it to PointStyle(icon = null, label = getShortHouseNumber(it.tags)) } +
mapData.filter("""
ways, relations with building
""").map {
it to PolygonStyle(Color.INVISIBLE, label = getShortHouseNumber(it.tags))
}
mapData
.filter("""
nodes with
addr:housenumber or addr:housename or addr:conscriptionnumber or addr:streetnumber
or entrance
""")
.map { it to PointStyle(icon = null, label = getShortHouseNumber(it.tags) ?: "") } + // or ▫
mapData
.filter("ways, relations with building")
.filter {
val center = mapData.getGeometry(it.type, it.id)?.center ?: return@filter false
val country = countryBoundaries.get().getIds(center).firstOrNull()
country !in noAddressesOnBuildings
}
.map { it to PolygonStyle(Color.INVISIBLE, label = getShortHouseNumber(it.tags)) }

override fun createForm(element: Element?) = AddressOverlayForm()
}

0 comments on commit b31da1c

Please sign in to comment.