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 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
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