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

Do not ask for surface of complicated roads (which already have surface:lanes* taged) #5453

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bcf2199
surface road quest: skip surface:lanes* too
mnalis Jan 22, 2024
0e5d011
surface overlay: color surface:lanes* in black, same as other complex…
mnalis Jan 22, 2024
1ca1302
typo
mnalis Jan 22, 2024
e622c45
check if string is not null
mnalis Jan 22, 2024
f460fd0
always check for surface:lanes*
mnalis Jan 22, 2024
ac3d1c5
create tests for surface:lanes* tagging
mnalis Jan 24, 2024
f7ec889
never asks surface quest when surface:lanes* is present
mnalis Jan 25, 2024
99a9fd6
more tests for surface:lanes:*, both_ways
mnalis Jan 25, 2024
773325d
fix "Name contains illegal characters" (no ":" permitted in test name)
mnalis Jan 25, 2024
5aa1ff3
really always skip surface:lanes*
mnalis Jan 25, 2024
574b256
Revert "really always skip surface:lanes*"
mnalis Feb 5, 2024
d94e38e
Manually revert "never asks surface quest when surface:lanes* is pres…
mnalis Feb 5, 2024
771f658
do not ask for surface:note is sufrace:lanes* is present
mnalis Feb 5, 2024
568e5bc
move isComplexSurfaceLanes() to hasSurfaceLanes() in SurfaceUtils.kt
mnalis Feb 27, 2024
c98f5d2
updated tests
mnalis Feb 27, 2024
ea66699
reuse hasSurfaceLanes()
mnalis Feb 27, 2024
db7583d
better place to skip asking surface:note; update tests
mnalis Feb 27, 2024
1bfc7a9
whitespaces, comments
mnalis Feb 27, 2024
973bc54
fix tests
mnalis Feb 27, 2024
03a51b7
Test: not applicable to generic unpaved track with a note and nonconf…
mnalis Feb 13, 2024
3c23eb1
add missing include
mnalis Feb 27, 2024
69f1dfc
try to fix compilation failures
mnalis Feb 27, 2024
ea559ec
Merge branch 'upstream-westnordost' into complicated-surface-lanes
mnalis Feb 27, 2024
0f5f442
fix function names
mnalis Feb 27, 2024
082f908
re-remove tests removed in master
mnalis Feb 27, 2024
9341541
try to fix compilation
mnalis Feb 27, 2024
5a5aa3c
remove invalid chars from test
mnalis Feb 27, 2024
6d07d94
merge test rules
mnalis Feb 27, 2024
e1f7f24
comment out failing test for now
mnalis Feb 27, 2024
534bbe1
reenable failing test
mnalis Feb 27, 2024
32f7b35
fix incorrect test
mnalis Feb 27, 2024
d57bab6
cleanups, reordering
mnalis Feb 27, 2024
340045f
try better location for test
mnalis Feb 27, 2024
0116e21
did not compile, try better location for check
mnalis Feb 27, 2024
ab3405c
try override onClickOk logic
mnalis Feb 27, 2024
2cb0c1a
add missing parenthesis
mnalis Feb 27, 2024
40da2cf
move test to more reasonable place in collectSurfaceDescriptionIfNece…
mnalis Feb 28, 2024
0dea7bc
try to check hasSurfaceLanes with yet another way
mnalis Feb 28, 2024
0643958
if hasSurfaceLanes, save just surface without surface note
mnalis Feb 28, 2024
c41ff5c
try to check hasSurfaceLanes for overlay too
mnalis Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ fun getKeysAssociatedWithSurface(prefix: String = ""): Set<String> =
) +
getLastCheckDateKeys("${prefix}surface") +
getLastCheckDateKeys("${prefix}smoothness")

