Skip to content

Commit

Permalink
prohibited for pedestirans: clear sidewalk tags when user answers tha…
Browse files Browse the repository at this point in the history
…t there is a sidewalk (fixes #5952)
  • Loading branch information
westnordost committed Oct 24, 2024
1 parent cd3416b commit 4b85f34
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.
import de.westnordost.streetcomplete.osm.ROADS_ASSUMED_TO_BE_PAVED
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.osm.surface.PAVED_SURFACES
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.HAS_SEPARATE_SIDEWALK
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.ACTUALLY_HAS_SIDEWALK
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.NO
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.YES

Expand Down Expand Up @@ -59,9 +59,9 @@ class AddProhibitedForPedestrians : OsmFilterQuestType<ProhibitedForPedestriansA
// the question is whether it is prohibited, so YES -> foot=no etc
YES -> tags["foot"] = "no"
NO -> tags["foot"] = "yes"
HAS_SEPARATE_SIDEWALK -> {
tags["sidewalk:both"] = "separate"
// wrong tagging may exist, it should be removed to prevent quest from reappearing
// but we did not specify on which side. So, clear it, sidewalk is added separately
ACTUALLY_HAS_SIDEWALK -> {
tags.remove("sidewalk:both")
tags.remove("sidewalk")
tags.remove("sidewalk:left")
tags.remove("sidewalk:right")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package de.westnordost.streetcomplete.quests.foot
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AListQuestForm
import de.westnordost.streetcomplete.quests.TextItem
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.HAS_SEPARATE_SIDEWALK
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.ACTUALLY_HAS_SIDEWALK
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.NO
import de.westnordost.streetcomplete.quests.foot.ProhibitedForPedestriansAnswer.YES

Expand All @@ -12,6 +12,6 @@ class AddProhibitedForPedestriansForm : AListQuestForm<ProhibitedForPedestriansA
override val items = listOf(
TextItem(YES, R.string.quest_accessible_for_pedestrians_prohibited),
TextItem(NO, R.string.quest_accessible_for_pedestrians_allowed),
TextItem(HAS_SEPARATE_SIDEWALK, R.string.quest_accessible_for_pedestrians_separate_sidewalk),
TextItem(ACTUALLY_HAS_SIDEWALK, R.string.quest_accessible_for_pedestrians_sidewalk),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package de.westnordost.streetcomplete.quests.foot
enum class ProhibitedForPedestriansAnswer {
YES,
NO,
HAS_SEPARATE_SIDEWALK
ACTUALLY_HAS_SIDEWALK
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Before uploading your changes, the app checks with a &lt;a href=\"https://www.we
<string name="quest_accessible_for_pedestrians_title_prohibited">Are pedestrians forbidden to walk on this road without sidewalk here?</string>
<string name="quest_accessible_for_pedestrians_prohibited">It is forbidden.</string>
<string name="quest_accessible_for_pedestrians_allowed">It is allowed.</string>
<string name="quest_accessible_for_pedestrians_separate_sidewalk">Actually, there is a sidewalk, but it is displayed separately on the map.</string>
<string name="quest_accessible_for_pedestrians_sidewalk">Actually, there is a sidewalk.</string>

<string name="quest_address_title">"What’s the house number of this building?"</string>
<string name="quest_address_house_number_label">House number:</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,15 @@ class AddProhibitedForPedestriansTest {
)
}

@Test fun `apply separate sidewalk answer`() {
assertEquals(
setOf(StringMapEntryAdd("sidewalk:both", "separate")),
questType.answerApplied(HAS_SEPARATE_SIDEWALK)
)
}

@Test fun `remove wrong sidewalk tagging`() {
@Test fun `apply actually sidewalk answer clears all sidewalk tagging`() {
assertEquals(
setOf(
StringMapEntryModify("sidewalk:both", "yes", "separate"),
StringMapEntryDelete("sidewalk:both", "yes"),
StringMapEntryDelete("sidewalk:left", "yes"),
StringMapEntryDelete("sidewalk:right", "yes"),
StringMapEntryDelete("sidewalk", "both"),
),
questType.answerAppliedTo(HAS_SEPARATE_SIDEWALK, mapOf(
questType.answerAppliedTo(ACTUALLY_HAS_SIDEWALK, mapOf(
"sidewalk" to "both",
"sidewalk:left" to "yes",
"sidewalk:right" to "yes",
Expand Down

0 comments on commit 4b85f34

Please sign in to comment.