forked from streetcomplete/StreetComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
918050a
commit c00aaf0
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/AddBenchArmrestForm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/de/westnordost/streetcomplete/quests/bench_armrest/BenchArmrestAnswer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters