Skip to content

Commit

Permalink
no segregate quest on some rare weird cases
Browse files Browse the repository at this point in the history
still ask about segregation if segregated=* is not tagged and way has footway:surface or cycleway:surface

this allows to finish tagging where it is segregated and flag weird cases for followup checks with proper editor

fixes #5213
  • Loading branch information
matkoniecz committed Sep 2, 2023
1 parent ffb674d commit a0db1b4
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ class AddCyclewaySegregation : OsmFilterQuestType<CyclewaySegregation>() {
(highway = path and bicycle = designated and foot = designated)
or (highway = footway and bicycle = designated)
or (highway = cycleway and foot ~ designated|yes)
or highway ~ path|footway|cycleway and (footway:surface or cycleway:surface)
or
(
highway ~ path|footway|cycleway
and (footway:surface or cycleway:surface)
and foot !~ private|no
and bicycle !~ private|no
)
)
and surface ~ ${ANYTHING_PAVED.joinToString("|")}
and area != yes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package de.westnordost.streetcomplete.quests.segregated

import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryAdd
import de.westnordost.streetcomplete.quests.TestMapDataWithGeometry
import de.westnordost.streetcomplete.quests.verifyAnswer
import de.westnordost.streetcomplete.testutils.way
import kotlin.test.Test
import kotlin.test.assertEquals

class AddCyclewaySegregationTest {
private val questType = AddCyclewaySegregation()

@Test
fun `sets expected tags on yes answer`() {
questType.verifyAnswer(
mapOf(),
CyclewaySegregation.YES,
StringMapEntryAdd("segregated", "yes"),
)
}

@Test
fun `not applicable to greengrocer shops`() {
val mapData = TestMapDataWithGeometry(
listOf(
way(1, tags = mapOf("shop" to "greengrocer", "name" to "Foobar")),
),
)
assertEquals(0, questType.getApplicableElements(mapData).toList().size)
}

@Test
fun `not applicable to unpaved ways`() {
val mapData = TestMapDataWithGeometry(
listOf(
way(1, tags = mapOf(
"highway" to "path",
"foot" to "designated",
"bicycle" to "designated",
"surface" to "gravel",
)
),
),
)
assertEquals(0, questType.getApplicableElements(mapData).toList().size)
}

@Test
fun `applicable to matching paved ways`() {
val mapData = TestMapDataWithGeometry(
listOf(
way(1, tags = mapOf(
"highway" to "path",
"foot" to "designated",
"bicycle" to "designated",
"surface" to "asphalt",
)
),
),
)
assertEquals(1, questType.getApplicableElements(mapData).toList().size)
}

@Test
fun `applicable to ways which suggest split cycling and walking`() {
// ask about segregation if segregated=* is not tagged
// and way has footway:surface or cycleway:surface
// this allows to finish tagging where it is segregated (as it usual is)
// and review weird cases for followup checks
val mapData = TestMapDataWithGeometry(
listOf(
way(1, tags = mapOf(
"highway" to "path",
"footway:surface" to "asphalt",
"surface" to "asphalt",
)
),
),
)
assertEquals(1, questType.getApplicableElements(mapData).toList().size)
}

@Test
fun `not applicable to ways which ban cycling or walking`() {
val mapData = TestMapDataWithGeometry(
listOf(
way(1, tags = mapOf(
"highway" to "path",
"footway:surface" to "asphalt",
"surface" to "asphalt",
"foot" to "private",
)
),
),
)
assertEquals(0, questType.getApplicableElements(mapData).toList().size)
}
}

0 comments on commit a0db1b4

Please sign in to comment.