fun hasSurfaceLanes(tags: Map<String, String>): Boolean =
tags["surface:lanes"] != null || tags["surface:lanes:forward"] != null || tags["surface:lanes:backward"] != null || tags["surface:lanes:both_ways"] != null
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.osm.surface.Surface
import de.westnordost.streetcomplete.osm.surface.SurfaceAndNote
import de.westnordost.streetcomplete.osm.surface.asItem
import de.westnordost.streetcomplete.osm.surface.hasSurfaceLanes
import de.westnordost.streetcomplete.osm.surface.shouldBeDescribed
import de.westnordost.streetcomplete.osm.surface.toItems
import de.westnordost.streetcomplete.quests.surface.DescribeGenericSurfaceDialog
Expand Down Expand Up @@ -92,7 +93,7 @@ class SurfaceAndNoteViewController(
private fun collectSurfaceData(callback: (Surface, String?) -> Unit) {
ImageListPickerDialog(selectButton.context, items, cellLayoutId, 2) { item ->
val value = item.value
if (value != null && value.shouldBeDescribed) {
if (value != null && value.shouldBeDescribed && !hasSurfaceLanes(element.tags)) {
DescribeGenericSurfaceDialog(selectButton.context) { description ->
callback(item.value!!, description)
}.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.westnordost.streetcomplete.osm.isPrivateOnFoot
import de.westnordost.streetcomplete.osm.surface.Surface
import de.westnordost.streetcomplete.osm.surface.Surface.*
import de.westnordost.streetcomplete.osm.surface.SurfaceAndNote
import de.westnordost.streetcomplete.osm.surface.hasSurfaceLanes
import de.westnordost.streetcomplete.osm.surface.isComplete
import de.westnordost.streetcomplete.overlays.Color

Expand Down Expand Up @@ -66,7 +67,9 @@ val Surface.color get() = when (this) {
}

fun SurfaceAndNote?.getColor(element: Element): String =
if (this?.isComplete != true) {
if (hasSurfaceLanes(element.tags)) {
Color.BLACK // same as other complex surfaces, e.g. surface=unpaved with surface:note=*
} else if (this?.isComplete != true) {
// not set but indoor, private or just a "virtual" link -> do not highlight as missing
if (isIndoor(element.tags) || isPrivateOnFoot(element) || isLink(element.tags)) {
Color.INVISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class AddRoadSurface : OsmFilterQuestType<SurfaceAndNote>() {
surface ~ paved|unpaved|${INVALID_SURFACES.joinToString("|")}
and !surface:note
and !note:surface
and !surface:lanes
and !surface:lanes:forward
and !surface:lanes:backward
and !surface:lanes:both_ways
)
${INVALID_SURFACES_FOR_TRACKTYPES.map{tracktypeConflictClause(it)}.joinToString("\n")}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.osm.surface.SELECTABLE_WAY_SURFACES
import de.westnordost.streetcomplete.osm.surface.Surface
import de.westnordost.streetcomplete.osm.surface.SurfaceAndNote
import de.westnordost.streetcomplete.osm.surface.hasSurfaceLanes
import de.westnordost.streetcomplete.osm.surface.isSurfaceAndTracktypeConflicting
import de.westnordost.streetcomplete.osm.surface.toItems
import de.westnordost.streetcomplete.quests.AImageListQuestForm
Expand All @@ -17,8 +18,12 @@ class AddRoadSurfaceForm : AImageListQuestForm<Surface, SurfaceAndNote>() {
override fun onClickOk(selectedItems: List<Surface>) {
val surface = selectedItems.single()
confirmPotentialTracktypeMismatch(surface) {
collectSurfaceDescriptionIfNecessary(requireContext(), surface) { description ->
applyAnswer(SurfaceAndNote(surface, description))
if (hasSurfaceLanes(element.tags)) {
applyAnswer(SurfaceAndNote(surface, null))
} else {
collectSurfaceDescriptionIfNecessary(requireContext(), surface) { description ->
applyAnswer(SurfaceAndNote(surface, description))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class SurfaceColorMappingKtTest {
assertEquals(Color.BLACK, parseSurfaceAndNote(road.tags).getColor(road))
}

@Test fun `return black for complex forward surface lanes`() {
val road = way(tags = mapOf("surface:lanes:forward" to "asphalt"))
assertEquals(Color.BLACK, parseSurfaceAndNote(road.tags).getColor(road))
}

@Test fun `return black for complex surface lanes`() {
val road = way(tags = mapOf("surface:lanes" to "concrete|asphalt|asphalt"))
assertEquals(Color.BLACK, parseSurfaceAndNote(road.tags).getColor(road))
}

@Test fun `return invisible for unpaved with restricted access`() {
val road = way(tags = mapOf(
"access" to "private",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package de.westnordost.streetcomplete.quests.surface

import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryAdd
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryDelete
import de.westnordost.streetcomplete.osm.surface.Surface
import de.westnordost.streetcomplete.osm.surface.SurfaceAndNote
import de.westnordost.streetcomplete.quests.TestMapDataWithGeometry
import de.westnordost.streetcomplete.testutils.way
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue

Expand All @@ -12,6 +19,20 @@ class AddRoadSurfaceTest {
assertIsNotApplicable("highway" to "residential", "surface" to "asphalt")
}

@Test fun `applicable to old enough road with surface, regardless of existing surface lanes or notes`() {
val way = way(1L, listOf(1, 2, 3), mapOf(
"highway" to "residential",
"surface" to "paved",
"surface:lanes" to "asphalt|concrete",
"surface:note" to "wildly mixed asphalt, concrete, paving stones and sett",
"check_date:surface" to "2001-01-01"
), timestamp = nowAsEpochMilliseconds())
val mapData = TestMapDataWithGeometry(listOf(way))

assertEquals(1, questType.getApplicableElements(mapData).toList().size)
assertTrue(questType.isApplicableTo(way))
}

@Test fun `applicable to untagged surface`() {
assertIsApplicable("highway" to "residential")
}
Expand All @@ -28,6 +49,20 @@ class AddRoadSurfaceTest {
assertIsNotApplicable("highway" to "track", "surface" to "asphalt", "tracktype" to "grade1")
}

// see https://github.com/streetcomplete/StreetComplete/pull/5453#issuecomment-1911891944
@Test fun `not applicable to alternate tag for surface notes`() {
assertIsNotApplicable("highway" to "residential", "surface" to "paved", "note:surface" to "alternative note format, varying asphalt and concrete")
}
@Test fun `not applicable to tagged complex surface lanes with general surface tag`() {
assertIsNotApplicable("highway" to "residential", "surface" to "paved", "surface:lanes" to "concrete|asphalt|asphalt")
assertIsNotApplicable("highway" to "track", "surface" to "unpaved", "surface:lanes:forward" to "compacted", "surface:lanes:backward" to "gravel" )
assertIsNotApplicable("highway" to "residential", "surface" to "paved", "surface:lanes:both_ways" to "asphalt|concrete")
assertIsNotApplicable("highway" to "residential", "surface" to "asphalt", "surface:lanes" to "concrete|asphalt|asphalt")
}
@Test fun `applicable to tagged complex surface lanes without surface tag`() {
assertIsApplicable("highway" to "residential", "surface:lanes" to "concrete|asphalt|cobblestone")
}

@Test fun `applicable to surface tags not providing proper info`() {
assertIsApplicable("highway" to "residential", "surface" to "paved")
assertIsNotApplicable("highway" to "residential", "surface" to "paved", "surface:note" to "wildly mixed asphalt, concrete, paving stones and sett")
Expand All @@ -50,4 +85,9 @@ class AddRoadSurfaceTest {
@Test fun `not applicable where tracktype and very good surface match is suspicious, but not conflicting`() {
assertIsNotApplicable("highway" to "track", "surface" to "asphalt", "tracktype" to "grade2")
}

@Test fun `not applicable to generic unpaved track with a note and nonconflicting tracktype`() {
assertIsNotApplicable("highway" to "track", "surface" to "unpaved", "tracktype" to "grade3", "surface:note" to "varying patches with more and less gravel")
}

}