Skip to content

Commit

Permalink
add new quest files
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 19, 2021
1 parent bf7b85b commit 42cff9b
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.westnordost.streetcomplete.quests


import android.os.Bundle
import android.view.View

import de.westnordost.streetcomplete.R
//import kotlinx.android.synthetic.main.quest_buttonpanel_yes_no.*

/** Abstract base class for dialogs in which the user answers a yes/no quest */
abstract class NoAAnswerFragment<T> : AbstractQuestAnswerFragment<T>() {

// override val buttonsResId = R.layout.quest_buttonpanel_yes_no
override val buttonsResId = R.layout.quest_buttonpanel_nothing

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// yesButton.setOnClickListener { onClick(true) }
// noButton.setOnClickListener { onClick(false) }
}

protected abstract fun onClick(answer: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.westnordost.streetcomplete.quests

class NoAnswerFragment : NoAAnswerFragment<Boolean>() {

override fun onClick(answer: Boolean) { applyAnswer(answer) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowBench : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes with amenity = bench
or leisure = picnic_table
"""
override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_bench_poi // replace later, but need own icon...
override val dotColor = "chocolate"

override fun getTitle(tags: Map<String, String>) =
if (tags.containsKey("leisure"))
R.string.quest_thisIsPicnic_title
else
R.string.quest_thisIsBench_title

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowBikeParking : OsmFilterQuestType<Boolean>() {
override val elementFilter = "nodes, ways with amenity = bicycle_parking"
override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_bicycle_parking_cover // replace later, but need own icon...
override val dotColor = "violet"

override fun getTitle(tags: Map<String, String>) =
R.string.quest_thisIsBikeParking_title

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.ktx.containsAny
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowBusiness : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes, ways, relations with
(
shop and shop !~ no|vacant
or craft
or office
or amenity = parking and parking = multi-storey
or tourism = information and information = office
or healthcare = laboratory
or """.trimIndent() +

// The common list is shared by the name quest, the opening hours quest and the wheelchair quest.
// So when adding other tags to the common list keep in mind that they need to be appropriate for all those quests.
// Independent tags can by added in the "wheelchair only" tab.

mapOf(
"amenity" to arrayOf(
// common
"restaurant", "cafe", "ice_cream", "fast_food", "bar", "pub", "biergarten", "food_court", "nightclub", // eat & drink
"cinema", "planetarium", "casino", // amenities
"townhall", "courthouse", "embassy", "community_centre", "youth_centre", "library", // civic
"bank", "bureau_de_change", "money_transfer", "post_office", "marketplace", "internet_cafe", // commercial
"car_wash", "car_rental", "fuel", // car stuff
"dentist", "doctors", "clinic", "pharmacy", "veterinary", // health
"animal_boarding", "animal_shelter", "animal_breeding", // animals

"boat_rental",
"theatre", // culture
"conference_centre", "arts_centre", // events
"police", "ranger_station", // civic
"ferry_terminal", // transport
"hospital", // health care
// name only
"studio", // culture
"events_venue", "exhibition_centre", "music_venue", // events
"social_facility", "nursing_home", "childcare", "retirement_home", "social_centre", // social
"driving_school", "dive_centre", "language_school", "music_school", // learning
"brothel", "gambling", "love_hotel", "stripclub" // bad stuff
),
"tourism" to arrayOf(
// common
"zoo", "aquarium", "theme_park", "gallery", "museum",

// name & wheelchair
"attraction",
"hotel", "guest_house", "motel", "hostel", "alpine_hut", "apartment", "resort", "camp_site", "caravan_site", "chalet" // accommodations


// and tourism = information, see above
),
"leisure" to arrayOf(
// common
"fitness_centre", "golf_course", "water_park", "miniature_golf", "bowling_alley",
"amusement_arcade", "adult_gaming_centre", "tanning_salon","escape_game",
"sauna","trampoline_park"

),
"military" to arrayOf(
"airfield", "barracks", "training_area"
)
).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") +
"\n)"

override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_opening_hours
override val dotColor = "orange"

override fun getTitle(tags: Map<String, String>) =
if (hasProperName(tags))
R.string.quest_thisIsBusiness_name_title
else
R.string.quest_thisIsBusiness_no_name_title

private fun hasProperName(tags: Map<String, String>?): Boolean =
tags?.keys?.containsAny(listOf("name", "brand")) ?: false

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
val name = tags["name"] ?: tags["brand"] ?: featureName.value
val name2 = featureName.value ?: tags.entries //tags["shop"] ?: tags["amenity"] ?: tags["office"] ?: tags["craft"] ?: tags["leisure"] ?: tags["sport"]
return if (name != null) arrayOf(name2.toString(),name) else arrayOf(name2.toString())
}

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowFixme : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes, ways, relations with
fixme
or FIXME
"""
override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_create_note // replace later, but need own icon...
override val dotColor = "red"

override fun getTitle(tags: Map<String, String>) = R.string.quest_fixme_title

override fun createForm() = NoAnswerFragment()

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
val name = featureName.value ?: tags.entries
val fixme = tags["fixme"] ?: tags["FIXME"]
return arrayOf(fixme.toString(),name.toString())
}

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowMachine : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes, ways with
amenity = vending_machine
or amenity = atm
or amenity = telephone
or amenity = charging_station
or atm = yes and (amenity or shop)
"""
override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_cash
override val dotColor = "blue"

override fun getTitle(tags: Map<String, String>) =
if (tags["amenity"].equals("atm") || !tags["atm"].isNullOrEmpty())
R.string.quest_thisIsAtm_title
else if (tags["amenity"].equals("telephone"))
R.string.quest_thisIsTelephone_title
else if (tags["amenity"].equals("charging_station"))
R.string.quest_thisIsCharging_title
else
R.string.quest_thisIsVendingMachine_title

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
return arrayOf(tags["vending"] ?: tags.entries.toString())
}

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.ktx.containsAny
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowOther : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes, ways, relations with
(
sport
or entrance
or playground
or information and information !~ office
or tourism = viewpoint
or tourism = artwork
or tourism = wilderness_hut
or pipeline = marker
or emergency = fire_hydrant
or emergency = defibrillator
or emergency = phone
or """.trimIndent() +

// The common list is shared by the name quest, the opening hours quest and the wheelchair quest.
// So when adding other tags to the common list keep in mind that they need to be appropriate for all those quests.
// Independent tags can by added in the "wheelchair only" tab.

mapOf(
"amenity" to arrayOf(
// common
"place_of_worship", // religious
"toilets",
"prison", "fire_station", // civic
"monastery", // religious
"kindergarten", "school", "college", "university", "research_institute", // education
"drinking_water","post_box","bbq","grit_bin","clock","hunting_stand"
),
"leisure" to arrayOf(
// name & wheelchair
"sports_centre", "stadium", "marina",

"horse_riding", "dance", "nature_reserve","pitch","playground"
),
"landuse" to arrayOf(
"cemetery", "allotments"
),
"military" to arrayOf(
"airfield", "barracks", "training_area"
)
).map { it.key + " ~ " + it.value.joinToString("|") }.joinToString("\n or ") +
"\n)"

override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_fire_hydrant
override val dotColor = "gold"

override fun getTitle(tags: Map<String, String>) =
R.string.quest_thisIsOther_title

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
if (tags["pipeline"].equals("marker"))
return arrayOf(tags.entries.toString())
val name = featureName.value ?: tags.entries
return arrayOf(name.toString())
}

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowRecycling : OsmFilterQuestType<Boolean>() {
override val elementFilter = "nodes, ways with amenity = recycling or amenity = waste_basket"
override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_recycling
override val dotColor = "green"

override fun getTitle(tags: Map<String, String>) =
if (tags["amenity"].equals("recycling"))
R.string.quest_thisIsRecycling_title
else
R.string.quest_thisIsWasteBasket_title

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.westnordost.streetcomplete.quests.show_poi

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquest.OsmFilterQuestType
import de.westnordost.streetcomplete.quests.NoAnswerFragment

class ShowTrafficStuff : OsmFilterQuestType<Boolean>() {
override val elementFilter = """
nodes, ways, relations with
barrier and barrier !~ wall|fence|retaining_wall
or traffic_calming
or crossing
or highway = crossing
or railway = crossing
or footway = crossing
or cycleway = crossing
or amenity = taxi
or public_transport
"""

override val commitMessage = "I hope this does not get committed"
override val wikiLink = "nope"
override val icon = R.drawable.ic_quest_railway // replace later, but need own icon...
override val dotColor = "deepskyblue"

override fun getTitle(tags: Map<String, String>) =
R.string.quest_thisIsOther_title

override fun getTitleArgs(tags: Map<String, String>, featureName: Lazy<String?>): Array<String> {
val name = featureName.value ?: tags.entries
return arrayOf(name.toString())
}

override fun createForm() = NoAnswerFragment()

override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) {
}
}
Loading

0 comments on commit 42cff9b

Please sign in to comment.