Skip to content

Add Guidepost Sports quest #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import de.westnordost.streetcomplete.quests.foot.AddProhibitedForPedestrians
import de.westnordost.streetcomplete.quests.fuel_service.AddFuelSelfService
import de.westnordost.streetcomplete.quests.general_fee.AddGeneralFee
import de.westnordost.streetcomplete.quests.grit_bin_seasonal.AddGritBinSeasonal
import de.westnordost.streetcomplete.quests.guidepost_sport.AddGuidepostSports
import de.westnordost.streetcomplete.quests.hairdresser.AddHairdresserCustomers
import de.westnordost.streetcomplete.quests.handrail.AddHandrail
import de.westnordost.streetcomplete.quests.healthcare_speciality.AddHealthcareSpeciality
Expand Down Expand Up @@ -589,6 +590,7 @@ fun getQuestTypeList(
EE_QUEST_OFFSET + 9 to AddTreeGenus(),
EE_QUEST_OFFSET + 26 to AddIsPharmacyDispensing(),
EE_QUEST_OFFSET + 28 to AddFootwayWidth(arSupportChecker),
EE_QUEST_OFFSET + 29 to AddGuidepostSports(),
EE_QUEST_OFFSET + 10 to OsmoseQuest(osmoseDao),
EE_QUEST_OFFSET + 11 to CustomQuest(customQuestList),
// POI quests
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package de.westnordost.streetcomplete.quests.guidepost_sport

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression
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.OsmElementQuestType
import de.westnordost.streetcomplete.osm.Tags

class AddGuidepostSports : OsmElementQuestType<GuidepostSportsAnswer> {

private val filter by lazy {
"""
nodes with
tourism = information
and information ~ guidepost|route_marker
and !hiking and !bicycle and !mtb and !climbing and !horse and !nordic_walking and !ski and !inline_skates and !running
and !disused
and !guidepost
""".toElementFilterExpression()
}

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not include this globally. We also have a lot of maps for cycle routes, but only a very small proportion overall. I would say that would be almost spammy even for SCEE. If you want to, you can edit the quest query individually. What do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this is ok too

override val changesetComment = "Specify what kind of guidepost"
override val wikiLink = "Tag:information=guidepost"
override val icon = R.drawable.ic_quest_guidepost_sport
override val isDeleteElementEnabled = true
override val defaultDisabledMessage = R.string.default_disabled_msg_ee

override fun getTitle(tags: Map<String, String>) = R.string.quest_guidepost_sports_title

override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable<Element> =
mapData.filter { isApplicableTo(it) == true }

override fun isApplicableTo(element: Element): Boolean? =
filter.matches(element)

override fun createForm() = AddGuidepostSportsForm()

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes with tourism = information and information ~ guidepost|route_marker")

override fun applyAnswerTo(
answer: GuidepostSportsAnswer,
tags: Tags,
geometry: ElementGeometry,
timestampEdited: Long
) {
answer.selectedSports.forEach { sport ->
tags[sport.key] = "yes"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.westnordost.streetcomplete.quests.guidepost_sport

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AImageListQuestForm
import de.westnordost.streetcomplete.view.image_select.ImageListPickerDialog
import de.westnordost.streetcomplete.view.image_select.Item

class AddGuidepostSportsForm : AImageListQuestForm<List<GuidepostSport>, GuidepostSportsAnswer>() {

override val descriptionResId = R.string.quest_recycling_materials_note

override val items get() = GuidepostSport.selectableValues.map { it.asItem() }
override val itemsPerRow = 3

override val maxSelectableItems = -1

private fun showPickItemForItemAtIndexDialog(index: Int, items: List<Item<List<GuidepostSport>>>) {
val ctx = context ?: return
ImageListPickerDialog(ctx, items, R.layout.cell_icon_select_with_label_below, 3) { selected ->
val newList = imageSelector.items.toMutableList()
newList[index] = selected
imageSelector.items = newList
}.show()
}

override fun onClickOk(selectedItems: List<List<GuidepostSport>>) {
val answer = SelectedGuidepostSports(selectedItems.flatten())
applyAnswer(answer)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.westnordost.streetcomplete.quests.guidepost_sport

enum class GuidepostSport(val key: String) {
HIKING("hiking"),
BICYCLE("bicycle"),
MTB("mtb"),
CLIMBING("climbing"),
HORSE("horse"),
NORDIC_WALKING("nordic_walking"),
SKI("ski"),
INLINE_SKATING("inline_skating"),
RUNNING("running"),
WINTER_HIKING("winter_hiking");

companion object {
val selectableValues = listOf(
HIKING, BICYCLE, MTB, CLIMBING, HORSE, NORDIC_WALKING, SKI, INLINE_SKATING, RUNNING, WINTER_HIKING
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.westnordost.streetcomplete.quests.guidepost_sport

sealed interface GuidepostSportsAnswer {
val selectedSports: List<GuidepostSport>
}

data class SelectedGuidepostSports(
override val selectedSports: List<GuidepostSport>
) : GuidepostSportsAnswer
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.westnordost.streetcomplete.quests.guidepost_sport

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.guidepost_sport.GuidepostSport.*
import de.westnordost.streetcomplete.view.image_select.Item

fun GuidepostSport.asItem(): Item<List<GuidepostSport>> =
Item(listOf(this), iconResId, titleResId)

private val GuidepostSport.iconResId: Int get() = when (this) {
HIKING -> R.drawable.ic_guidepost_hiking
BICYCLE -> R.drawable.ic_guidepost_cycling
MTB -> R.drawable.ic_guidepost_mtb
CLIMBING -> R.drawable.ic_guidepost_climbing
HORSE -> R.drawable.ic_guidepost_horse_riding
NORDIC_WALKING -> R.drawable.ic_guidepost_nordic_walking
SKI -> R.drawable.ic_guidepost_ski
INLINE_SKATING -> R.drawable.ic_guidepost_inline_skating
RUNNING -> R.drawable.ic_guidepost_running
WINTER_HIKING -> R.drawable.ic_guidepost_snow_shoe_hiking
}

private val GuidepostSport.titleResId: Int get() = when (this) {
HIKING -> R.string.quest_guidepost_sports_hiking
BICYCLE -> R.string.quest_guidepost_sports_bicycle
MTB -> R.string.quest_guidepost_sports_mtb
CLIMBING -> R.string.quest_guidepost_sports_climbing
HORSE -> R.string.quest_guidepost_sports_horse
NORDIC_WALKING -> R.string.quest_guidepost_sports_nordic_walking
SKI -> R.string.quest_guidepost_sports_ski
INLINE_SKATING -> R.string.quest_guidepost_sports_inline_skating
RUNNING -> R.string.quest_guidepost_sports_running
WINTER_HIKING -> R.string.quest_guidepost_sports_winter_hiking
}
108 changes: 108 additions & 0 deletions app/src/main/res/drawable/ic_guidepost_climbing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="96dp"
android:height="96dp"
android:viewportWidth="96"
android:viewportHeight="96">
<path
android:pathData="M669.2,2168.8H478.1c-14.7,0 -26.6,-11.9 -26.6,-26.6v-186.1c0,-14.7 11.9,-26.6 26.6,-26.6h100c0,0 32.2,3.8 30.2,13.3c-2.3,10.9 -16.3,45.8 -16.9,51.2c-1.1,10.8 31.5,29.2 29.9,41.8c-4.9,39.4 -23.3,54.8 -16.6,75.1c0.8,2.6 24.5,4.8 30.5,7.9C670.9,2137.7 670.6,2168.8 669.2,2168.8z"
android:fillColor="#66757F"/>
<path
android:pathData="M650.9,2168.8H478.1c-14.7,0 -26.6,-11.9 -26.6,-26.6v-186.1c0,-14.7 11.9,-26.6 26.6,-26.6h47.6c0,0 59.5,5.7 58.8,13.7c-1.1,12.3 -24.2,51.3 -16.7,58.6s29.5,25.2 30.4,36.8c1.2,14.9 -28.5,55.2 -12.7,88.4c5,10.6 33.6,6.4 42.1,12.3C648.6,2154.3 652.9,2168.8 650.9,2168.8z"
android:fillColor="#99AAB5"/>
<path
android:pathData="M649.3,2127.8c0,0 2.7,1.8 10.1,4.4c2.9,1 -0.3,12.2 -2,13.8s-14.5,4.2 -26.1,0.7c-10.6,-3.2 -2.7,-6.2 4.9,-7.9C643.9,2137 649.3,2127.8 649.3,2127.8z"
android:fillColor="#292F33"/>
<path
android:pathData="M639.7,2024.7c-7.2,3.6 -15.4,6.5 -19.1,5.4c-2.8,-0.8 -8.2,-2.5 -12.5,-2.5c-4.3,0 -5.1,2.3 -2.2,6.8c2.9,4.5 8.8,6.9 13.5,5.5c4.7,-1.4 15.1,-1.9 21.5,-2.1C647.3,2037.6 645.1,2022 639.7,2024.7L639.7,2024.7z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M636.6,2026.7c3.2,-1.7 8.9,-2.6 8.9,-2.6l6.2,-15.1l16.5,10.9c0,0 -11,12.9 -13.6,15.7c-2.7,2.8 -11.8,3 -17.2,2.3C631.8,2037 633,2028.6 636.6,2026.7L636.6,2026.7zM649.7,2103.5c0,0 -18.2,-12.4 -19.5,-7.2c-1.3,5.3 15,19.3 18.9,32.5c1.6,5.3 11.2,11.1 11.3,0.5C660.6,2111.2 649.7,2103.5 649.7,2103.5L649.7,2103.5z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M632.1,2099.1c0,0 5.8,11.6 11.7,10.4s21.4,-20 26.1,-27.1c4.7,-7.1 2.8,-24.4 -7.8,-16.1C651.6,2074.7 632.1,2099.1 632.1,2099.1z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M679,2075.4l-42.3,5.4l21.1,19.2L679,2075.4z"
android:fillColor="#A0041E"/>
<path
android:pathData="M635.1,2076.7c0,0 -15.7,14.3 -17.2,20.1c-1.4,5.7 0,24.4 -4.3,41.5c-4.3,17.2 7.2,20 8.6,14.3c1.4,-5.7 12.5,-31.5 10,-40.1c-1.8,-6.3 17.2,-20.1 17.2,-20.1L635.1,2076.7z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M649.6,2057.6c-8.6,5.6 -12.9,13.7 -24.8,26.9l15.9,17c0,0 40.1,-15.2 46.2,-35.6c5.3,-17.6 -9.9,-27.5 -9.9,-27.5S657.8,2052.3 649.6,2057.6L649.6,2057.6z"
android:fillColor="#BE1931"/>
<path
android:pathData="M670.4,1980l-1.6,15.5l-17.8,-2.9l0.1,-13.4L670.4,1980z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M673.8,1980.6c-6.3,8.3 -16.2,7.6 -25.5,5.9c-8.9,-1.5 -7.3,-17.8 -2.9,-27.1c4.4,-9.5 18.8,-10 26.3,-4.2C679.1,1960.9 680.1,1972.3 673.8,1980.6z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M620.7,1982.5c-6.3,-8.1 -17.5,-17.2 -18.6,-22.4c-1.4,-6.4 -1.1,-13 -10,-18.3c-5.6,-3.3 -1.8,5.9 -1,18.1c0.5,7 11.9,25 18.4,31.6c4.1,4.2 23,12.3 29.5,26.4c1.1,2.4 -0.1,5 3.3,10.4c5.6,8.9 11.9,18.9 7.4,29.3c19.8,1 36.4,-8.1 36.4,-8.1c-5.9,-15.4 -1.4,-28.8 -6.2,-40.9c-7.6,-19.1 -16.1,-19.9 -28.9,-17.3C641.2,1993.4 635.6,1987.6 620.7,1982.5L620.7,1982.5z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M648.2,2047.1c19.8,1 36.7,-5.7 36.7,-5.7c-1.5,-13.1 -0.2,-20.7 -5.1,-32.8c-0.9,-2.4 -2,-4.6 -3.3,-6.8c-0.1,1.7 -1,3 -4,2.4c-6.4,-1.3 -10.5,-8.5 -16.9,-12.6c-1.5,-0.1 -3.1,-0.1 -4.7,-0.2c5.1,4 7.2,14.4 4.2,21.9c-2.9,7.6 -9.8,7 -16.2,4.6c0.2,0.5 -3.8,6.4 -0.4,11.8C642,2035 648,2040.4 648.2,2047.1L648.2,2047.1z"
android:fillColor="#DD2E44"/>
<path
android:pathData="M613,2142.2c0,0 2.5,6.7 10.8,5.8c1.8,-0.2 -0.5,7.7 -2.6,9.7c-2.1,2 -22.6,11.4 -33,5.7c-10.3,-5.7 -2.3,-8 5.7,-10.3C602,2150.7 613,2142.2 613,2142.2L613,2142.2z"
android:fillColor="#292F33"/>
<path
android:pathData="M657.1,1949.1c13.2,-1.4 21.7,5.8 22.9,13.1c2.4,14.3 -6.7,25.9 -14.6,23.6c-3.5,-1 -6.4,-3.6 -7.1,-14.5c-0.6,-8.6 -2.2,-20.4 -13.1,-12C642.8,1961.4 648,1950.1 657.1,1949.1L657.1,1949.1z"
android:fillColor="#FFAC33"/>
<path
android:pathData="M672.4,1956.8c2,-3.4 11.6,-2.9 15.3,4.7s-4.6,21.1 -5.2,28.2c-0.6,7.1 3.3,7.9 3.2,9.5c-0.1,1.6 -4.2,5.7 -9.5,4.2c-5.4,-1.6 -18.5,-4.1 -8.3,-19.9C678.1,1967.5 672.4,1956.8 672.4,1956.8L672.4,1956.8z"
android:fillColor="#FFAC33"/>
<path
android:pathData="M493.6,1945.6h31.3c5.3,0 -14.7,21 -21.9,21S484.2,1945.6 493.6,1945.6zM522.4,1986.9h29.6c5,0 -16.3,19.6 -23,19.6C522.4,2006.5 513.9,1986.9 522.4,1986.9zM510.5,2047.5h60.6c8.6,0 -36.8,33.9 -44.3,33.9C519.4,2081.4 494.2,2047.5 510.5,2047.5zM472.6,2122.7h53.6c12.5,0 -21.8,30.1 -34,30.1S460.4,2122.7 472.6,2122.7z"
android:fillColor="#66757F"/>
<path
android:pathData="M81.1,88H17.3c-4.9,0 -8.9,-4 -8.9,-8.9V16.9c0,-4.9 4,-8.9 8.9,-8.9h33.4c0,0 10.8,1.3 10.1,4.4c-0.8,3.6 -5.5,15.3 -5.6,17.1c-0.4,3.6 10.5,9.8 10,14c-1.6,13.2 -7.8,18.3 -5.6,25.1c0.3,0.9 8.2,1.6 10.2,2.7C81.7,77.6 81.6,88 81.1,88z"
android:fillColor="#66757F"/>
<path
android:pathData="M75,88H17.3c-4.9,0 -8.9,-4 -8.9,-8.9V16.9c0,-4.9 4,-8.9 8.9,-8.9h15.9c0,0 19.9,1.9 19.6,4.6c-0.4,4.1 -8.1,17.1 -5.6,19.6s9.8,8.4 10.2,12.3c0.4,5 -9.5,18.4 -4.3,29.6c1.7,3.6 11.2,2.1 14.1,4.1C74.2,83.1 75.7,88 75,88z"
android:fillColor="#99AAB5"/>
<path
android:pathData="M74.5,74.3c0,0 0.9,0.6 3.4,1.5c1,0.3 -0.1,4.1 -0.7,4.6c-0.6,0.5 -4.9,1.4 -8.7,0.2c-3.5,-1.1 -0.9,-2.1 1.7,-2.7C72.7,77.4 74.5,74.3 74.5,74.3z"
android:fillColor="#292F33"/>
<path
android:pathData="M71.3,39.8c-2.4,1.2 -5.2,2.2 -6.4,1.8c-0.9,-0.3 -2.7,-0.8 -4.2,-0.8S59,41.5 60,43.1c1,1.5 2.9,2.3 4.5,1.8s5.1,-0.6 7.2,-0.7C73.8,44.1 73.1,38.9 71.3,39.8L71.3,39.8z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M70.3,40.5c1.1,-0.6 3,-0.9 3,-0.9l2.1,-5l5.5,3.6c0,0 -3.7,4.3 -4.6,5.2c-0.9,0.9 -3.9,1 -5.8,0.8C68.6,43.9 69.1,41.1 70.3,40.5L70.3,40.5zM74.6,66.2c0,0 -6.1,-4.2 -6.5,-2.4c-0.4,1.8 5,6.5 6.3,10.9c0.5,1.8 3.7,3.7 3.8,0.2C78.3,68.7 74.6,66.2 74.6,66.2L74.6,66.2z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M68.7,64.7c0,0 2,3.9 3.9,3.5c2,-0.4 7.2,-6.7 8.7,-9.1c1.6,-2.4 0.9,-8.2 -2.6,-5.4C75.2,56.5 68.7,64.7 68.7,64.7z"
android:fillColor="#F9CA55"/>
<path
android:pathData="M84.4,56.7l-14.2,1.8l7.1,6.4L84.4,56.7z"
android:fillColor="#A0041E"/>
<path
android:pathData="M69.8,57.2c0,0 -5.3,4.8 -5.7,6.7c-0.5,1.9 0,8.1 -1.4,13.9c-1.4,5.7 2.4,6.7 2.9,4.8c0.5,-1.9 4.2,-10.5 3.3,-13.4c-0.6,-2.1 5.7,-6.7 5.7,-6.7L69.8,57.2z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M74.6,50.8c-2.9,1.9 -4.3,4.6 -8.3,9l5.3,5.7c0,0 13.4,-5.1 15.5,-11.9c1.8,-5.9 -3.3,-9.2 -3.3,-9.2S77.3,49 74.6,50.8L74.6,50.8z"
android:fillColor="#BE1931"/>
<path
android:pathData="M81.6,24.9L81,30l-5.9,-1l0,-4.5L81.6,24.9z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M82.7,25c-2.1,2.8 -5.4,2.5 -8.5,2c-3,-0.5 -2.4,-5.9 -1,-9.1c1.5,-3.2 6.3,-3.3 8.8,-1.4C84.5,18.5 84.8,22.3 82.7,25z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M64.9,25.7c-2.1,-2.7 -5.8,-5.7 -6.2,-7.5c-0.5,-2.1 -0.4,-4.3 -3.3,-6.1c-1.9,-1.1 -0.6,2 -0.3,6c0.2,2.3 4,8.4 6.1,10.6c1.4,1.4 7.7,4.1 9.9,8.8c0.4,0.8 0,1.7 1.1,3.5c1.9,3 4,6.3 2.5,9.8c6.6,0.3 12.2,-2.7 12.2,-2.7c-2,-5.1 -0.5,-9.6 -2.1,-13.7c-2.6,-6.4 -5.4,-6.6 -9.7,-5.8C71.8,29.3 69.9,27.4 64.9,25.7L64.9,25.7z"
android:fillColor="#FFDC5D"/>
<path
android:pathData="M74.1,47.3c6.6,0.3 12.3,-1.9 12.3,-1.9c-0.5,-4.4 -0.1,-6.9 -1.7,-11c-0.3,-0.8 -0.7,-1.5 -1.1,-2.3c0,0.6 -0.3,1 -1.3,0.8c-2.2,-0.4 -3.5,-2.8 -5.6,-4.2c-0.5,0 -1,0 -1.6,-0.1c1.7,1.3 2.4,4.8 1.4,7.3c-1,2.5 -3.3,2.3 -5.4,1.5c0.1,0.2 -1.3,2.1 -0.1,3.9C72,43.2 74.1,45 74.1,47.3L74.1,47.3z"
android:fillColor="#DD2E44"/>
<path
android:pathData="M62.4,79.1c0,0 0.8,2.2 3.6,1.9c0.6,-0.1 -0.2,2.6 -0.9,3.2c-0.7,0.7 -7.6,3.8 -11,1.9c-3.5,-1.9 -0.8,-2.7 1.9,-3.5C58.7,81.9 62.4,79.1 62.4,79.1L62.4,79.1z"
android:fillColor="#292F33"/>
<path
android:pathData="M77.1,14.5c4.4,-0.5 7.2,1.9 7.7,4.4c0.8,4.8 -2.2,8.7 -4.9,7.9c-1.2,-0.3 -2.1,-1.2 -2.4,-4.9c-0.2,-2.9 -0.7,-6.8 -4.4,-4C72.3,18.6 74,14.9 77.1,14.5L77.1,14.5z"
android:fillColor="#FFAC33"/>
<path
android:pathData="M82.2,17.1c0.7,-1.1 3.9,-1 5.1,1.6c1.2,2.5 -1.6,7 -1.7,9.4s1.1,2.6 1.1,3.2s-1.4,1.9 -3.2,1.4c-1.8,-0.5 -6.2,-1.4 -2.8,-6.7C84.1,20.7 82.2,17.1 82.2,17.1L82.2,17.1z"
android:fillColor="#FFAC33"/>
<path
android:pathData="M22.4,13.4h10.5c1.8,0 -4.9,7 -7.3,7S19.3,13.4 22.4,13.4zM32.1,27.2H42c1.7,0 -5.5,6.6 -7.7,6.6C32.1,33.7 29.2,27.2 32.1,27.2zM28.1,47.4h20.3c2.9,0 -12.3,11.3 -14.8,11.3S22.6,47.4 28.1,47.4zM15.4,72.6h17.9c4.2,0 -7.3,10.1 -11.4,10.1S11.3,72.6 15.4,72.6z"
android:fillColor="#66757F"/>
</vector>
Loading