Skip to content
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

Added quest for mtb:scale #5308

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
@@ -0,0 +1,9 @@
package de.westnordost.streetcomplete.osm.smoothness

val SMOOTHNESS_BAD_OR_WORSE_BUT_PASSABLE = setOf(
"bad", "very_bad", "horrible", "very_horrible"
)

val SMOOTHNESS_BAD_OR_WORSE = SMOOTHNESS_BAD_OR_WORSE_BUT_PASSABLE + setOf(
"impassable"
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ val SOFT_SURFACES = setOf(
"earth", "dirt", "soil", "grass", "sand", "mud", "ice", "salt", "snow", "woodchips"
)

val NATURAL_SURFACES = setOf(
"ground", "earth", "dirt", "soil", "grass", "sand", "mud", "ice", "salt", "snow"
)

val UNPAVED_BUT_NOT_ALWAYS_SOFT = setOf(
"ground", // see https://community.openstreetmap.org/t/is-tracktype-grade2-also-for-trails-with-large-naturally-occuring-pieces-of-rock/96850
"unpaved", "compacted", "gravel", "fine_gravel", "pebblestone", "grass_paver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import de.westnordost.streetcomplete.quests.max_weight.AddMaxWeight
import de.westnordost.streetcomplete.quests.memorial_type.AddMemorialType
import de.westnordost.streetcomplete.quests.motorcycle_parking_capacity.AddMotorcycleParkingCapacity
import de.westnordost.streetcomplete.quests.motorcycle_parking_cover.AddMotorcycleParkingCover
import de.westnordost.streetcomplete.quests.mtb_scale.AddMtbScale
import de.westnordost.streetcomplete.quests.oneway.AddOneway
import de.westnordost.streetcomplete.quests.oneway_suspects.AddSuspectedOneway
import de.westnordost.streetcomplete.quests.oneway_suspects.data.TrafficFlowSegmentsApi
Expand Down Expand Up @@ -498,6 +499,9 @@ fun questTypeRegistry(
147 to AddSidewalkSurface(),
148 to AddCyclewayWidth(arSupportChecker), // should be after cycleway segregation

// Mountain bike trails
160 to AddMtbScale(),

/* should best be after road surface because it excludes unpaved roads, also, need to search
* for the sign which is one reason why it is disabled by default */
149 to AddMaxSpeed(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.westnordost.streetcomplete.quests.mtb_scale

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.osm.surface.NATURAL_SURFACES
import de.westnordost.streetcomplete.osm.smoothness.SMOOTHNESS_BAD_OR_WORSE_BUT_PASSABLE
import de.westnordost.streetcomplete.osm.updateWithCheckDate

class AddMtbScale : OsmFilterQuestType<MtbScale>() {

override val elementFilter = """
ways with highway ~ path|track
and (
!mtb:scale
or mtb:scale older today -8 years
)
and (
surface ~ ${NATURAL_SURFACES.joinToString("|")}
or smoothness ~ ${SMOOTHNESS_BAD_OR_WORSE_BUT_PASSABLE.joinToString("|")}
)
and (access !~ private|no or (foot and foot !~ private|no) or (bicycle and bicycle !~ private|no))
and (sidewalk !~ both|left|right)
"""
override val changesetComment = "Specify MTB difficulty"
override val wikiLink = "Key:mtb:scale"
override val icon = R.drawable.ic_quest_mtb
override val achievements = listOf(BICYCLIST, OUTDOORS)
override val defaultDisabledMessage = R.string.default_disabled_msg_mtb

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

override fun createForm() = AddMtbScaleForm()

override fun applyAnswerTo(answer: MtbScale, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags.updateWithCheckDate("mtb:scale", answer.osmValue)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.westnordost.streetcomplete.quests.mtb_scale

import de.westnordost.streetcomplete.quests.AImageListQuestForm

class AddMtbScaleForm : AImageListQuestForm<MtbScale, MtbScale>() {

override val items = MtbScale.values().map { it.asItem() }

override val itemsPerRow = 3

override val moveFavoritesToFront = false

override fun onClickOk(selectedItems: List<MtbScale>) {
applyAnswer(selectedItems.single())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.westnordost.streetcomplete.quests.mtb_scale

enum class MtbScale(val osmValue: String) {
SCALE0("0"),
SCALE1("1"),
SCALE2("2"),
SCALE3("3"),
SCALE4("4"),
SCALE5("5"),
SCALE6("6"),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package de.westnordost.streetcomplete.quests.mtb_scale

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE0
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE1
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE2
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE3
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE4
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE5
import de.westnordost.streetcomplete.quests.mtb_scale.MtbScale.SCALE6
import de.westnordost.streetcomplete.view.image_select.Item

fun MtbScale.asItem() = Item(this, iconResId, titleResId)

private val MtbScale.titleResId: Int get() = when (this) {
SCALE0 -> R.string.quest_mtb_scale0
SCALE1 -> R.string.quest_mtb_scale1
SCALE2 -> R.string.quest_mtb_scale2
SCALE3 -> R.string.quest_mtb_scale3
SCALE4 -> R.string.quest_mtb_scale4
SCALE5 -> R.string.quest_mtb_scale5
SCALE6 -> R.string.quest_mtb_scale6
}

private val MtbScale.iconResId: Int get() = when (this) {
SCALE0 -> R.drawable.mtb_scale0
SCALE1 -> R.drawable.mtb_scale1
SCALE2 -> R.drawable.mtb_scale2
SCALE3 -> R.drawable.mtb_scale3
SCALE4 -> R.drawable.mtb_scale4
SCALE5 -> R.drawable.mtb_scale5
SCALE6 -> R.drawable.mtb_scale6
}
8 changes: 8 additions & 0 deletions app/src/main/res/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ memorial_type_stele_wooden.j… CC-BY-SA 3.0 Assenmacher https://commons.w
memorial_type_stele_stone.jpg CC-BY-SA 4.0 Alta Falisa https://commons.wikimedia.org/wiki/File:18_June_1815_%E2%80%93_Waterloo_%E2%80%93_27th_(Inniskilling)_Regiment_of_Foot,_stele.jpg modified by Matija Nalis to remove wreath
memorial_type_sculpture.jpg CC-BY-SA 4.0 Adrian Tync https://commons.wikimedia.org/wiki/File:Katowice_alpinists_monument.jpg

mtb_scale0.jpg Public Domain https://wiki.openstreetmap.org/wiki/File:Mtbscale_0_doubletrack.jpg (Anders Fougner)
mtb_scale1.jpg Public Domain https://wiki.openstreetmap.org/wiki/File:Mtbscale_1_path_portait.jpg (Anders Fougner)
mtb_scale2.jpg CC-BY-SA 3.0 https://wiki.openstreetmap.org/wiki/File:S2.jpg (Felix Hartmann)
mtb_scale3.jpg CC-BY-SA 3.0 https://wiki.openstreetmap.org/wiki/File:S3.jpg (Felix Hartmann)
mtb_scale4.jpg CC-BY-SA 3.0 https://wiki.openstreetmap.org/wiki/File:S4.jpg (Felix Hartmann)
mtb_scale5.jpg CC-BY-SA 3.0 https://wiki.openstreetmap.org/wiki/File:S5.jpg (Felix Hartmann)
mtb_scale6.jpg fair use https://unsplash.com/photos/EiJQdDI_t_Y (Maja Kochanowska)

location_nyan.png fair use see https://en.wikipedia.org/wiki/Nyan_Cat for context
car_nyan.png fair use see https://en.wikipedia.org/wiki/Nyan_Cat for context

Expand Down
Binary file added app/src/main/res/drawable-hdpi/mtb_scale0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/mtb_scale6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/mtb_scale6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/mtb_scale6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale4.jpg
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale5.jpg
Binary file added app/src/main/res/drawable-xxhdpi/mtb_scale6.jpg
Loading