/
AddHairdresserCustomers.kt
46 lines (39 loc) · 1.92 KB
/
AddHairdresserCustomers.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package de.westnordost.streetcomplete.quests.hairdresser
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.CITIZEN
import de.westnordost.streetcomplete.osm.IS_SHOP_OR_DISUSED_SHOP_EXPRESSION
import de.westnordost.streetcomplete.osm.Tags
class AddHairdresserCustomers : OsmFilterQuestType<HairdresserCustomers>() {
override val elementFilter = """
nodes, ways with
(
shop = hairdresser
and !female and !male
and !male:signed and !female:signed
)
"""
override val changesetComment = "Survey hairdresser's customers"
override val wikiLink = "Tag:shop=hairdresser"
override val icon = R.drawable.ic_quest_hairdresser
override val isReplaceShopEnabled = true
override val achievements = listOf(CITIZEN)
override fun getTitle(tags: Map<String, String>) = R.string.quest_hairdresser_title
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter(IS_SHOP_OR_DISUSED_SHOP_EXPRESSION)
override fun createForm() = AddHairdresserCustomersForm()
override fun applyAnswerTo(answer: HairdresserCustomers, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
if (answer == HairdresserCustomers.NOT_SIGNED) {
tags["male:signed"] = "no"
tags["female:signed"] = "no"
} else {
if (answer.isMale) tags["male"] = "yes"
if (answer.isFemale) tags["female"] = "yes"
}
tags.remove("unisex")
}
}