diff --git a/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt index c8499669f9..fc0e173047 100644 --- a/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt +++ b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt @@ -124,6 +124,7 @@ import de.westnordost.streetcomplete.quests.moped.AddMopedAccess import de.westnordost.streetcomplete.quests.motorcycle_parking_capacity.AddMotorcycleParkingCapacity import de.westnordost.streetcomplete.quests.motorcycle_parking_cover.AddMotorcycleParkingCover import de.westnordost.streetcomplete.quests.note_discussion.OsmNoteQuestType +import de.westnordost.streetcomplete.quests.oneway.AddCyclewayDirection import de.westnordost.streetcomplete.quests.oneway.AddOneway import de.westnordost.streetcomplete.quests.oneway.AddOnewayAerialway import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHours @@ -554,6 +555,7 @@ fun questTypeRegistry( // footways 143 to AddPathSurface(), // used by OSM Carto, BRouter, OsmAnd, OSRM, graphhopper... 144 to AddCyclewaySegregation(), // Cyclosm, Valhalla, Bike Citizens Bicycle Navigation... + 198 to AddCyclewayDirection(), 145 to AddFootwayPartSurface(), 146 to AddCyclewayPartSurface(), 147 to AddSidewalkSurface(), diff --git a/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirection.kt b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirection.kt new file mode 100644 index 0000000000..f013862784 --- /dev/null +++ b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirection.kt @@ -0,0 +1,65 @@ +package de.westnordost.streetcomplete.quests.oneway + +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.quest.AndroidQuest +import de.westnordost.streetcomplete.data.quest.NoCountriesExcept +import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST +import de.westnordost.streetcomplete.osm.Tags +import de.westnordost.streetcomplete.quests.oneway.OnewayAnswer.BACKWARD +import de.westnordost.streetcomplete.quests.oneway.OnewayAnswer.FORWARD +import de.westnordost.streetcomplete.quests.oneway.OnewayAnswer.NO_ONEWAY +import de.westnordost.streetcomplete.resources.Res +import de.westnordost.streetcomplete.resources.default_disabled_msg_maxspeed +import de.westnordost.streetcomplete.resources.quest_arrow_tutorial +import de.westnordost.streetcomplete.resources.quest_cycleway_direction_title + +class AddCyclewayDirection : OsmFilterQuestType(), AndroidQuest { + + override val elementFilter = """ + ways with + highway ~ path|footway|cycleway + and (footway = sidewalk or is_sidepath = yes) + and bicycle ~ yes|designated + and !oneway + and !oneway:bicycle + and area != yes + and junction != roundabout + and access !~ private|no + """ + + override val changesetComment = "Specify in which direction cyclists may ride this path" + override val wikiLink = "Key:oneway:bicycle" + override val icon = R.drawable.quest_bicycleway_oneway + override val title = Res.string.quest_cycleway_direction_title + override val hasMarkersAtEnds = true + override val achievements = listOf(BICYCLIST) + override val hint = Res.string.quest_arrow_tutorial + override val defaultDisabledMessage = Res.string.default_disabled_msg_visible_sign_bicycle_sidewalk_access + override val enabledInCountries = NoCountriesExcept("DE", "AT", "DK", "NL", "FI", "NO") + + override fun createForm() = AddCyclewayDirectionForm() + + override fun applyAnswerTo( + answer: OnewayAnswer, + tags: Tags, + geometry: ElementGeometry, + timestampEdited: Long, + ) { + val key = if (tags["highway"] == "cycleway" && + tags["foot"] !in setOf("yes", "designated") && + tags["segregated"] != "yes" + ) { + "oneway" + } else { + "oneway:bicycle" + } + + tags[key] = when (answer) { + FORWARD -> "yes" + BACKWARD -> "-1" + NO_ONEWAY -> "no" + } + } +} diff --git a/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirectionForm.kt b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirectionForm.kt new file mode 100644 index 0000000000..1a79ddbe7a --- /dev/null +++ b/app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/oneway/AddCyclewayDirectionForm.kt @@ -0,0 +1,39 @@ +package de.westnordost.streetcomplete.quests.oneway + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import de.westnordost.streetcomplete.quests.AItemSelectQuestForm +import de.westnordost.streetcomplete.resources.Res +import de.westnordost.streetcomplete.resources.quest_cycleway_direction_dir +import de.westnordost.streetcomplete.resources.quest_cycleway_direction_no_oneway +import de.westnordost.streetcomplete.ui.common.item_select.ImageWithLabel +import de.westnordost.streetcomplete.ui.util.ClipCirclePainter +import kotlinx.serialization.serializer +import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.painterResource +import org.jetbrains.compose.resources.stringResource + +class AddCyclewayDirectionForm : AItemSelectQuestForm() { + + override val items = OnewayAnswer.entries + override val itemsPerRow = 3 + override val serializer = serializer() + + @Composable override fun ItemContent(item: OnewayAnswer) { + val painter = painterResource(item.icon) + ImageWithLabel( + painter = remember(painter) { ClipCirclePainter(painter) }, + label = stringResource(item.cyclewayDirectionTitle), + imageRotation = geometryRotation.floatValue - mapRotation.floatValue, + ) + } + + override fun onClickOk(selectedItem: OnewayAnswer) { + applyAnswer(selectedItem) + } +} + +private val OnewayAnswer.cyclewayDirectionTitle: StringResource get() = when (this) { + OnewayAnswer.FORWARD, OnewayAnswer.BACKWARD -> Res.string.quest_cycleway_direction_dir + OnewayAnswer.NO_ONEWAY -> Res.string.quest_cycleway_direction_no_oneway +} diff --git a/app/src/commonMain/composeResources/values-de/strings.xml b/app/src/commonMain/composeResources/values-de/strings.xml index 4263109ea9..9545f501df 100644 --- a/app/src/commonMain/composeResources/values-de/strings.xml +++ b/app/src/commonMain/composeResources/values-de/strings.xml @@ -699,6 +699,10 @@ Erfolge Ist dies eine Einbahnstraße? In welche Richtung? Einbahn­straße in diese Richtung Keine Einbahn­straße + In welche Richtung darf man mit dem Fahrrad auf diesem Bürgersteig fahren? + Nur in diese Richtung + In beide Richtungen + Dieser Aufgabentyp ist standardmäßig deaktiviert, da der Zugang für für Fahrräder auf dem Bürgersteig nur durch bestimmte Schilder am Anfang/Ende einer Straße gekennzeichnet ist. Welche Richtung führt hier nach oben? Hier nach oben Wie viele Stufen gibt es hier? @@ -1504,4 +1508,4 @@ Zum Beispiel 1,3 oder 2b,4,6. Kann man hier warm duschen? Neues OSM-Event in deiner Gegend! Neue OSM-Events in deiner Gegend - \ No newline at end of file + diff --git a/app/src/commonMain/composeResources/values-en/strings.xml b/app/src/commonMain/composeResources/values-en/strings.xml index ae6c346405..dcaa56f371 100644 --- a/app/src/commonMain/composeResources/values-en/strings.xml +++ b/app/src/commonMain/composeResources/values-en/strings.xml @@ -1313,6 +1313,12 @@ If there are no signs along the whole street which apply for the highlighted sec Is this a one-way street? In which direction? Oneway in this direction Not a oneway + In what direction are you allowed to cycle on this sidewalk? + Only this way + In both directions + + This quest type is disabled by default because bicycle access on sidewalks is only indicated by specific signs at start/end of a sidewalk. + What are the opening hours here? Are the opening hours here signed? diff --git a/app/src/commonMain/composeResources/values/strings.xml b/app/src/commonMain/composeResources/values/strings.xml index acdcfe7354..899afb126b 100644 --- a/app/src/commonMain/composeResources/values/strings.xml +++ b/app/src/commonMain/composeResources/values/strings.xml @@ -1315,6 +1315,11 @@ If there are no signs along the whole street which apply for the highlighted sec Is this a one-way street? In which direction? Oneway in this direction Not a oneway + In what direction are you allowed to cycle on this sidewalk? + Only this direction + In both directions + + This quest type is disabled by default because bicycle access on sidewalks is only indicated by specific signs at start/end of a sidewalk. What are the opening hours here? Are the opening hours here signed?