Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect tactile paving option for crossings #3844

Merged
merged 4 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import de.westnordost.streetcomplete.data.osm.osmquests.Tags
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BLIND
import de.westnordost.streetcomplete.ktx.toYesNo

class AddTactilePavingBusStop : OsmFilterQuestType<Boolean>() {
class AddTactilePavingBusStop : OsmFilterQuestType<TactilePavingAnswer>() {

override val elementFilter = """
nodes, ways with
Expand Down Expand Up @@ -44,7 +44,7 @@ class AddTactilePavingBusStop : OsmFilterQuestType<Boolean>() {

override fun createForm() = TactilePavingForm()

override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.toYesNo())
override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.osmValue)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement
import de.westnordost.streetcomplete.ktx.toYesNo
import de.westnordost.streetcomplete.osm.isCrossing

class AddTactilePavingCrosswalk : OsmElementQuestType<Boolean> {
class AddTactilePavingCrosswalk : OsmElementQuestType<TactilePavingAnswer> {

private val crossingFilter by lazy { """
nodes with
Expand Down Expand Up @@ -61,7 +61,7 @@ class AddTactilePavingCrosswalk : OsmElementQuestType<Boolean> {

override fun createForm() = TactilePavingForm()

override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.toYesNo())
override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.osmValue)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import de.westnordost.streetcomplete.ktx.toYesNo
import de.westnordost.streetcomplete.osm.kerb.couldBeAKerb
import de.westnordost.streetcomplete.osm.kerb.findAllKerbNodes

class AddTactilePavingKerb : OsmElementQuestType<Boolean> {
class AddTactilePavingKerb : OsmElementQuestType<TactilePavingAnswer> {

private val eligibleKerbsFilter by lazy { """
nodes with
Expand Down Expand Up @@ -41,8 +41,8 @@ class AddTactilePavingKerb : OsmElementQuestType<Boolean> {
if (!eligibleKerbsFilter.matches(element) || element !is Node || !element.couldBeAKerb()) false
else null

override fun applyAnswerTo(answer: Boolean, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.toYesNo())
override fun applyAnswerTo(answer: TactilePavingAnswer, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("tactile_paving", answer.osmValue)
tags["barrier"] = "kerb"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.westnordost.streetcomplete.quests.tactile_paving

enum class TactilePavingAnswer(val osmValue: String) {
arrival-spring marked this conversation as resolved.
Show resolved Hide resolved
YES("yes"),
NO("no"),
INCORRECT("incorrect")
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
package de.westnordost.streetcomplete.quests.tactile_paving

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.mapdata.Node
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.YES
import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.NO
import de.westnordost.streetcomplete.quests.tactile_paving.TactilePavingAnswer.INCORRECT

class TactilePavingForm : AbstractQuestAnswerFragment<Boolean>() {
class TactilePavingForm : AbstractQuestAnswerFragment<TactilePavingAnswer>() {

override val contentLayoutResId = R.layout.quest_tactile_paving

override val otherAnswers get() = listOfNotNull(
createIncorrectAnswerItem()
)

private fun createIncorrectAnswerItem(): AnswerItem? {
val node = osmElement as? Node ?: return null
return if (node.tags["highway"] == "crossing" || node.tags["highway"] == "traffic_signals") {
AnswerItem(R.string.quest_tactilePaving_incorrect) { applyAnswer(INCORRECT) }
} else {
null
}
}

override val buttonPanelAnswers = listOf(
AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(false) },
AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(true) }
AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(NO) },
AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(YES) }
)
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ The info you enter is then directly added to the OpenStreetMap in your name, wit
<string name="quest_tactilePaving_title_bus">"Does this bus stop have tactile paving?"</string>
<string name="quest_tactilePaving_title_tram">"Does this streetcar stop have tactile paving?"</string>
<string name="quest_tactilePaving_title_crosswalk">"Does this crosswalk have tactile paving on both sides?"</string>
<string name="quest_tactilePaving_incorrect">"Only on one side"</string>
<string name="quest_source_dialog_title">Are you sure you checked this on-site?</string>
<string name="quest_source_dialog_note">Only information that was found on a survey should be entered.</string>
<string name="quest_tactilePaving_title_name_bus">"Does the bus stop %s have tactile paving?"</string>
Expand Down