Skip to content

Commit

Permalink
minor adjustment to setting building properties
Browse files Browse the repository at this point in the history
fixes #3386
  • Loading branch information
matkoniecz committed Oct 16, 2021
1 parent 7977964 commit d5b55a6
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class AddBuildingType : OsmFilterQuestType<BuildingType>() {
changes.add("man_made", answer.osmValue)
} else if (answer.osmKey != "building") {
changes.addOrModify(answer.osmKey, answer.osmValue)
if(answer == BuildingType.ABANDONED) {
changes.deleteIfExists("disused")
}
if(answer == BuildingType.RUINS && changes.getPreviousValue("disused") == "no") {
changes.deleteIfExists("disused")
}
if(answer == BuildingType.RUINS && changes.getPreviousValue("abandoned") == "no") {
changes.deleteIfExists("disused")
}
} else {
changes.modify("building", answer.osmValue)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package de.westnordost.streetcomplete.quests.building_type

import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryAdd
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryDelete
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapEntryModify
import de.westnordost.streetcomplete.quests.verifyAnswer
import org.junit.Test

class AddBuildingTypeTest {
private val questType = AddBuildingType()

@Test
fun `set building as residential`() {
questType.verifyAnswer(
mapOf(
"building" to "yes",
),
BuildingType.RESIDENTIAL,
StringMapEntryModify("building", "yes", "residential"),
)
}

@Test
fun `set building as abandoned`() {
questType.verifyAnswer(
mapOf(
"building" to "yes",
),
BuildingType.ABANDONED,
StringMapEntryAdd("abandoned", "yes"),
)
}

@Test
fun `set building as abandoned and prevent double tagging`() {
// https://github.com/streetcomplete/StreetComplete/issues/3386
questType.verifyAnswer(
mapOf(
"building" to "yes",
"disused" to "yes",
),
BuildingType.ABANDONED,
StringMapEntryAdd("abandoned", "yes"),
StringMapEntryDelete("disused", "yes"),
)
}

@Test
fun `set building as abandoned where it was marked as used`() {
questType.verifyAnswer(
mapOf(
"building" to "yes",
"disused" to "no",
),
BuildingType.ABANDONED,
StringMapEntryAdd("abandoned", "yes"),
StringMapEntryDelete("disused", "no"),
)
}
}

0 comments on commit d5b55a6

Please sign in to comment.