From a4d2f0f349a926915268e273d06de40b2beb6f0e Mon Sep 17 00:00:00 2001 From: mcliquid Date: Sat, 28 Sep 2024 15:29:17 +0200 Subject: [PATCH 1/4] Add Swimming Pool Availability Quest Fixes #654 --- .../streetcomplete/quests/QuestsModule.kt | 2 + .../AddSwimmingPoolAvailability.kt | 39 +++++++++++++++++++ .../AddSwimmingPoolAvailabilityForm.kt | 18 +++++++++ .../SwimmingPoolAvailability.kt | 8 ++++ .../res/drawable/ic_quest_swimming_pool.xml | 12 ++++++ app/src/main/res/values/strings_ee.xml | 7 ++++ res/graphics/authors.txt | 1 + res/graphics/quest/swimming_pool.svg | 21 ++++++++++ 8 files changed, 108 insertions(+) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailabilityForm.kt create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/SwimmingPoolAvailability.kt create mode 100644 app/src/main/res/drawable/ic_quest_swimming_pool.xml create mode 100644 res/graphics/quest/swimming_pool.svg diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt index a8327c6c60..d088b6af6d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -220,6 +220,7 @@ import de.westnordost.streetcomplete.quests.trail_visibility.AddTrailVisibility import de.westnordost.streetcomplete.quests.tree.AddTreeGenus import de.westnordost.streetcomplete.quests.sac_scale.AddSacScale import de.westnordost.streetcomplete.quests.sauna_availability.AddSaunaAvailability +import de.westnordost.streetcomplete.quests.swimming_pool_availability.AddSwimmingPoolAvailability import de.westnordost.streetcomplete.quests.valves.AddValves import de.westnordost.streetcomplete.quests.via_ferrata_scale.AddViaFerrataScale import de.westnordost.streetcomplete.quests.way_lit.AddWayLit @@ -635,6 +636,7 @@ fun getQuestTypeList( EE_QUEST_OFFSET + 47 to AddParkingOrientation(), EE_QUEST_OFFSET + 50 to AddCaravanSiteType(), EE_QUEST_OFFSET + 52 to AddSaunaAvailability(), + EE_QUEST_OFFSET + 53 to AddSwimmingPoolAvailability(), EE_QUEST_OFFSET + 10 to OsmoseQuest(osmoseDao), EE_QUEST_OFFSET + 11 to CustomQuest(customQuestList), // POI quests diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt new file mode 100644 index 0000000000..b59919a38d --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt @@ -0,0 +1,39 @@ +package de.westnordost.streetcomplete.quests.swimming_pool_availability + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.Element +import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry +import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.osm.isPlaceOrDisusedPlace +import de.westnordost.streetcomplete.osm.updateWithCheckDate + +class AddSwimmingPoolAvailability : OsmFilterQuestType() { + + override val elementFilter = """ + nodes, ways with + ( + leisure ~ resort + or leisure = sports_hall and sport = swimming + or tourism ~ camp_site|hotel + ) + and !swimming_pool + """ + override val changesetComment = "Survey whether places have a swimming pool" + override val wikiLink = "Key:swimming_pool" + override val icon = R.drawable.ic_quest_swimming_pool + override val isReplacePlaceEnabled = true + override val defaultDisabledMessage = R.string.default_disabled_msg_ee + + override fun getTitle(tags: Map) = R.string.quest_swimmingPoolAvailability_title + + override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = + getMapData().asSequence().filter { it.isPlaceOrDisusedPlace() } + + override fun createForm() = AddSwimmingPoolAvailabilityForm() + + override fun applyAnswerTo(answer: SwimmingPoolAvailability, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { + tags.updateWithCheckDate("swimming_pool", answer.osmValue) + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailabilityForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailabilityForm.kt new file mode 100644 index 0000000000..1a76526bfb --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailabilityForm.kt @@ -0,0 +1,18 @@ +package de.westnordost.streetcomplete.quests.swimming_pool_availability + +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.quests.AListQuestForm +import de.westnordost.streetcomplete.quests.TextItem +import de.westnordost.streetcomplete.quests.swimming_pool_availability.SwimmingPoolAvailability.INDOOR_AND_OUTDOOR +import de.westnordost.streetcomplete.quests.swimming_pool_availability.SwimmingPoolAvailability.NO +import de.westnordost.streetcomplete.quests.swimming_pool_availability.SwimmingPoolAvailability.ONLY_INDOOR +import de.westnordost.streetcomplete.quests.swimming_pool_availability.SwimmingPoolAvailability.ONLY_OUTDOOR + +class AddSwimmingPoolAvailabilityForm : AListQuestForm() { + override val items = listOf( + TextItem(INDOOR_AND_OUTDOOR, R.string.quest_swimming_pool_indoor_and_outdoor), + TextItem(ONLY_INDOOR, R.string.quest_swimming_pool_indoor_only), + TextItem(ONLY_OUTDOOR, R.string.quest_swimming_pool_outdoor_only), + TextItem(NO, R.string.quest_swimming_pool_no), + ) +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/SwimmingPoolAvailability.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/SwimmingPoolAvailability.kt new file mode 100644 index 0000000000..b7bc654f17 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/SwimmingPoolAvailability.kt @@ -0,0 +1,8 @@ +package de.westnordost.streetcomplete.quests.swimming_pool_availability + +enum class SwimmingPoolAvailability(val osmValue: String) { + NO("no"), + ONLY_INDOOR("indoor"), + ONLY_OUTDOOR("outdoor"), + INDOOR_AND_OUTDOOR("indoor;outdoor"), +} diff --git a/app/src/main/res/drawable/ic_quest_swimming_pool.xml b/app/src/main/res/drawable/ic_quest_swimming_pool.xml new file mode 100644 index 0000000000..4b2bf52776 --- /dev/null +++ b/app/src/main/res/drawable/ic_quest_swimming_pool.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/values/strings_ee.xml b/app/src/main/res/values/strings_ee.xml index b7c86b4880..372faf4189 100644 --- a/app/src/main/res/values/strings_ee.xml +++ b/app/src/main/res/values/strings_ee.xml @@ -325,6 +325,13 @@ Is there a sauna here? + + Is there a swimming pool here? + Both, indoor and outdoor + Only indoor + Only outdoor + No swimming pool + What kind of service building is this? Electrical substation diff --git a/res/graphics/authors.txt b/res/graphics/authors.txt index d04790949e..61aaf598b4 100644 --- a/res/graphics/authors.txt +++ b/res/graphics/authors.txt @@ -398,6 +398,7 @@ quest/ summit_cross.svg based on peak.svg which is (c) 2020 Mateusz Konieczny and Tobias Zwick (CC-BY-SA 4.0), with cross added by Flo Edelmann (so also CC-BY-SA 4.0) surveillance.svg surveillance_camera.svg + swimming_pool.svg modified by mcliquid based on Kocio CC0 1.0 from https://wiki.openstreetmap.org/wiki/File:Swimming-16.svg tent.svg toilets.svg toilet_fee.svg diff --git a/res/graphics/quest/swimming_pool.svg b/res/graphics/quest/swimming_pool.svg new file mode 100644 index 0000000000..531c8aaf4e --- /dev/null +++ b/res/graphics/quest/swimming_pool.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file From 3995c9a667ec683c6f851c594f6d00be1859db5c Mon Sep 17 00:00:00 2001 From: mcliquid Date: Sat, 28 Sep 2024 18:08:02 +0200 Subject: [PATCH 2/4] Fixed element filter --- .../swimming_pool_availability/AddSwimmingPoolAvailability.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt index b59919a38d..12cccd1ada 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt @@ -14,8 +14,8 @@ class AddSwimmingPoolAvailability : OsmFilterQuestType override val elementFilter = """ nodes, ways with ( - leisure ~ resort - or leisure = sports_hall and sport = swimming + leisure = resort + or (leisure = sports_hall and sport = swimming) or tourism ~ camp_site|hotel ) and !swimming_pool From 4ee73a253cf7101a55732fe0cd127b44e11775dc Mon Sep 17 00:00:00 2001 From: mcliquid Date: Sun, 29 Sep 2024 13:28:00 +0200 Subject: [PATCH 3/4] Add brackets for string --- app/src/main/res/values/strings_ee.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings_ee.xml b/app/src/main/res/values/strings_ee.xml index 372faf4189..c4dd52b6d4 100644 --- a/app/src/main/res/values/strings_ee.xml +++ b/app/src/main/res/values/strings_ee.xml @@ -327,7 +327,7 @@ Is there a swimming pool here? - Both, indoor and outdoor + Both (indoor and outdoor) Only indoor Only outdoor No swimming pool From d9384191253bf2a317f452eed9e88dbbd33fb419 Mon Sep 17 00:00:00 2001 From: mcliquid Date: Sun, 29 Sep 2024 13:28:16 +0200 Subject: [PATCH 4/4] Add swimming pools to highlighted elements filter --- .../AddSwimmingPoolAvailability.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt index 12cccd1ada..7b577e3d44 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/swimming_pool_availability/AddSwimmingPoolAvailability.kt @@ -4,6 +4,7 @@ import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry import de.westnordost.streetcomplete.data.osm.mapdata.Element import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry +import de.westnordost.streetcomplete.data.osm.mapdata.filter import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType import de.westnordost.streetcomplete.osm.Tags import de.westnordost.streetcomplete.osm.isPlaceOrDisusedPlace @@ -29,7 +30,14 @@ class AddSwimmingPoolAvailability : OsmFilterQuestType override fun getTitle(tags: Map) = R.string.quest_swimmingPoolAvailability_title override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = - getMapData().asSequence().filter { it.isPlaceOrDisusedPlace() } + getMapData().filter(""" + nodes, ways with + ( + leisure ~ resort|swimming_pool + or (leisure = sports_hall and sport = swimming) + or tourism ~ camp_site|hotel + ) + """) override fun createForm() = AddSwimmingPoolAvailabilityForm()