Skip to content

Commit

Permalink
Add Street cabinet quest (#470)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Helium314 <[email protected]>
  • Loading branch information
mcliquid and Helium314 authored Nov 1, 2023
1 parent 36debbf commit afd1b0c
Show file tree
Hide file tree
Showing 33 changed files with 848 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ import de.westnordost.streetcomplete.quests.sport.AddSport
import de.westnordost.streetcomplete.quests.step_count.AddStepCount
import de.westnordost.streetcomplete.quests.step_count.AddStepCountStile
import de.westnordost.streetcomplete.quests.steps_ramp.AddStepsRamp
import de.westnordost.streetcomplete.quests.street_cabinet.AddStreetCabinetType
import de.westnordost.streetcomplete.quests.summit.AddSummitCross
import de.westnordost.streetcomplete.quests.summit.AddSummitRegister
import de.westnordost.streetcomplete.quests.surface.AddCyclewayPartSurface
Expand Down Expand Up @@ -583,6 +584,7 @@ fun getQuestTypeList(
EE_QUEST_OFFSET + 5 to AddHealthcareSpeciality(),
EE_QUEST_OFFSET + 6 to AddServiceBuildingType(),
EE_QUEST_OFFSET + 7 to AddServiceBuildingOperator(),
EE_QUEST_OFFSET + 29 to AddStreetCabinetType(),
EE_QUEST_OFFSET + 8 to AddOutdoorSeatingType(),
EE_QUEST_OFFSET + 25 to AddDestination(),
EE_QUEST_OFFSET + 22 to AddArtworkType(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.westnordost.streetcomplete.quests.street_cabinet

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.mapdata.Element
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry
import de.westnordost.streetcomplete.data.osm.mapdata.filter
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.osm.Tags

class AddStreetCabinetType : OsmFilterQuestType<StreetCabinetType>() {

override val elementFilter = """
nodes, ways with
man_made = street_cabinet
and !street_cabinet
and !utility
"""
override val changesetComment = "Add street cabinet type"
override val wikiLink = "Tag:man_made=street_cabinet"
override val icon = R.drawable.ic_quest_street_cabinet
override val defaultDisabledMessage: Int = R.string.default_disabled_msg_ee

override fun getTitle(tags: Map<String, String>) = R.string.quest_street_cabinet_type_title

override fun getTitleArgs(tags: Map<String, String>): Array<String> {
val operator = tags["operator"]?.let { " ($it)" } ?: ""
return arrayOf(operator)
}

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("""
nodes, ways with
(
man_made = street_cabinet
or building = service
)
""")

override fun createForm() = AddStreetCabinetTypeForm()

override fun applyAnswerTo(answer: StreetCabinetType, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags[answer.osmKey] = answer.osmValue
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.westnordost.streetcomplete.quests.street_cabinet

import android.os.Bundle
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AImageListQuestForm

class AddStreetCabinetTypeForm : AImageListQuestForm<StreetCabinetType, StreetCabinetType>() {

override val items = StreetCabinetType.values().map { it.asItem() }
override val itemsPerRow = 4
override val moveFavoritesToFront = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
imageSelector.cellLayoutId = R.layout.cell_icon_select_with_label_below
}

override fun onClickOk(selectedItems: List<StreetCabinetType>) {
applyAnswer(selectedItems.single())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.westnordost.streetcomplete.quests.street_cabinet

enum class StreetCabinetType(val osmKey: String, val osmValue: String) {
POWER("utility", "power"),
TELECOM("utility", "telecom"),
TRAFFIC_CONTROL("street_cabinet", "traffic_control"),
POSTAL_SERVICE("street_cabinet", "postal_service"),
GAS("utility", "gas"),
STREET_LIGHTING("utility", "street_lighting"),
TRANSPORT_MANAGEMENT("street_cabinet", "transport_management"),
TRAFFIC_MONITORING("street_cabinet", "traffic_monitoring"),
WASTE("street_cabinet", "waste"),
TELEVISION("utility", "television"),
WATER("utility", "water"),
SEWERAGE("utility", "sewerage");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package de.westnordost.streetcomplete.quests.street_cabinet

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.street_cabinet.StreetCabinetType.*
import de.westnordost.streetcomplete.view.image_select.Item

fun StreetCabinetType.asItem() = Item(this, iconResId, titleResId)

private val StreetCabinetType.titleResId: Int get() = when (this) {
POWER -> R.string.quest_utility_power
TELECOM -> R.string.quest_utility_telecom
POSTAL_SERVICE -> R.string.quest_street_cabinet_postal_service
TRAFFIC_CONTROL -> R.string.quest_street_cabinet_traffic_control
TRAFFIC_MONITORING -> R.string.quest_street_cabinet_traffic_monitoring
TRANSPORT_MANAGEMENT -> R.string.quest_street_cabinet_transport_management
WASTE -> R.string.quest_street_cabinet_waste
TELEVISION -> R.string.quest_street_cabinet_television
GAS -> R.string.quest_utility_gas
STREET_LIGHTING -> R.string.quest_street_cabinet_street_lighting
WATER -> R.string.quest_utility_water
SEWERAGE -> R.string.quest_utility_sewerage
}

private val StreetCabinetType.iconResId: Int get() = when (this) {
POWER -> R.drawable.quest_street_cabinet_power
TELECOM -> R.drawable.quest_street_cabinet_telecom
POSTAL_SERVICE -> R.drawable.quest_street_cabinet_postal_service
TRAFFIC_CONTROL -> R.drawable.quest_street_cabinet_traffic_control
TRAFFIC_MONITORING -> R.drawable.quest_street_cabinet_traffic_monitoring
TRANSPORT_MANAGEMENT -> R.drawable.quest_street_cabinet_transport_management
WASTE -> R.drawable.quest_street_cabinet_waste
TELEVISION -> R.drawable.quest_street_cabinet_television
GAS -> R.drawable.quest_street_cabinet_gas
STREET_LIGHTING -> R.drawable.quest_street_cabinet_street_lighting
WATER -> R.drawable.quest_street_cabinet_water
SEWERAGE -> R.drawable.quest_street_cabinet_sewerage
}
34 changes: 34 additions & 0 deletions app/src/main/res/drawable/ic_quest_street_cabinet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<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="m128,64c0,35.35 -28.65,64 -64,64s-64,-28.65 -64,-64 28.65,-64 64,-64 64,28.65 64,64"
android:strokeWidth=".2"
android:fillColor="#fd5"/>
<path
android:pathData="m25.69,107.25l76.66,0"
android:strokeWidth="7.67"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="3"
android:pathData="M37.15,20.72l53.67,0l0,84.33l-53.67,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:strokeWidth="3"
android:pathData="m25.65,105.06l76.66,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="m65.48,31.95 l-5,15 6.25,-1.25 -2.5,13.75 18.75,-20 -12.5,2.5 7.5,-12.5z"
android:strokeLineJoin="round"
android:strokeWidth="1.25"
android:fillColor="#fac800"
android:strokeColor="#fac800"/>
<path
android:pathData="M48.09,55.73l7.67,0l0,16.75l-7.67,0z"
android:fillColor="#ccc"/>
</vector>
33 changes: 33 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_gas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.51,5.21l72.92,0l0,114.59l-72.92,0z"
android:fillColor="#aaaaaa"
android:strokeColor="#333333"/>
<path
android:pathData="M11.94,122.79L116.11,122.79"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="M64,92.42C49.17,92.42 39.29,85.01 39.29,72.65 39.29,60.29 65.16,58.14 59.06,35.58c0,0 19.77,12.36 14.83,27.18 0,0 5.29,-6.43 7.41,-9.88 0,0 7.41,7.41 7.41,19.77 0,12.36 -9.88,19.77 -24.71,19.77z"
android:fillColor="#eb650d"/>
<path
android:pathData="m78.83,62.76c2.47,4.94 14.83,17.3 -4.94,17.3 -4.94,0 2.47,-12.36 4.94,-17.3z"
android:fillColor="#e98616"/>
<path
android:pathData="M73.88,70.18C64,60.29 73.88,55.35 64,42.99 66.47,55.35 46.7,65.24 46.7,75.12c0,9.88 7.41,14.83 17.3,14.83 9.88,0 15.03,-14.01 9.88,-19.77z"
android:fillColor="#f1b014"/>
<path
android:pathData="M64,85.01C54.12,85.01 54.12,72.65 64,60.29 64,72.65 73.88,85.01 64,85.01Z"
android:fillColor="#f3f40f"/>
</vector>
46 changes: 46 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_postal_service.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.52,5.21l72.92,0l0,114.6l-72.92,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:pathData="m11.94,122.79l104.17,0"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="m43.08,44.01l41.9,0c2.24,0 4.04,1.8 4.04,4.04l0,31.9c0,2.24 -1.8,4.04 -4.04,4.04l-41.9,0c-2.24,0 -4.04,-1.8 -4.04,-4.04l0,-31.9c0,-2.24 1.8,-4.04 4.04,-4.04z"
android:fillColor="#ddd"/>
<path
android:pathData="m41.51,80.24 l22.49,-23.74 22.49,23.74"
android:strokeLineJoin="round"
android:strokeWidth="5"
android:fillColor="#00000000"
android:strokeColor="#aaa"
android:strokeLineCap="round"/>
<path
android:pathData="m41.51,83.99c-2.3,0 -3.38,-2.84 -1.66,-4.37l22.49,-19.99c0.95,-0.84 2.37,-0.84 3.32,0l22.49,19.99c1.72,1.53 0.64,4.37 -1.66,4.37z"
android:fillColor="#e9e9e9"
android:fillType="evenOdd"/>
<path
android:pathData="m41.51,47.76 l22.49,23.74 22.49,-23.74"
android:strokeLineJoin="round"
android:strokeWidth="5"
android:fillColor="#00000000"
android:strokeColor="#aaa"
android:strokeLineCap="round"/>
<path
android:pathData="m41.51,44.01c-2.3,-0 -3.38,2.84 -1.66,4.37l22.49,19.99c0.95,0.84 2.37,0.84 3.32,0l22.49,-19.99c1.72,-1.53 0.64,-4.37 -1.66,-4.37z"
android:fillColor="#fff"
android:fillType="evenOdd"/>
</vector>
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_power.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.52,5.21l72.92,0l0,114.6l-72.92,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:pathData="m11.94,122.79l104.17,0"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="m88.7,56.02 l-22.73,40.91c-0.41,0.73 -1.16,1.16 -1.98,1.16 -0.18,0 -0.39,-0.02 -0.57,-0.07 -1,-0.27 -1.7,-1.16 -1.7,-2.2l0,-25l-20.45,0c-0.77,0 -1.48,-0.39 -1.91,-1.02 -0.41,-0.64 -0.48,-1.45 -0.18,-2.16l15.91,-36.36c0.36,-0.82 1.18,-1.36 2.09,-1.36l13.64,0c0.75,0 1.45,0.36 1.89,1 0.41,0.61 0.5,1.41 0.23,2.11l-7.84,19.61l21.64,0c0.8,0 1.55,0.43 1.95,1.11 0.41,0.7 0.43,1.57 0.02,2.27z"
android:fillColor="#ffb841"/>
</vector>
45 changes: 45 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_sewerage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.52,5.21l72.92,0l0,114.6l-72.92,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:pathData="m11.94,122.79l104.17,0"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="m56.1,52.49c15.26,0 27.63,12.37 27.63,27.63l0,2.63l-15.79,0l0,-2.63c0,-6.54 -5.3,-11.84 -11.84,-11.84l-1.32,0l0,-15.79z"
android:fillColor="#6dc180"/>
<path
android:pathData="m67.94,55.15l0,27.6l15.79,0l0,-2.63c0,-11.02 -6.45,-20.54 -15.79,-24.97z"
android:fillColor="#5ca15d"/>
<path
android:pathData="M39,47.22l9.21,0l0,21.05l-9.21,0"
android:fillColor="#dfdfe1"/>
<path
android:pathData="M46.89,43.28l9.21,0l0,28.95l-9.21,0z"
android:fillColor="#cfcdd2"/>
<path
android:pathData="M62.68,80.78l26.31,0l0,3.95l-26.31,0z"
android:fillColor="#5ca15d"/>
<path
android:pathData="M67.94,80.78l21.05,0l0,3.95l-21.05,0z"
android:fillColor="#477e48"/>
<path
android:pathData="m72.51,73.32c-1.79,-4.32 -5.15,-7.71 -9.45,-9.54l1.55,-3.63c5.26,2.24 9.36,6.38 11.55,11.67z"
android:fillColor="#95d5a7"/>
<path
android:pathData="m67.94,61.92l0,4.95c1.97,1.76 3.53,3.95 4.57,6.45l3.65,-1.51c-1.7,-4.11 -4.56,-7.52 -8.22,-9.89z"
android:fillColor="#6dc180"/>
</vector>
46 changes: 46 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_street_lighting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.52,5.21l72.92,0l0,114.6l-72.92,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:pathData="m11.94,122.79l104.17,0"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:fillColor="#FF000000"
android:pathData="m51.5,82.26l0,6.25l7.81,3.13l9.38,0l7.81,-3.13l0,-6.25z"
android:strokeWidth="0.16"
android:fillAlpha="0.2"/>
<path
android:pathData="m45.25,40.56 l6.25,37.5l25,0l6.25,-37.5z"
android:strokeWidth="3.13"
android:fillColor="#ffffdf"
android:fillType="evenOdd"
android:strokeColor="#c1a551"/>
<path
android:pathData="m54.63,40.56 l3.13,37.5"
android:strokeWidth="3.13"
android:fillColor="#00000000"
android:strokeColor="#c1a551"/>
<path
android:pathData="m73.38,40.56 l-3.13,37.5"
android:strokeWidth="3.13"
android:fillColor="#00000000"
android:strokeColor="#c1a551"/>
<path
android:pathData="m64,18.69c-9.38,3.13 -15.63,15.63 -25,15.63l0,6.25l50,0l0,-6.25c-9.38,0 -15.63,-12.5 -25,-15.63zM51.5,78.06l0,6.25l7.81,3.13l0,21.65c1.54,0.14 3.11,0.23 4.69,0.23s3.14,-0.08 4.69,-0.23l0,-21.65l7.81,-3.13l0,-6.25z"
android:fillColor="#555"
android:fillType="evenOdd"/>
</vector>
25 changes: 25 additions & 0 deletions app/src/main/res/drawable/quest_street_cabinet_telecom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:strokeWidth="4"
android:pathData="M27.52,5.21l72.92,0l0,114.6l-72.92,0z"
android:fillColor="#aaa"
android:strokeColor="#333"/>
<path
android:pathData="m11.94,122.79l104.17,0"
android:strokeWidth="10.42"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:strokeWidth="1"
android:pathData="m11.89,119.8l104.17,0"
android:fillColor="#00000000"
android:strokeColor="#c87137"/>
<path
android:pathData="m49.44,39.04c-9.03,1.5 -10.39,6.75 -10.44,6.97 4.56,19.7 27.88,38.57 41.93,42.96 4.3,-0.05 7.87,-9.74 8.07,-10.85 -1.65,-3.25 -8.65,-8.34 -12.28,-8.07 -2.43,2.08 -5.79,4.29 -7.24,4.52 -9.72,-4.75 -15.15,-13.87 -15.35,-15.6 -0.12,-0.97 5.11,-5.48 4.89,-7.82 -2.12,-5.34 -5.64,-10.04 -9.57,-12.11z"
android:strokeWidth="0.59"
android:fillColor="#fc0"/>
</vector>
Loading

0 comments on commit afd1b0c

Please sign in to comment.