-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a294cc
commit 312dd41
Showing
33 changed files
with
319 additions
and
361 deletions.
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
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
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/crossing_signals/AddCrossingSignals.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.crossing_signals | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression | ||
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry | ||
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.user.achievements.EditTypeAchievement.PEDESTRIAN | ||
import de.westnordost.streetcomplete.osm.Tags | ||
import de.westnordost.streetcomplete.osm.isCrossing | ||
import de.westnordost.streetcomplete.osm.updateCheckDateForKey | ||
import de.westnordost.streetcomplete.osm.updateWithCheckDate | ||
import de.westnordost.streetcomplete.quests.YesNoQuestForm | ||
import de.westnordost.streetcomplete.util.ktx.toYesNo | ||
|
||
class AddCrossingSignals : OsmElementQuestType<Boolean> { | ||
|
||
private val crossingFilter by lazy { """ | ||
nodes with | ||
highway = crossing | ||
and foot != no | ||
and !crossing:signals | ||
and (!crossing or crossing = island) | ||
""".toElementFilterExpression() } | ||
/* only looking for crossings that have no crossing=* at all set because if the crossing had | ||
* signals, it would have been tagged with crossing=traffic_signals */ | ||
|
||
private val excludedWaysFilter by lazy { """ | ||
ways with | ||
highway and access ~ private|no | ||
or highway = service | ||
""".toElementFilterExpression() } | ||
|
||
override val changesetComment = "Specify whether pedestrian crossings have traffic signals" | ||
override val wikiLink = "Key:crossing:signals" | ||
override val icon = R.drawable.ic_quest_traffic_lights | ||
override val achievements = listOf(PEDESTRIAN) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_pedestrian_crossing_signals | ||
|
||
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) = | ||
getMapData().filter { it.isCrossing() }.asSequence() | ||
|
||
override fun getApplicableElements(mapData: MapDataWithGeometry): Iterable<Element> { | ||
val excludedWayNodeIds = mapData.ways | ||
.filter { excludedWaysFilter.matches(it) } | ||
.flatMapTo(HashSet()) { it.nodeIds } | ||
|
||
return mapData.nodes | ||
.filter { crossingFilter.matches(it) && it.id !in excludedWayNodeIds } | ||
} | ||
|
||
override fun isApplicableTo(element: Element): Boolean? = | ||
if (!crossingFilter.matches(element)) false else null | ||
|
||
override fun createForm() = YesNoQuestForm() | ||
|
||
override fun applyAnswerTo(answer: Boolean, tags: Tags, geometry: ElementGeometry, timestampEdited: Long, ) { | ||
tags["crossing:signals"] = answer.toYesNo() | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
app/src/main/java/de/westnordost/streetcomplete/quests/crossing_type/AddCrossingTypeForm.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
app/src/main/java/de/westnordost/streetcomplete/quests/crossing_type/CrossingType.kt
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
app/src/main/java/de/westnordost/streetcomplete/quests/crossing_type/CrossingTypeItem.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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.