Skip to content

Commit

Permalink
[Quest] How power line is attached on this support? (#5382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-BaptisteC authored Nov 14, 2024
1 parent 02860fb commit dd4514b
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import de.westnordost.streetcomplete.quests.police_type.AddPoliceType
import de.westnordost.streetcomplete.quests.postbox_collection_times.AddPostboxCollectionTimes
import de.westnordost.streetcomplete.quests.postbox_ref.AddPostboxRef
import de.westnordost.streetcomplete.quests.postbox_royal_cypher.AddPostboxRoyalCypher
import de.westnordost.streetcomplete.quests.power_attachment.AddPowerAttachment
import de.westnordost.streetcomplete.quests.powerpoles_material.AddPowerPolesMaterial
import de.westnordost.streetcomplete.quests.railway_crossing.AddRailwayCrossingBarrier
import de.westnordost.streetcomplete.quests.recycling.AddRecyclingType
Expand Down Expand Up @@ -288,7 +289,8 @@ fun questTypeRegistry(

26 to AddReligionToPlaceOfWorship(), // icons on maps are different - OSM Carto, mapy.cz, OsmAnd, Sputnik etc
27 to AddReligionToWaysideShrine(),


172 to AddPowerAttachment(),
28 to AddPowerPolesMaterial(),

29 to AddIsBuildingUnderground(), // should be before AddHousenumber to avoid asking for underground buildings
Expand Down
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
}
}
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())
}
}
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"),
}
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
}
4 changes: 4 additions & 0 deletions app/src/main/res/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ power_pole_concrete.jpg CC-BY-SA 3.0 https://commons.wikimedia.org/w
power_pole_steel.jpg Public Domain https://commons.wikimedia.org/wiki/File:Steel_tube_pylon.JPG
power_pole_wood.jpg CC-BY 3.0 https://commons.wikimedia.org/wiki/File:Two_armed_power_pole_1.jpg

power_attachment_anchor.jpg CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Power_pole_anchor.jpg
power_attachment_pin.jpg CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Power_pole_pin.jpg
power_attachment_suspension... CC-BY-SA 4.0 https://commons.wikimedia.org/wiki/File:Power_pole_suspension.jpg

produce_agave.jpg CC-BY-SA 3.0 Marc Ryckaert, under username MJJR https://commons.wikimedia.org/wiki/File:Agave_americana_R01.jpg
produce_almond.jpg CC-BY-SA 2.0 antcaesar https://commons.wikimedia.org/wiki/File:Madrigueras_(20578932389)_(cropped).jpg
produce_apple.jpg CC0 https://www.pexels.com/photo/close-up-of-fruits-hanging-on-tree-257840/ - archived at https://web.archive.org/web/20210507233404/https://www.pexels.com/photo/close-up-of-fruits-hanging-on-tree-257840/
Expand Down
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.
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,11 @@ If there are no signs along the whole street which apply for the highlighted sec
<string name="quest_postboxRoyalCypher_title">What’s the royal cypher on this postbox?</string>
<string name="quest_postboxRoyalCypher_type_none">No royal cypher is visible</string>
<string name="quest_postboxRoyalCypher_type_scottish_crown">The Crown of Scotland</string>

<string name="quest_powerAttachment_title">How is this power line attached?</string>
<string name="quest_powerAttachment_suspension">Supported from above</string>
<string name="quest_powerAttachment_anchor">Fixed horizontally</string>
<string name="quest_powerAttachment_pin">Supported from below</string>

<!-- I.e. which material. Pole as in "power pole" or "utility pole" -->
<string name="quest_powerPolesMaterial_title">What’s this pole made of?</string>
Expand Down

0 comments on commit dd4514b

Please sign in to comment.