Skip to content

Commit

Permalink
Ask for the type of crossing for crossing=island (fixes #1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Dec 20, 2019
1 parent 8f8c518 commit a609da8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataAndGeometr

class AddCrossingType(o: OverpassMapDataAndGeometryDao) : SimpleOverpassQuestType<String>(o) {

override val tagFilters = "nodes with highway = crossing and !crossing"
override val tagFilters = "nodes with highway = crossing and (!crossing or crossing = island)"
override val commitMessage = "Add crossing type"
override val icon = R.drawable.ic_quest_pedestrian_crossing

Expand All @@ -16,6 +16,11 @@ class AddCrossingType(o: OverpassMapDataAndGeometryDao) : SimpleOverpassQuestTyp
override fun createForm() = AddCrossingTypeForm()

override fun applyAnswerTo(answer: String, changes: StringMapChangesBuilder) {
changes.add("crossing", answer)
if(changes.getPreviousValue("crossing") == "island") {
changes.modify("crossing", answer)
changes.addOrModify("crossing:island", "yes")
} else {
changes.add("crossing", answer)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package de.westnordost.streetcomplete.quests

import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryAdd
import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryModify
import de.westnordost.streetcomplete.mock
import de.westnordost.streetcomplete.quests.crossing_type.AddCrossingType
import org.junit.Test

class AddCrossingTypeTest {

private val questType = AddCrossingType(mock())

@Test fun `apply normal answer`() {
questType.verifyAnswer(
"bla",
StringMapEntryAdd("crossing", "bla")
)
}

@Test fun `apply answer for crossing = island`() {
questType.verifyAnswer(
mapOf("crossing" to "island"),
"blub",
StringMapEntryModify("crossing", "island", "blub"),
StringMapEntryAdd("crossing:island", "yes")
)
}

@Test fun `apply answer for crossing = island and crossing_island set`() {
questType.verifyAnswer(
mapOf("crossing" to "island", "crossing:island" to "something"),
"blub",
StringMapEntryModify("crossing", "island", "blub"),
StringMapEntryModify("crossing:island", "something", "yes")
)
}
}

0 comments on commit a609da8

Please sign in to comment.