Skip to content

Commit

Permalink
Ask AddCrossing for sidewalk and crossing ways (#5162)
Browse files Browse the repository at this point in the history
* ask AddCrossing for sidwalk and crossing ways

* ask user to leave a note when crossing with a sidewalk or crossing path is not possible

* do not make isFormComplete have side-effects

* improve wording: For the user, it is irrelevant and confusing to read that "a position is on a sidewalk or crossing"

---------

Co-authored-by: Tobias Zwick <newton@westnordost.de>
  • Loading branch information
Helium314 and westnordost authored Sep 27, 2023
1 parent 84cf067 commit 430d170
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
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 All @@ -38,7 +40,7 @@ abstract class AListQuestForm<T> : AbstractOsmQuestForm<T>() {
}

override fun onClickOk() {
applyAnswer(radioButtonIds.getValue(binding.radioButtonGroup.checkedRadioButtonId).value)
applyAnswer(checkedItem!!.value)
}

override fun isFormComplete() = binding.radioButtonGroup.checkedRadioButtonId != -1
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,48 @@
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(
TextItem(YES, R.string.quest_crossing_yes),
TextItem(NO, R.string.quest_crossing_no),
TextItem(PROHIBITED, R.string.quest_crossing_prohibited),
)

/* PROHIBITED is not possible for sidewalks or crossings (=separately mapped sidewalk
infrastructure) because if the crossing does not exist, it 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
NO on the other hand would be okay because crossing=informal would not require deleting
the crossing ways (I would say... it is in edge case...)
*/
override fun onClickOk() {
if (checkedItem?.value == PROHIBITED && isOnSidewalkOrCrossing()) {
AlertDialog.Builder(requireContext())
.setMessage(R.string.quest_leave_new_note_as_answer)
.setPositiveButton(R.string.quest_leave_new_note_yes) { _, _ -> composeNote() }
.setNegativeButton(android.R.string.cancel, null)
.show()
} else {
super.onClickOk()
}
}

private fun isOnSidewalkOrCrossing(): Boolean =
mapDataSource.getWaysForNode(element.id).any {
val footway = it.tags["footway"]
footway == "sidewalk" || footway == "crossing"
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ The info you enter is directly added to OpenStreetMap in your name, without the
<string name="quest_leave_new_note_description">"You can leave a public note for other mappers to resolve at this location, or hide this quest for yourself only"</string>
<string name="quest_leave_new_note_yes">"Leave note"</string>
<string name="quest_leave_new_note_no">"Hide"</string>
<string name="quest_leave_new_note_as_answer">In this case, you need to leave a note in which you explain the situation.</string>


<string name="quest_generic_otherAnswers">"Other answers…"</string>
<!-- aka "not applicable", "not answerable" -->
Expand Down

0 comments on commit 430d170

Please sign in to comment.