diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingType.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingType.kt index 2bf7aa5d30..f682903fba 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingType.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingType.kt @@ -45,6 +45,15 @@ class AddBuildingType : OsmFilterQuestType() { 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("abandoned") + } } else { changes.modify("building", answer.osmValue) } diff --git a/app/src/test/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingTypeTest.kt b/app/src/test/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingTypeTest.kt new file mode 100644 index 0000000000..85605905b6 --- /dev/null +++ b/app/src/test/java/de/westnordost/streetcomplete/quests/building_type/AddBuildingTypeTest.kt @@ -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"), + ) + } +}