Skip to content

Commit

Permalink
fix merge problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Mar 8, 2022
1 parent 7fc145a commit c809076
Showing 1 changed file with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import de.westnordost.streetcomplete.osm.sidewalk.Sidewalk.INVALID
import de.westnordost.streetcomplete.osm.sidewalk.SidewalkSides
import de.westnordost.streetcomplete.osm.sidewalk.applyTo
import de.westnordost.streetcomplete.osm.sidewalk.createSidewalkSides
import de.westnordost.streetcomplete.util.isNearAndAligned
import de.westnordost.streetcomplete.quests.singleTypeElementSelectionDialog
import de.westnordost.streetcomplete.util.isNearAndAligned

class AddSidewalk(private val prefs: SharedPreferences) : OsmElementQuestType<SidewalkSides> {
private val maybeSeparatelyMappedSidewalksFilter by lazy { """
Expand Down Expand Up @@ -83,10 +83,10 @@ class AddSidewalk(private val prefs: SharedPreferences) : OsmElementQuestType<Si
private fun getMinDistanceToWays(tags: Map<String, String>): Float =
(
(estimateRoadwayWidth(tags) ?: guessRoadwayWidth(tags)) +
(estimateParkingOffRoadWidth(tags) ?: 4f) +
(estimateCycleTrackWidth(tags) ?: 0f)
) / 2f +
4f // + generous buffer for possible grass verge
(estimateParkingOffRoadWidth(tags) ?: 0f) +
(estimateCycleTrackWidth(tags) ?: 0f)
) / 2f +
4f // + generous buffer for possible grass verge

override fun isApplicableTo(element: Element): Boolean? {
if (!roadsFilter.matches(element)) return false
Expand Down Expand Up @@ -117,19 +117,21 @@ class AddSidewalk(private val prefs: SharedPreferences) : OsmElementQuestType<Si
and access !~ private|no
""".toElementFilterExpression() }

// streets that do not have sidewalk tagging yet
/* the filter additionally filters out ways that are unlikely to have sidewalks:
*
* + unpaved roads
* + roads that are probably not developed enough to have sidewalk (i.e. country roads)
* + roads with a very low speed limit
* + Also, anything explicitly tagged as no pedestrians or explicitly tagged that the sidewalk
* is mapped as a separate way OR that is tagged with that the cycleway is separate. If the
* cycleway is separate, the sidewalk is too for sure
* */
private val untaggedRoadsFilter by lazy { """
}

// streets that do not have sidewalk tagging yet
/* the filter additionally filters out ways that are unlikely to have sidewalks:
*
* + unpaved roads
* + roads that are probably not developed enough to have sidewalk (i.e. country roads)
* + roads with a very low speed limit
* + Also, anything explicitly tagged as no pedestrians or explicitly tagged that the sidewalk
* is mapped as a separate way OR that is tagged with that the cycleway is separate. If the
* cycleway is separate, the sidewalk is too for sure
* */
private val untaggedRoadsFilter by lazy { """
ways with
highway ~ trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|unclassified|residential
highway ~ ${prefs.getString(PREF_SIDEWALK_HIGHWAY_SELECTION, ROADS_WITH_SIDEWALK.joinToString("|"))}
and !sidewalk and !sidewalk:both and !sidewalk:left and !sidewalk:right
and (
!maxspeed
Expand All @@ -151,15 +153,25 @@ class AddSidewalk(private val prefs: SharedPreferences) : OsmElementQuestType<Si
and cycleway:right != separate
and cycleway:both != separate
""".toElementFilterExpression() }
}

private fun Element.hasInvalidOrIncompleteSidewalkTags(): Boolean {
val sides = createSidewalkSides(tags)
if (sides == null) return false
if (sides.any { it == INVALID }) return true
return false
}

override val hasQuestSettings = true

override fun getQuestSettingsDialog(context: Context): AlertDialog =
singleTypeElementSelectionDialog(context, prefs, PREF_SIDEWALK_HIGHWAY_SELECTION, ROADS_WITH_SIDEWALK.joinToString("|"), "set highways eligible for this quest, comma separated")
}

private fun LeftAndRightSidewalk.any(block: (sidewalk: Sidewalk) -> Boolean): Boolean =
left?.let(block) == true || right?.let(block) == true

private val ROADS_WITH_SIDEWALK = arrayOf(
"primary","primary_link","secondary","secondary_link",
"tertiary","tertiary_link","unclassified","residential")

private const val PREF_SIDEWALK_HIGHWAY_SELECTION = "quest_sidewalk_highway_selection"

0 comments on commit c809076

Please sign in to comment.