Skip to content

Commit

Permalink
Add new quest for bench armrests
Browse files Browse the repository at this point in the history
  • Loading branch information
bompstable committed Jun 4, 2024
1 parent 918050a commit c00aaf0
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import de.westnordost.streetcomplete.quests.barrier_type.AddBarrierType
import de.westnordost.streetcomplete.quests.barrier_type.AddStileType
import de.westnordost.streetcomplete.quests.bbq_fuel.AddBbqFuel
import de.westnordost.streetcomplete.quests.bench_backrest.AddBenchBackrest
import de.westnordost.streetcomplete.quests.bench_armrest.AddBenchArmrest
import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity
import de.westnordost.streetcomplete.quests.bike_parking_cover.AddBikeParkingCover
import de.westnordost.streetcomplete.quests.bike_parking_type.AddBikeParkingType
Expand Down Expand Up @@ -266,6 +267,7 @@ fun questTypeRegistry(
9 to AddCarWashType(),

10 to AddBenchBackrest(),
170 to AddBenchArmrest(),
11 to AddAmenityCover(getFeature),

12 to AddBridgeStructure(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package de.westnordost.streetcomplete.quests.bench_armrest

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.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.PEDESTRIAN
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.NO
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.PICNIC_TABLE
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.YES

class AddBenchArmrest : OsmFilterQuestType<BenchArmrestAnswer>() {

override val elementFilter = """
nodes, ways with
amenity = bench
and (!area or area = no)
and !armrest
and !bench:type
and (!seasonal or seasonal = no)
and access !~ private|no
"""
override val changesetComment = "Survey whether benches have armrests"
override val wikiLink = "Key:armrest"
override val icon = R.drawable.ic_quest_bench_poi
override val isDeleteElementEnabled = true
override val achievements = listOf(PEDESTRIAN, OUTDOORS)

override val hint = R.string.quest_bench_armrest_description

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes, ways with amenity = bench or leisure = picnic_table")

override fun createForm() = AddBenchArmrestForm()

override fun applyAnswerTo(answer: BenchArmrestAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
PICNIC_TABLE -> {
tags["leisure"] = "picnic_table"
tags.remove("amenity")
}
YES -> tags["armrest"] = "yes"
NO -> tags["armrest"] = "no"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.westnordost.streetcomplete.quests.bench_armrest

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.NO
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.PICNIC_TABLE
import de.westnordost.streetcomplete.quests.bench_armrest.BenchArmrestAnswer.YES

class AddBenchArmrestForm : AbstractOsmQuestForm<BenchArmrestAnswer>() {

override val buttonPanelAnswers = listOf(
AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) },
AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) }
)

override val otherAnswers = listOf(
AnswerItem(R.string.quest_bench_answer_picnic_table) { applyAnswer(PICNIC_TABLE) }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package de.westnordost.streetcomplete.quests.bench_armrest

enum class BenchArmrestAnswer { YES, NO, PICNIC_TABLE }
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ Before uploading your changes, the app checks with a &lt;a href=\"https://www.we
<string name="quest_barrier_type_passage_conversion">Converted into a passage in a wall/fence/etc.</string>
<string name="quest_barrier_type_gate_conversion">Converted into a gate</string>

<string name="quest_bench_armrest_title">Does this bench have any armrests?</string>
<string name="quest_bench_armrest_description">It does not matter how many armrests the bench has or where they are on the bench.</string>

<string name="quest_bench_backrest_title">Does this bench have a backrest?</string>
<string name="quest_bench_answer_picnic_table">It’s a picnic table</string>

Expand Down

0 comments on commit c00aaf0

Please sign in to comment.