Skip to content

Commit

Permalink
Redo crossing quests (#5471)
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost authored Feb 5, 2024
1 parent 6a294cc commit 312dd41
Show file tree
Hide file tree
Showing 33 changed files with 319 additions and 361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.westnordost.streetcomplete.overlays.street_parking.StreetParkingOverla
import de.westnordost.streetcomplete.quests.amenity_cover.AddAmenityCover
import de.westnordost.streetcomplete.quests.amenity_indoor.AddIsAmenityIndoor
import de.westnordost.streetcomplete.quests.building_type.AddBuildingType
import de.westnordost.streetcomplete.quests.crossing_markings.AddCrossingMarkings
import de.westnordost.streetcomplete.quests.cycleway.AddCycleway
import de.westnordost.streetcomplete.quests.foot.AddProhibitedForPedestrians
import de.westnordost.streetcomplete.quests.oneway.AddOneway
Expand Down Expand Up @@ -53,6 +54,7 @@ private val typeAliases = listOf(
"AddTrafficSignalsBlindFeatures" to AddTrafficSignalsVibration::class.simpleName!!,
"AddSuspectedOneway" to AddOneway::class.simpleName!!,
"AddPicnicTableCover" to AddAmenityCover::class.simpleName!!,
"AddCrossingType" to AddCrossingMarkings::class.simpleName!!,
// whether lit roads have been added in context of the quest or the overlay should not matter for the statistics
"WayLitOverlay" to AddWayLit::class.simpleName!!,
"SidewalkOverlay" to AddSidewalk::class.simpleName!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private val isCrossingWithTrafficSignalsExpr by lazy { """
highway ~ crossing|traffic_signals
and (
crossing = traffic_signals
or crossing:signals = yes
or crossing:signals and crossing:signals != no
)
""".toElementFilterExpression() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ import de.westnordost.streetcomplete.quests.construction.MarkCompletedHighwayCon
import de.westnordost.streetcomplete.quests.crossing.AddCrossing
import de.westnordost.streetcomplete.quests.crossing_island.AddCrossingIsland
import de.westnordost.streetcomplete.quests.crossing_kerb_height.AddCrossingKerbHeight
import de.westnordost.streetcomplete.quests.crossing_type.AddCrossingType
import de.westnordost.streetcomplete.quests.crossing_markings.AddCrossingMarkings
import de.westnordost.streetcomplete.quests.crossing_signals.AddCrossingSignals
import de.westnordost.streetcomplete.quests.cycleway.AddCycleway
import de.westnordost.streetcomplete.quests.defibrillator.AddDefibrillatorLocation
import de.westnordost.streetcomplete.quests.diet_type.AddHalal
Expand Down Expand Up @@ -317,8 +318,9 @@ fun questTypeRegistry(

// crossing quests: A little later because they are not all solvable from a distance
38 to AddCrossing(),
164 to AddCrossingSignals(),
39 to AddCrossingIsland(), // can be done at a glance
40 to AddCrossingType(),
163 to AddCrossingMarkings(),
41 to AddTactilePavingCrosswalk(),
159 to AddCrossingKerbHeight(),
42 to AddTrafficSignalsSound(), // Sound needs to be done as or after you're crossing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class AddCrossingIsland : OsmElementQuestType<Boolean> {
nodes with
highway = crossing
and foot != no
and crossing
and crossing != island
and !crossing:island
and crossing != island
""".toElementFilterExpression() }

private val excludedWaysFilter by lazy { """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.westnordost.streetcomplete.quests.crossing_type
package de.westnordost.streetcomplete.quests.crossing_markings

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression
Expand All @@ -11,40 +11,38 @@ import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.osm.isCrossing
import de.westnordost.streetcomplete.osm.updateCheckDateForKey
import de.westnordost.streetcomplete.osm.updateWithCheckDate
import de.westnordost.streetcomplete.quests.YesNoQuestForm
import de.westnordost.streetcomplete.util.ktx.toYesNo

class AddCrossingType : OsmElementQuestType<CrossingType> {
class AddCrossingMarkings : OsmElementQuestType<Boolean> {

/*
Always ask for deprecated/meaningless values (island, unknown, yes)
Only ask again for crossing types that are known to this quest so to be conservative with
existing data
*/
private val crossingFilter by lazy { """
nodes with highway = crossing
nodes with
highway = crossing
and foot != no
and (
!crossing
or crossing ~ island|unknown|yes
or (
crossing ~ traffic_signals|uncontrolled|zebra|marked|unmarked
and crossing older today -8 years
)
)
and !crossing:markings
and (!crossing or crossing = island)
and (!crossing:signals or crossing:signals = no)
""".toElementFilterExpression() }
/* only looking for crossings that have no crossing=* at all set because if the crossing was
* - if it had markings, it would be tagged with "marked","zebra" or "uncontrolled"
* - if it hadn't, it would be tagged with "unmarked"
* - and in case of "traffic_signals", we currently assume that when there are traffic signals
* it would be spammy to ask about markings because the answer would almost always be "yes".
* Might differ per country, research necessary. */

private val excludedWaysFilter by lazy { """
ways with
highway = service and service = driveway
or highway and access ~ private|no
highway and access ~ private|no
or highway = service and service = driveway
""".toElementFilterExpression() }

override val changesetComment = "Specify crossing types"
override val wikiLink = "Key:crossing"
override val changesetComment = "Specify whether pedestrian crossings have markings"
override val wikiLink = "Key:crossing:markings"
override val icon = R.drawable.ic_quest_pedestrian_crossing
override val achievements = listOf(PEDESTRIAN)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter { it.isCrossing() }.asSequence()
Expand All @@ -61,21 +59,13 @@ class AddCrossingType : OsmElementQuestType<CrossingType> {
override fun isApplicableTo(element: Element): Boolean? =
if (!crossingFilter.matches(element)) false else null

override fun createForm() = AddCrossingTypeForm()
override fun createForm() = YesNoQuestForm()

override fun applyAnswerTo(answer: CrossingType, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
val crossingValue = tags["crossing"]
val isAndWasMarked = answer == CrossingType.MARKED && crossingValue in listOf("zebra", "marked", "uncontrolled")
/* don't change the tag value of the synonyms for "marked" because it is something of a
hot topic / subject of an edit war */
if (isAndWasMarked) {
tags.updateCheckDateForKey("crossing")
} else {
tags.updateWithCheckDate("crossing", answer.osmValue)
// put previous crossing=island into proper tag
if (crossingValue == "island") {
tags["crossing:island"] = "yes"
}
}
override fun applyAnswerTo(answer: Boolean, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["crossing:markings"] = answer.toYesNo()
/* We only tag yes/no, however, in countries where depending on the kind of marking,
* different traffic rules apply, it makes sense to ask which marking it is. But to know
* which kinds exist per country needs research. (Whose results should be added to the
* wiki page for crossing:markings first) */
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package de.westnordost.streetcomplete.quests.crossing_signals

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.osmquests.OsmElementQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.PEDESTRIAN
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.osm.isCrossing
import de.westnordost.streetcomplete.osm.updateCheckDateForKey
import de.westnordost.streetcomplete.osm.updateWithCheckDate
import de.westnordost.streetcomplete.quests.YesNoQuestForm
import de.westnordost.streetcomplete.util.ktx.toYesNo

class AddCrossingSignals : OsmElementQuestType<Boolean> {

private val crossingFilter by lazy { """
nodes with
highway = crossing
and foot != no
and !crossing:signals
and (!crossing or crossing = island)
""".toElementFilterExpression() }
/* only looking for crossings that have no crossing=* at all set because if the crossing had
* signals, it would have been tagged with crossing=traffic_signals */

private val excludedWaysFilter by lazy { """
ways with
highway and access ~ private|no
or highway = service
""".toElementFilterExpression() }

override val changesetComment = "Specify whether pedestrian crossings have traffic signals"
override val wikiLink = "Key:crossing:signals"
override val icon = R.drawable.ic_quest_traffic_lights
override val achievements = listOf(PEDESTRIAN)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter { it.isCrossing() }.asSequence()

override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable<Element> {
val excludedWayNodeIds = mapData.ways
.filter { excludedWaysFilter.matches(it) }
.flatMapTo(HashSet()) { it.nodeIds }

return mapData.nodes
.filter { crossingFilter.matches(it) && it.id !in excludedWayNodeIds }
}

override fun isApplicableTo(element: Element): Boolean? =
if (!crossingFilter.matches(element)) false else null

override fun createForm() = YesNoQuestForm()

override fun applyAnswerTo(answer: Boolean, tags: Tags, geometry: ElementGeometry, timestampEdited: Long, ) {
tags["crossing:signals"] = answer.toYesNo()
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AddTrafficSignalsButton : OsmFilterQuestType<Boolean>() {
"""
override val changesetComment = "Specify whether traffic signals have a button for pedestrians"
override val wikiLink = "Tag:highway=traffic_signals"
override val icon = R.drawable.ic_quest_traffic_lights
override val icon = R.drawable.ic_quest_traffic_lights_button
override val achievements = listOf(PEDESTRIAN)

override fun getTitle(tags: Map<String, String>) = R.string.quest_traffic_signals_button_title
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ car_wash_automated.jpg CC-BY-SA 3.0 Michiel1972 https://commons.wik
car_wash_self_service.jpg CC-BY-SA 4.0 Jacek Halicki https://commons.wikimedia.org/wiki/File:2015_K%C5%82odzko,_ul._Dusznicka,_myjnia_samochodowa_02.jpg
car_wash_service.jpg Public Domain https://commons.wikimedia.org/wiki/File:US_Navy_110831-N-NT881-079_Sailors_assigned_to_the_guided-missile_submarine_USS_Ohio_(SSGN_726)_and_Navy_Operational_Support_Center_Cincinnati_part.jpg

crossing_type_signals.jpg CC-BY-SA 3.0 Bjørn Erik Pedersen https://commons.wikimedia.org/wiki/File:Stop_sign_in_Oscars_gate_in_Oslo_1.jpg
crossing_type_unmarked.jpg CC0 Mateusz Konieczny
crossing_type_zebra.jpg CC-BY-SA 1.0 https://commons.wikimedia.org/wiki/File%3AZebra_crossing.jpg

drinking_water_type_jet_water… CC-BY-SA 3.0 crop of image by Sulfur https://commons.wikimedia.org/wiki/File:Bubbler.jpg
drinking_water_type_generic... CC-BY-SA 4.0 crop of image by Basotxerri https://commons.wikimedia.org/wiki/File:Bielerh%C3%B6he_-_Barbarakapelle_-_Brunnen_01.jpg
drinking_water_type_bottle_re… CC-BY-SA 4.0 crop of image by Fantaglobe11 https://commons.wikimedia.org/wiki/File:Station_Alkmaar_watertappunt.jpg
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 312dd41

Please sign in to comment.