-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Incline quest where mtb:scale:uphill=* is used #4385
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
746b6ba
more generic incline name
matkoniecz bb2f6b8
ask for incline where mtb:scale:uphill is present
matkoniecz 949332a
skip bicycle incline quest for very long ways
matkoniecz 8c746f7
source of image
matkoniecz 83b9fc6
clarify why multiple markers are selected as a barrier
matkoniecz b2040b3
Drop generic phrasing
matkoniecz ba98bf9
have applyTo for incline
matkoniecz 8f79378
incline on cycleways: hardcode maximum length independently from how …
matkoniecz 9fd9307
support up and down hops
matkoniecz dd5a1a0
restrict up/down to just bicycle incline form
matkoniecz e980b0d
juggle incline items
matkoniecz f97e7aa
Merge branch 'master' into incline
matkoniecz 7f14947
Simplify code
matkoniecz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...src/main/java/de/westnordost/streetcomplete/quests/incline_direction/AddBicycleIncline.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package de.westnordost.streetcomplete.quests.incline_direction | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression | ||
import de.westnordost.streetcomplete.data.osm.geometry.ElementPolylinesGeometry | ||
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.osm.osmquests.OsmQuest | ||
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BICYCLIST | ||
import de.westnordost.streetcomplete.osm.Tags | ||
import de.westnordost.streetcomplete.quests.incline_direction.InclineDirection.UP | ||
import de.westnordost.streetcomplete.quests.incline_direction.InclineDirection.UP_REVERSED | ||
import de.westnordost.streetcomplete.util.math.measuredLength | ||
|
||
class AddBicycleIncline : OsmElementQuestType<InclineDirection> { | ||
|
||
private val tagFilter by lazy { """ | ||
ways with mtb:scale:uphill | ||
and highway ~ footway|cycleway|path|bridleway|track | ||
and (!indoor or indoor = no) | ||
and area != yes | ||
and access !~ private|no | ||
and !incline | ||
""".toElementFilterExpression() } | ||
|
||
override val changesetComment = "Specify which way leads up (where mtb:scale:uphill is present)" | ||
override val wikiLink = "Key:incline" | ||
override val icon = R.drawable.ic_quest_bicycle_incline | ||
override val achievements = listOf(BICYCLIST) | ||
override val hasMarkersAtEnds = false | ||
|
||
override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable<Element> { | ||
// sadly for very long ways shape may be complex and it may be confusing which answer should be given | ||
// once multiple quest markers are appearing it becomes completely unclear | ||
// see for example https://www.openstreetmap.org/way/437205914 | ||
return mapData | ||
.filter { tagFilter.matches(it) } | ||
.filter { | ||
val geometry = mapData.getGeometry(it.type, it.id) as? ElementPolylinesGeometry | ||
val overlyLong = geometry?.polylines?.filter { it.measuredLength() > OsmQuest.minLengthForMultiMarkers(false) } | ||
overlyLong?.size == 0 | ||
} | ||
} | ||
|
||
override fun isApplicableTo(element: Element): Boolean? { | ||
// we don't want to show overly long things | ||
if (!tagFilter.matches(element)) return false | ||
return null | ||
} | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_bicycle_incline_title | ||
|
||
override fun createForm() = AddInclineForm() | ||
|
||
override fun applyAnswerTo(answer: InclineDirection, tags: Tags, timestampEdited: Long) { | ||
tags["incline"] = when (answer) { | ||
UP -> "up" | ||
UP_REVERSED -> "down" | ||
} | ||
matkoniecz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/src/main/java/de/westnordost/streetcomplete/quests/incline_direction/InclineDirection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package de.westnordost.streetcomplete.quests.incline_direction | ||
|
||
enum class InclineDirection { | ||
UP, UP_REVERSED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
app/src/main/java/de/westnordost/streetcomplete/quests/steps_incline/StepsIncline.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="128dp" | ||
android:height="128dp" | ||
android:viewportWidth="128" | ||
android:viewportHeight="128"> | ||
<path | ||
android:pathData="m128,64.06c0,33.42 -28.65,60.52 -64,60.52 -35.35,0 -64,-27.1 -64,-60.52s28.65,-60.52 64,-60.52c35.35,0 64,27.1 64,60.52" | ||
android:strokeWidth=".19449" | ||
android:fillColor="#529add"/> | ||
<path | ||
android:pathData="M30.26,104.11 L110.26,58.72" | ||
android:strokeAlpha="0.2" | ||
android:strokeWidth="7.7795" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#000000"/> | ||
<path | ||
android:pathData="M30.26,99.11 L110.26,53.72" | ||
android:strokeWidth="7.7795" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#ffffff"/> | ||
<path | ||
android:pathData="m67.26,60.07a10.14,10.14 0,0 0,13.85 3.71,10.14 10.14,0 0,0 3.71,-13.85 10.14,10.14 0,0 0,-13.85 -3.71,10.14 10.14,0 0,0 -3.71,13.85m-28.61,16.52a10.14,10.14 0,0 0,13.85 3.71,10.14 10.14,0 0,0 3.71,-13.85 10.14,10.14 0,0 0,-13.85 -3.71,10.14 10.14,0 0,0 -3.71,13.85m24.7,-32.29 l-3.32,19.88 -12.68,7.32 0.94,-18.51 15.06,-8.7m-16.89,5.52 l-3.87,2.22m17.44,12.14 l-13.57,-14.36m29.43,5.2 l-17.96,-15.86 -6.34,3.66" | ||
android:strokeAlpha="0.2" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="3" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#000000" | ||
android:strokeLineCap="round"/> | ||
<path | ||
android:pathData="m67.28,55a10.14,10.14 0,0 0,13.85 3.71,10.14 10.14,0 0,0 3.71,-13.85 10.14,10.14 0,0 0,-13.85 -3.71,10.14 10.14,0 0,0 -3.71,13.85m-28.61,16.52a10.14,10.14 0,0 0,13.85 3.71,10.14 10.14,0 0,0 3.71,-13.85 10.14,10.14 0,0 0,-13.85 -3.71,10.14 10.14,0 0,0 -3.71,13.85m24.7,-32.29 l-3.32,19.88 -12.68,7.32 0.94,-18.51 15.06,-8.7m-16.89,5.52 l-3.87,2.22m17.44,12.14 l-13.57,-14.36m29.43,5.2 l-17.96,-15.86 -6.34,3.66" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="3" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#ffffff" | ||
android:strokeLineCap="round"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is arbitrary. Please just specify a constant here instead of referring to some unrelated function. Also, 800+ meters sounds a bit long for choosing to not display this quest for long ways.
Also, why can the user not simply split up the way in such a case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually a related function: if there are multiple markers on a windy paths then it becomes utterly unclear which direction should be actually applied.
So the plan was to avoid any cases where multiple markers would be shown.
Though I guess that some small distance can be also used, with assumption that it will always have a single marker
It is not entirely obvious (at least I have not thought about it) and in many cases would be done solely as workaround for SC interface so probably should not be encouraged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it be done as a workaround to SC interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case where incline changes it should be split, and if parts of it are small enough this stops being relevant.
In case where way has continuous this case primary motivation for splitting way would be to get its direction displayed clearly in SC (so: workaround to SC interface)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well you have the same for any length of way.