-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Quest] How power line is attached on this support? (#5382)
- Loading branch information
1 parent
02860fb
commit dd4514b
Showing
19 changed files
with
93 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
...src/main/java/de/westnordost/streetcomplete/quests/power_attachment/AddPowerAttachment.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,42 @@ | ||
package de.westnordost.streetcomplete.quests.power_attachment | ||
|
||
import de.westnordost.streetcomplete.R | ||
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.mapdata.filter | ||
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType | ||
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.BUILDING | ||
import de.westnordost.streetcomplete.osm.Tags | ||
|
||
class AddPowerAttachment : OsmFilterQuestType<PowerAttachment>() { | ||
|
||
override val elementFilter = """ | ||
nodes with | ||
power ~ tower|pole|insulator | ||
and !line_attachment | ||
""" | ||
override val changesetComment = "Specify line_attachment power support" | ||
override val wikiLink = "Key:line_attachment" | ||
override val icon = R.drawable.ic_quest_power | ||
override val achievements = listOf(BUILDING) | ||
|
||
override fun getTitle(tags: Map<String, String>) = R.string.quest_powerAttachment_title | ||
|
||
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry): Sequence<Element> { | ||
val mapData = getMapData() | ||
// and also show the (power) lines themselves | ||
return mapData.filter("nodes with power ~ tower|pole|insulator") + | ||
mapData.filter("ways with power ~ line|minor_line") | ||
} | ||
|
||
// map data density is usually lower where there are power poles and more context is necessary | ||
// when looking at them from afar | ||
override val highlightedElementsRadius get() = 100.0 | ||
|
||
override fun createForm() = AddPowerAttachmentForm() | ||
|
||
override fun applyAnswerTo(answer: PowerAttachment, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) { | ||
tags["line_attachment"] = answer.osmValue | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...main/java/de/westnordost/streetcomplete/quests/power_attachment/AddPowerAttachmentForm.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,13 @@ | ||
package de.westnordost.streetcomplete.quests.power_attachment | ||
|
||
import de.westnordost.streetcomplete.quests.AImageListQuestForm | ||
|
||
class AddPowerAttachmentForm : AImageListQuestForm<PowerAttachment, PowerAttachment>() { | ||
|
||
override val items = PowerAttachment.entries.map { it.asItem() } | ||
override val itemsPerRow = 3 | ||
|
||
override fun onClickOk(selectedItems: List<PowerAttachment>) { | ||
applyAnswer(selectedItems.single()) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/de/westnordost/streetcomplete/quests/power_attachment/PowerAttachment.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,7 @@ | ||
package de.westnordost.streetcomplete.quests.power_attachment | ||
|
||
enum class PowerAttachment(val osmValue: String) { | ||
SUSPENSION("suspension"), | ||
ANCHOR("anchor"), | ||
PIN("pin"), | ||
} |
19 changes: 19 additions & 0 deletions
19
...rc/main/java/de/westnordost/streetcomplete/quests/power_attachment/PowerAttachmentItem.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,19 @@ | ||
package de.westnordost.streetcomplete.quests.power_attachment | ||
|
||
import de.westnordost.streetcomplete.R | ||
import de.westnordost.streetcomplete.quests.power_attachment.PowerAttachment.* | ||
import de.westnordost.streetcomplete.view.image_select.Item | ||
|
||
fun PowerAttachment.asItem() = Item(this, iconResId, titleResId) | ||
|
||
private val PowerAttachment.titleResId: Int get() = when (this) { | ||
SUSPENSION -> R.string.quest_powerAttachment_suspension | ||
ANCHOR -> R.string.quest_powerAttachment_anchor | ||
PIN -> R.string.quest_powerAttachment_pin | ||
} | ||
|
||
private val PowerAttachment.iconResId: Int get() = when (this) { | ||
SUSPENSION -> R.drawable.power_attachment_suspension | ||
ANCHOR -> R.drawable.power_attachment_anchor | ||
PIN -> R.drawable.power_attachment_pin | ||
} |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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