Skip to content

Commit

Permalink
Merge pull request #5461 from streetcomplete/building-overlay
Browse files Browse the repository at this point in the history
Buildings overlay
  • Loading branch information
westnordost authored Feb 1, 2024
2 parents 1fb96ed + 33e48d3 commit 025f96f
Show file tree
Hide file tree
Showing 58 changed files with 1,639 additions and 417 deletions.
55 changes: 55 additions & 0 deletions app/src/androidTest/res/drawable/ic_building_tower.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:pathData="m84,56v68h-40v-68z"
android:fillColor="#888"/>
<path
android:pathData="m32,12v36h64l0,-36z"
android:fillColor="#9c9c9c"/>
<path
android:pathData="m40,12v36h48l-0,-36z"
android:fillColor="#aaa"/>
<path
android:pathData="m76,12v36h-24v-36z"
android:fillColor="#c6c6c6"/>
<path
android:pathData="M32,20h64v20h-64z"
android:fillColor="#bacfef"/>
<path
android:pathData="m78,56v68h-28v-68z"
android:fillColor="#a8a8a8"/>
<path
android:pathData="m70,56v68h-12v-68z"
android:fillColor="#c6c6c6"/>
<path
android:pathData="M28,48h72v8h-72z"
android:fillColor="#5878b7"/>
<path
android:pathData="M28,4h72v8h-72z"
android:fillColor="#5878b7"/>
<path
android:fillColor="#FF000000"
android:pathData="M44,56h40v8h-40z"
android:fillAlpha="0.2"/>
<path
android:pathData="M32,20h64v4h-64z"
android:fillColor="#859dbf"/>
<path
android:pathData="M32,20h4v20h-4z"
android:fillColor="#6f829f"/>
<path
android:pathData="M92,20h4v20h-4z"
android:fillColor="#6f829f"/>
<path
android:pathData="M80,20h6v20h-6z"
android:fillColor="#6f829f"/>
<path
android:pathData="M60,20h8v20h-8z"
android:fillColor="#6f829f"/>
<path
android:pathData="M42,20h6v20h-6z"
android:fillColor="#6f829f"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.overlays.street_parking.StreetParkingOverlay
import de.westnordost.streetcomplete.quests.amenity_cover.AddAmenityCover
import de.westnordost.streetcomplete.quests.amenity_indoor.AddIsAmenityIndoor
import de.westnordost.streetcomplete.quests.building_type.AddBuildingType
import de.westnordost.streetcomplete.quests.cycleway.AddCycleway
import de.westnordost.streetcomplete.quests.foot.AddProhibitedForPedestrians
import de.westnordost.streetcomplete.quests.oneway.AddOneway
Expand Down Expand Up @@ -56,6 +57,7 @@ private val typeAliases = listOf(
"WayLitOverlay" to AddWayLit::class.simpleName!!,
"SidewalkOverlay" to AddSidewalk::class.simpleName!!,
"CyclewayOverlay" to AddCycleway::class.simpleName!!,
"BuildingsOverlay" to AddBuildingType::class.simpleName!!,
"AddStreetParking" to StreetParkingOverlay::class.simpleName!!,
"AddIsDefibrillatorIndoor" to AddIsAmenityIndoor::class.simpleName!!
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
package de.westnordost.streetcomplete.osm.building

enum class BuildingType(val osmKey: String?, val osmValue: String?) {
UNSUPPORTED (null, null),

HISTORIC ("historic", "yes"),
ABANDONED ("abandoned", "yes"),
RUINS ("ruins", "yes"),

HOUSE ("building", "house"),
APARTMENTS ("building", "apartments"),
DETACHED ("building", "detached"),
SEMI_DETACHED ("building", "semidetached_house"),
TERRACE ("building", "terrace"),
HOTEL ("building", "hotel"),
DORMITORY ("building", "dormitory"),
HOUSEBOAT ("building", "houseboat"),
BUNGALOW ("building", "bungalow"),
STATIC_CARAVAN ("building", "static_caravan"),
HUT ("building", "hut"),

INDUSTRIAL ("building", "industrial"),
RETAIL ("building", "retail"),
OFFICE ("building", "office"),
WAREHOUSE ("building", "warehouse"),
KIOSK ("building", "kiosk"),
STORAGE_TANK ("man_made", "storage_tank"),
GUARDHOUSE ("building", "guardhouse"),

KINDERGARTEN ("building", "kindergarten"),
SCHOOL ("building", "school"),
COLLEGE ("building", "college"),
SPORTS_CENTRE ("building", "sports_centre"),
HOSPITAL ("building", "hospital"),
STADIUM ("building", "stadium"),
GRANDSTAND ("building", "grandstand"),
TRAIN_STATION ("building", "train_station"),
TRANSPORTATION ("building", "transportation"),
FIRE_STATION ("building", "fire_station"),
UNIVERSITY ("building", "university"),
GOVERNMENT ("building", "government"),

CHURCH ("building", "church"),
CHAPEL ("building", "chapel"),
CATHEDRAL ("building", "cathedral"),
MOSQUE ("building", "mosque"),
TEMPLE ("building", "temple"),
PAGODA ("building", "pagoda"),
SYNAGOGUE ("building", "synagogue"),
SHRINE ("building", "shrine"),

CARPORT ("building", "carport"),
GARAGE ("building", "garage"),
GARAGES ("building", "garages"),
PARKING ("building", "parking"),

FARM ("building", "farm"),
FARM_AUXILIARY ("building", "farm_auxiliary"),
SILO ("man_made", "silo"),
GREENHOUSE ("building", "greenhouse"),

OUTBUILDING ("building", "outbuilding"),
SHED ("building", "shed"),
ALLOTMENT_HOUSE ("building", "allotment_house"),
ROOF ("building", "roof"),
BRIDGE ("building", "bridge"),
TOILETS ("building", "toilets"),
SERVICE ("building", "service"),
HANGAR ("building", "hangar"),
BUNKER ("building", "bunker"),
BOATHOUSE ("building", "boathouse"),
CONTAINER ("building", "container"),
TENT ("building", "tent"),
TOMB ("building", "tomb"),
TOWER ("man_made", "tower"),

RESIDENTIAL ("building", "residential"),
COMMERCIAL ("building", "commercial"),
CIVIC ("building", "civic"),
RELIGIOUS ("building", "religious"),

CONSTRUCTION ("building", "construction");

companion object {
val topSelectableValues = listOf(DETACHED, APARTMENTS, HOUSE, GARAGE, SHED, HUT)

/** a map of tag to [BuildingType] of building features that should be treated as aliases
* of known building types, i.e. that are displayed as that building type but whose tag is
* not modified when saving it again. */
val aliases: Map<Pair<String, String>, BuildingType> = mapOf(
// for better overview, this list is sorted by how the values appear on the wiki page
// for Key:building (if they do appear there)

// Accommodation
("building" to "cabin") to BUNGALOW,
("building" to "chalet") to BUNGALOW, // not documented
("building" to "summer_cottage") to BUNGALOW, // not documented
("building" to "cottage") to BUNGALOW, // not documented
("building" to "ger") to TENT, // a Mongolian tent
("building" to "stilt_house") to HOUSE,
("building" to "terrace_house") to HOUSE, // not documented, auto-changing to house would be a loss of information
("building" to "trullo") to HUT,
("building" to "pajaru") to HUT, // not documented, but similar to trullo https://it.wikipedia.org/wiki/Pajaru

// Commercial
("building" to "manufacture") to INDUSTRIAL, // not documented on main page
("building" to "factory") to INDUSTRIAL, // not documented on main page
("building" to "supermarket") to RETAIL,
("building" to "restaurant") to RETAIL, // not documented
("building" to "pub") to RETAIL, // not documented
("building" to "bank") to RETAIL, // not documented

// Religious
("building" to "kingdom_hall") to RELIGIOUS,
("building" to "monastery") to RELIGIOUS,
("building" to "presbytery") to RELIGIOUS,
("building" to "wayside_shrine") to RELIGIOUS,
("building" to "convent") to RELIGIOUS,

// Civic
("building" to "museum") to CIVIC,
("building" to "public") to CIVIC, // pretty much a real synonym
("building" to "government_office") to GOVERNMENT, // not documented
("building" to "education") to CIVIC, // not documented (but I like this tag!!)
("building" to "townhall") to CIVIC,
("building" to "administrative") to GOVERNMENT, // not documented; =government is also for provincial administration

// Agricultural
("building" to "barn") to FARM_AUXILIARY,
("building" to "cowshed") to FARM_AUXILIARY,
("building" to "stable") to FARM_AUXILIARY,
("building" to "sty") to FARM_AUXILIARY,
("building" to "livestock") to FARM_AUXILIARY,
("building" to "poultry_house") to FARM_AUXILIARY, // not documented
("building" to "chicken_coop") to FARM_AUXILIARY, // not documented
("building" to "granary") to SILO, // not documented

("building" to "slurry_tank") to STORAGE_TANK,
("building" to "digester") to STORAGE_TANK,
("building" to "gasometer") to STORAGE_TANK,
("building" to "agricultural") to FARM_AUXILIARY, // not documented

// Technical
("building" to "tech_cab") to SERVICE,
("building" to "transformer_tower") to SERVICE,
("building" to "power_substation") to SERVICE,
("building" to "tower") to TOWER, // not really a synonym though
("building" to "communications_tower") to TOWER,
("building" to "lighthouse") to TOWER,
("building" to "water_tower") to TOWER,
("building" to "cooling_tower") to TOWER,

// Other
("building" to "castle") to HISTORIC,
("building" to "canopy") to ROOF, // not documented
("man_made" to "canopy") to ROOF, // not documented
("building" to "gazebo") to ROOF, // not documented
)

/** a set of building values that should be treated as deprecated aliases of known building
* types */
val deprecatedValues = setOf(
"semi",
"semidetached",
"semi_detached",
"duplex", // -> semidetached_house

"detached_house", // -> detached

"terraced_house",
"terraced",
"townhouse", // -> terrace

"mobile_home", // -> static_caravan

"flats", // -> apartments

"shop", // -> retail

"storage_tank", // -> man_made=storage_tank
"tank", // -> man_made=storage_tank
"silo", // -> man_made=silo

"glasshouse", // ambiguous: could be greenhouse or conservatory

"collapsed",
"damaged",
"ruins", // (not explicitly deprecated though)
"ruin", // -> ruins=yes

"abandoned",
"disused", // -> abandoned=yes

"unclassified",
"undefined",
"unknown",
"other",
"fixme", // -> yes
)

/** other OSM keys that may describe the purpose of a building */
val otherKeysPotentiallyDescribingBuildingType = listOf(
// See #1854, #1891, #3233
"man_made",
"historic",
"military",
"power",
"tourism",
"attraction",
"amenity",
"leisure",
"aeroway",
"railway",
"craft",
"healthcare",
"office",
"shop",
"description",
"emergency",
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.westnordost.streetcomplete.osm.building

import de.westnordost.streetcomplete.osm.building.BuildingType.*

enum class BuildingTypeCategory(val type: BuildingType?, val subTypes: List<BuildingType>) {
RESIDENTIAL(
BuildingType.RESIDENTIAL, listOf(
DETACHED, APARTMENTS, SEMI_DETACHED, TERRACE, HOUSE, FARM, HUT, BUNGALOW, STATIC_CARAVAN,
DORMITORY, HOUSEBOAT,
)),
COMMERCIAL(
BuildingType.COMMERCIAL, listOf(
OFFICE, RETAIL, KIOSK, INDUSTRIAL, WAREHOUSE, HOTEL, STORAGE_TANK, PARKING, HANGAR,
)),
CIVIC(
BuildingType.CIVIC, listOf(
SCHOOL, UNIVERSITY, HOSPITAL, KINDERGARTEN, SPORTS_CENTRE, TRAIN_STATION, TRANSPORTATION,
COLLEGE, GOVERNMENT, TOILETS, STADIUM, FIRE_STATION, OFFICE, GRANDSTAND
)),
OUTBUILDING(
BuildingType.OUTBUILDING, listOf(
SHED, GARAGE, GARAGES, CARPORT, SERVICE, ALLOTMENT_HOUSE, GREENHOUSE, ROOF,
BOATHOUSE, CONTAINER, TENT, GUARDHOUSE,
)),
RELIGIOUS(
BuildingType.RELIGIOUS, listOf(
CHURCH, CATHEDRAL, CHAPEL, MOSQUE, TEMPLE, PAGODA, SYNAGOGUE, SHRINE
)),
FOR_FARMS(null, listOf(
FARM, FARM_AUXILIARY, SILO, GREENHOUSE, STORAGE_TANK, SHED,
)),
OTHER(null, listOf(
ROOF, TOWER, BUNKER, BRIDGE, HISTORIC, ABANDONED, RUINS, TOMB
)),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.westnordost.streetcomplete.osm.building

import de.westnordost.streetcomplete.R

Check failure on line 3 in app/src/main/java/de/westnordost/streetcomplete/osm/building/BuildingTypeCategoryItem.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.CIVIC
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.COMMERCIAL
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.OUTBUILDING
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.FOR_FARMS
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.OTHER
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.RELIGIOUS
import de.westnordost.streetcomplete.osm.building.BuildingTypeCategory.RESIDENTIAL
import de.westnordost.streetcomplete.view.image_select.GroupableDisplayItem
import de.westnordost.streetcomplete.view.image_select.Item

fun Iterable<BuildingTypeCategory>.toItems() = map { it.asItem() }

fun BuildingTypeCategory.asItem(): GroupableDisplayItem<BuildingType> =
Item(type, iconResId, titleResId, descriptionResId, subTypes.toItems())

private val BuildingTypeCategory.titleResId: Int get() = when (this) {
RESIDENTIAL -> R.string.quest_buildingType_residential
COMMERCIAL -> R.string.quest_buildingType_commercial
CIVIC -> R.string.quest_buildingType_civic
RELIGIOUS -> R.string.quest_buildingType_religious
OUTBUILDING -> R.string.quest_buildingType_outbuilding
FOR_FARMS -> R.string.quest_buildingType_farm
OTHER -> R.string.quest_buildingType_other
}

private val BuildingTypeCategory.descriptionResId: Int? get() = when (this) {
RESIDENTIAL -> R.string.quest_buildingType_residential_description
COMMERCIAL -> R.string.quest_buildingType_commercial_generic_description
CIVIC -> R.string.quest_buildingType_civic_description
OUTBUILDING -> R.string.quest_buildingType_outbuilding_description
else -> null
}

private val BuildingTypeCategory.iconResId: Int get() = when (this) {
RESIDENTIAL -> R.drawable.ic_building_apartments
COMMERCIAL -> R.drawable.ic_building_office
CIVIC -> R.drawable.ic_building_civic
RELIGIOUS -> R.drawable.ic_building_temple
OUTBUILDING -> R.drawable.ic_building_shed
FOR_FARMS -> R.drawable.ic_building_farm
OTHER -> R.drawable.ic_building_other
}
Loading

0 comments on commit 025f96f

Please sign in to comment.