Skip to content

Commit

Permalink
handle private springs
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Mar 31, 2023
1 parent bb5a344 commit a5a070e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ class AddDrinkingWater : OsmFilterQuestType<DrinkingWater>() {
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("""
nodes with
man_made = water_tap
or man_made = water_well
or natural = spring
or amenity = drinking_water
(
man_made = water_tap
or man_made = water_well
or natural = spring
or amenity = drinking_water
)
and access !~ private|no
""")

override fun createForm() = AddDrinkingWaterForm()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.westnordost.streetcomplete.quests.drinking_water

import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryAdd

Check failure on line 3 in app/src/test/java/de/westnordost/streetcomplete/quests/drinking_water/AddDrinkingWaterTest.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryDelete

Check failure on line 4 in app/src/test/java/de/westnordost/streetcomplete/quests/drinking_water/AddDrinkingWaterTest.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.osm.SURVEY_MARK_KEY

Check failure on line 5 in app/src/test/java/de/westnordost/streetcomplete/quests/drinking_water/AddDrinkingWaterTest.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.osm.nowAsCheckDateString

Check failure on line 6 in app/src/test/java/de/westnordost/streetcomplete/quests/drinking_water/AddDrinkingWaterTest.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.quests.TestMapDataWithGeometry
import de.westnordost.streetcomplete.quests.verifyAnswer

Check failure on line 8 in app/src/test/java/de/westnordost/streetcomplete/quests/drinking_water/AddDrinkingWaterTest.kt

View workflow job for this annotation

GitHub Actions / Kotlin

Unused import
import de.westnordost.streetcomplete.testutils.node
import org.junit.Assert
import org.junit.Test

class AddDrinkingWaterTest {
private val questType = AddDrinkingWater()

@Test
fun `applicable to springs`() {
val mapData = TestMapDataWithGeometry(
listOf(
node(1, tags = mapOf("natural" to "spring")),
),
)
Assert.assertEquals(1, questType.getApplicableElements(mapData).toList().size)
}

@Test
fun `not applicable to inaccessible springs`() {
val mapData = TestMapDataWithGeometry(
listOf(
node(1, tags = mapOf("natural" to "spring", "access" to "no")),
),
)
Assert.assertEquals(0, questType.getApplicableElements(mapData).toList().size)
}
}

0 comments on commit a5a070e

Please sign in to comment.