diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregation.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregation.kt index dc331a3b80..0576f5bd62 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregation.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregation.kt @@ -18,7 +18,13 @@ class AddCyclewaySegregation : OsmFilterQuestType() { (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 diff --git a/app/src/test/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregationTest.kt b/app/src/test/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregationTest.kt new file mode 100644 index 0000000000..23f964ef21 --- /dev/null +++ b/app/src/test/java/de/westnordost/streetcomplete/quests/segregated/AddCyclewaySegregationTest.kt @@ -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) + } +}