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

Ask AddCrossing for sidewalk and crossing ways #5162

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -19,6 +19,8 @@ abstract class AListQuestForm<T> : AbstractOsmQuestForm<T>() {

private val radioButtonIds = HashMap<Int, TextItem<T>>()

val checkedItem get() = radioButtonIds[binding.radioButtonGroup.checkedRadioButtonId]

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
for (item in items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ class AddCrossing : OsmElementQuestType<CrossingAnswer> {
private val footwaysFilter by lazy { """
ways with
(highway ~ footway|steps or highway ~ path|cycleway and foot ~ designated|yes)
and footway !~ sidewalk|crossing
and area != yes
and access !~ private|no
""".toElementFilterExpression() }

/* It is neither asked for sidewalks nor crossings (=separately mapped sidewalk infrastructure)
* because a "no" answer would require to also delete/adapt the crossing ways, rather than just
* tagging crossing=no on the vertex.
* See https://github.com/streetcomplete/StreetComplete/pull/2999#discussion_r681516203 */

override val changesetComment = "Specify whether there are crossings at intersections of paths and roads"
override val wikiLink = "Tag:highway=crossing"
override val icon = R.drawable.ic_quest_pedestrian
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
package de.westnordost.streetcomplete.quests.crossing

import androidx.appcompat.app.AlertDialog
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.edits.MapDataWithEditsSource
import de.westnordost.streetcomplete.quests.AListQuestForm
import de.westnordost.streetcomplete.quests.TextItem
import de.westnordost.streetcomplete.quests.crossing.CrossingAnswer.*
import org.koin.android.ext.android.inject

class AddCrossingForm : AListQuestForm<CrossingAnswer>() {
private val mapDataSource: MapDataWithEditsSource by inject()

override val items = listOf(
override val items get() = listOf(
TextItem(YES, R.string.quest_crossing_yes),
TextItem(NO, R.string.quest_crossing_no),
TextItem(PROHIBITED, R.string.quest_crossing_prohibited),
TextItem(PROHIBITED, R.string.quest_crossing_prohibited)
)

/* PROHIBITED is neither possible for sidewalks nor crossings (=separately mapped sidewalk infrastructure)
* because a "no" answer would require to also delete/adapt the crossing ways, rather than just
* tagging crossing=no on the vertex.
* This situation needs to be solved in a different editor, so we ask the user to leave a note.
* See https://github.com/streetcomplete/StreetComplete/pull/2999#discussion_r681516203
* and https://github.com/streetcomplete/StreetComplete/issues/5160 */
override fun isFormComplete(): Boolean {
westnordost marked this conversation as resolved.
Show resolved Hide resolved
if (checkedItem?.value == PROHIBITED && isOnSidewalkOrCrossing()) {
AlertDialog.Builder(requireContext())
.setMessage(R.string.quest_crossing_prohibited_but_on_sidewalk_or_crossing)
.setPositiveButton(R.string.quest_leave_new_note_yes) { _, _ -> composeNote() }
.setNegativeButton(android.R.string.cancel, null)
.show()
return false
}
return super.isFormComplete()
}

override fun isRejectingClose() = super.isFormComplete()

private fun isOnSidewalkOrCrossing(): Boolean {
val ways = mapDataSource.getWaysForNode(element.id)
return ways.any {
val footway = it.tags["footway"]
footway == "sidewalk" || footway == "crossing"
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ Before uploading your changes, the app checks with a &lt;a href=\"https://www.we
<string name="quest_crossing_yes">Yes (e.g. the curb is lowered here or there are markings)</string>
<string name="quest_crossing_no">No, but crossing is possible</string>
<string name="quest_crossing_prohibited">No, crossing is prohibited or impossible</string>
<string name="quest_crossing_prohibited_but_on_sidewalk_or_crossing">This position is on a sidewalk or crossing. Please leave a note to explain the situation.</string>

<string name="quest_crossing_type_title">What kind of crossing is this?</string>
<string name="quest_crossing_type_signals_controlled">Controlled by traffic lights</string>
Expand Down