Skip to content

Commit

Permalink
fix mismatch, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Sep 27, 2023
1 parent 86c5922 commit c87aaf6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ val SOFT_SURFACES = setOf(
"earth", "dirt", "soil", "grass", "sand", "mud", "ice", "salt", "snow", "woodchips"
)

val ANYTHING_UNPAVED = SOFT_SURFACES + setOf(
val UNPAVED_BUT_NOT_ALWAYS_SOFT = setOf(
"ground", // see https://community.openstreetmap.org/t/is-tracktype-grade2-also-for-trails-with-large-naturally-occuring-pieces-of-rock/96850
"unpaved", "compacted", "gravel", "fine_gravel", "pebblestone", "grass_paver"
)

val ANYTHING_UNPAVED = SOFT_SURFACES + UNPAVED_BUT_NOT_ALWAYS_SOFT

val ANYTHING_FULLY_PAVED = setOf(
"paved", "asphalt", "cobblestone", "cobblestone:flattened", "sett",
"concrete", "concrete:plates", "paving_stones",
Expand All @@ -43,7 +45,7 @@ fun isSurfaceAndTracktypeConflicting(surface: String, tracktype: String?): Boole

val EXPECTED_SURFACES_FOR_TRACKTYPES = mapOf(
"grade1" to ANYTHING_FULLY_PAVED,
"grade2" to ANYTHING_UNPAVED,
"grade2" to UNPAVED_BUT_NOT_ALWAYS_SOFT,
"grade3" to ANYTHING_UNPAVED,
"grade4" to ANYTHING_UNPAVED,
"grade5" to SOFT_SURFACES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class SurfaceUtilsKtTest {
assertTrue(isSurfaceAndTracktypeCombinationSuspicious("paving_stones", "grade2"))
}

@Test fun `sand surface is conflicting and suspicious on tracktype=grade2`() {
assertTrue(isSurfaceAndTracktypeConflicting("sand", "grade2"))
assertTrue(isSurfaceAndTracktypeCombinationSuspicious("sand", "grade2"))
}

@Test fun `missing tracktype is not conflicting`() {
assertFalse(isSurfaceAndTracktypeConflicting("paving_stones", null))
assertFalse(isSurfaceAndTracktypeCombinationSuspicious("paving_stones", null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ class AddRoadSurfaceTest {
StringMapEntryDelete("smoothness", "good"),
)
}

@Test fun `tracktype tag is removed when surface match is conflicting`() {
questType.verifyAnswer(
mapOf(
"tracktype" to "grade2",
"smoothness" to "good"
),
SurfaceAndNote(Surface.SAND),
StringMapEntryAdd("surface", "sand"),
StringMapEntryDelete("tracktype", "grade2"),
StringMapEntryDelete("smoothness", "good"),
)
}
}

0 comments on commit c87aaf6

Please sign in to comment.