Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect guidepost/map metadata (ref,ele,name) #477

Merged
merged 8 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ import de.westnordost.streetcomplete.quests.foot.AddProhibitedForPedestrians
import de.westnordost.streetcomplete.quests.fuel_service.AddFuelSelfService
import de.westnordost.streetcomplete.quests.general_fee.AddGeneralFee
import de.westnordost.streetcomplete.quests.grit_bin_seasonal.AddGritBinSeasonal
import de.westnordost.streetcomplete.quests.guidepost.AddGuidepostEle
import de.westnordost.streetcomplete.quests.guidepost.AddGuidepostName
import de.westnordost.streetcomplete.quests.guidepost.AddGuidepostRef
import de.westnordost.streetcomplete.quests.hairdresser.AddHairdresserCustomers
import de.westnordost.streetcomplete.quests.handrail.AddHandrail
import de.westnordost.streetcomplete.quests.healthcare_speciality.AddHealthcareSpeciality
Expand Down Expand Up @@ -606,6 +609,9 @@ fun getQuestTypeList(
EE_QUEST_OFFSET + 9 to AddTreeGenus(),
EE_QUEST_OFFSET + 39 to AddBarrierLocked(),
EE_QUEST_OFFSET + 26 to AddIsPharmacyDispensing(),
EE_QUEST_OFFSET + 42 to AddGuidepostRef(),
EE_QUEST_OFFSET + 43 to AddGuidepostName(),
EE_QUEST_OFFSET + 44 to AddGuidepostEle(),
EE_QUEST_OFFSET + 30 to AddShelterType(),
EE_QUEST_OFFSET + 28 to AddFootwayWidth(arSupportChecker),
EE_QUEST_OFFSET + 31 to AddViaFerrataScale(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.westnordost.streetcomplete.quests.guidepost

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.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags

class AddGuidepostEle : OsmFilterQuestType<String>() {

override val elementFilter = """
nodes with
information = guidepost
and !ele and !~"ele:.*"
and hiking = yes
"""
override val changesetComment = "Specify guidepost elevation"
override val wikiLink = "Tag:information=guidepost"
override val icon = R.drawable.ic_quest_guidepost_ele
override val isDeleteElementEnabled = true
override val achievements = listOf(OUTDOORS)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes with information = guidepost")

override val highlightedElementsRadius: Double get() = 200.0
override val defaultDisabledMessage: Int = R.string.quest_guidepost_disabled_msg

override fun createForm() = AddGuidepostEleForm()

override fun applyAnswerTo(answer: String, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["ele"] = answer

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.westnordost.streetcomplete.quests.guidepost

import android.os.Bundle
import android.view.View
import androidx.core.widget.doAfterTextChanged
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.databinding.QuestGuidepostEleBinding
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
import de.westnordost.streetcomplete.util.ktx.nonBlankTextOrNull

class AddGuidepostEleForm : AbstractOsmQuestForm<String>() {

override val contentLayoutResId = R.layout.quest_guidepost_ele
private val binding by contentViewBinding(QuestGuidepostEleBinding::bind)

private val ele get() = binding.refInput.nonBlankTextOrNull

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.refInput.doAfterTextChanged { checkIsFormComplete() }
}

override fun onClickOk() {
applyAnswer(ele!!)
}


override fun isFormComplete() = ele != null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.westnordost.streetcomplete.quests.guidepost

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.quest.NoCountriesExcept
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags

class AddGuidepostName : OsmFilterQuestType<GuidepostNameAnswer>() {

override val elementFilter = """
nodes with
information ~ guidepost|map
and !name and noname != yes and !~"name:.*"
and hiking = yes
"""
override val changesetComment = "Specify guidepost/map name"
override val wikiLink = "Tag:information=guidepost"
override val icon = R.drawable.ic_quest_guidepost_name
override val isDeleteElementEnabled = true
override val achievements = listOf(OUTDOORS)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes with information ~ guidepost|map")


override val defaultDisabledMessage: Int = R.string.quest_guidepost_disabled_msg

override val highlightedElementsRadius: Double get() = 200.0

override fun createForm() = AddGuidepostNameForm()

override fun applyAnswerTo(answer: GuidepostNameAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
is NoVisibleGuidepostName -> tags["name:signed"] = "no"
is GuidepostName -> tags["name"] = answer.name
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.westnordost.streetcomplete.quests.guidepost

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.core.widget.doAfterTextChanged
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.databinding.QuestGuidepostRefBinding
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.util.ktx.nonBlankTextOrNull

class AddGuidepostNameForm : AbstractOsmQuestForm<GuidepostNameAnswer>() {

override val contentLayoutResId = R.layout.quest_guidepost_ref
private val binding by contentViewBinding(QuestGuidepostRefBinding::bind)

override val otherAnswers = listOf(
AnswerItem(R.string.quest_ref_answer_noName) { confirmNoRef() }
)

private val name get() = binding.refInput.nonBlankTextOrNull

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.refInput.doAfterTextChanged { checkIsFormComplete() }
binding.tvHint.setText(R.string.quest_guidepostName_hint)
}

override fun onClickOk() {
applyAnswer(GuidepostName(name!!))
}

private fun confirmNoRef() {
val ctx = context ?: return
AlertDialog.Builder(ctx)
.setTitle(R.string.quest_generic_confirmation_title)
.setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> applyAnswer(NoVisibleGuidepostName) }
.setNegativeButton(R.string.quest_generic_confirmation_no, null)
.show()
}

override fun isFormComplete() = name != null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package de.westnordost.streetcomplete.quests.guidepost

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.quest.NoCountriesExcept
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.OUTDOORS
import de.westnordost.streetcomplete.osm.Tags
class AddGuidepostRef : OsmFilterQuestType<GuidepostRefAnswer>() {

override val elementFilter = """
nodes with
information ~ guidepost|map
Helium314 marked this conversation as resolved.
Show resolved Hide resolved
and !ref and noref != yes and !~"ref:.*" and hiking = yes
"""
override val changesetComment = "Specify guidepost/map refs"
override val wikiLink = "Tag:information=guidepost"
override val icon = R.drawable.ic_quest_guidepost_ref
override val isDeleteElementEnabled = true
override val achievements = listOf(OUTDOORS)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes with information ~ guidepost|map")
override val highlightedElementsRadius: Double get() = 200.0

override val defaultDisabledMessage: Int = R.string.quest_guidepost_disabled_msg

override fun createForm() = AddGuidepostRefForm()

override fun applyAnswerTo(answer: GuidepostRefAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
is NoVisibleGuidepostRef -> tags["ref:signed"] = "no"
is GuidepostRef -> tags["ref"] = answer.ref
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.westnordost.streetcomplete.quests.guidepost

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.core.widget.doAfterTextChanged
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.databinding.QuestGuidepostRefBinding
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem
import de.westnordost.streetcomplete.util.ktx.nonBlankTextOrNull

class AddGuidepostRefForm : AbstractOsmQuestForm<GuidepostRefAnswer>() {

override val contentLayoutResId = R.layout.quest_guidepost_ref
private val binding by contentViewBinding(QuestGuidepostRefBinding::bind)

override val otherAnswers = listOf(
AnswerItem(R.string.quest_ref_answer_noRef) { confirmNoRef() }
)

private val ref get() = binding.refInput.nonBlankTextOrNull

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.refInput.doAfterTextChanged { checkIsFormComplete() }
}

override fun onClickOk() {
applyAnswer(GuidepostRef(ref!!))
}

private fun confirmNoRef() {
val ctx = context ?: return
AlertDialog.Builder(ctx)
.setTitle(R.string.quest_generic_confirmation_title)
.setPositiveButton(R.string.quest_generic_confirmation_yes) { _, _ -> applyAnswer(NoVisibleGuidepostRef) }
.setNegativeButton(R.string.quest_generic_confirmation_no, null)
.show()
}

override fun isFormComplete() = ref != null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.westnordost.streetcomplete.quests.guidepost

sealed interface GuidepostNameAnswer

data class GuidepostName(val name: String) : GuidepostNameAnswer
object NoVisibleGuidepostName : GuidepostNameAnswer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.westnordost.streetcomplete.quests.guidepost

sealed interface GuidepostRefAnswer

data class GuidepostRef(val ref: String) : GuidepostRefAnswer
object NoVisibleGuidepostRef : GuidepostRefAnswer
51 changes: 51 additions & 0 deletions app/src/main/res/drawable/ic_quest_guidepost_ele.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="138dp"
android:height="138dp"
android:viewportWidth="138"
android:viewportHeight="138">
<path
android:pathData="m133,69c0,35.35 -28.65,64 -64,64 -35.35,0 -64,-28.65 -64,-64 0,-35.35 28.65,-64 64,-64 35.35,0 64,28.65 64,64"
android:strokeWidth="0.2"
android:fillColor="#9bbe55"/>
<path
android:pathData="M61,21h16.04v112h-16.04z"
android:strokeLineJoin="miter"
android:strokeWidth="25.9658"
android:fillColor="#666666"
android:strokeColor="#00000000"
android:strokeLineCap="butt"/>
<path
android:pathData="m28.96,41c-4.43,0 -8,3.96 -8,8.87v38.27c0,4.91 3.57,8.87 8,8.87h79.99c4.43,0 8,-3.95 8,-8.87L116.95,49.87c0,-4.91 -3.57,-8.87 -8,-8.87z"
android:strokeAlpha="0.4"
android:strokeLineJoin="round"
android:strokeWidth="6.51836"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="0.2"
android:strokeLineCap="round"/>
<path
android:pathData="M29,37L109,37A8,8.87 0,0 1,117 45.87L117,84.13A8,8.87 0,0 1,109 93L29,93A8,8.87 0,0 1,21 84.13L21,45.87A8,8.87 0,0 1,29 37z"
android:strokeAlpha="0.4"
android:strokeLineJoin="round"
android:strokeWidth="6.51836"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:strokeLineCap="round"/>
<path
android:pathData="m29,53v24c4,0 8,4 8,8h64c0,-4 4.69,-8 8,-8v-24c-4,0 -8,-4 -8,-8h-64c0,4 -4,8 -8,8z"
android:strokeLineJoin="miter"
android:strokeWidth="5.0152"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:fillType="evenOdd"
android:strokeLineCap="butt"/>
<path
android:pathData="m60.91,68.08v1.76L44.39,69.83q0.23,3.71 2.23,5.66 2.01,1.93 5.59,1.93 2.07,0 4,-0.51 1.95,-0.51 3.87,-1.52v3.4q-1.93,0.82 -3.96,1.25 -2.03,0.43 -4.12,0.43 -5.23,0 -8.3,-3.05 -3.05,-3.05 -3.05,-8.24 0,-5.37 2.89,-8.52 2.91,-3.16 7.83,-3.16 4.41,0 6.97,2.85 2.58,2.83 2.58,7.71zM57.32,67.02q-0.04,-2.95 -1.66,-4.71 -1.6,-1.76 -4.26,-1.76 -3.01,0 -4.82,1.7 -1.8,1.7 -2.07,4.79z"
android:fillColor="#e6e6e6"/>
<path
android:pathData="m66.81,49.52h3.59v30.39h-3.59z"
android:fillColor="#e6e6e6"/>
<path
android:pathData="m96.63,68.08v1.76L80.11,69.83q0.23,3.71 2.23,5.66 2.01,1.93 5.59,1.93 2.07,0 4,-0.51 1.95,-0.51 3.87,-1.52v3.4q-1.93,0.82 -3.96,1.25 -2.03,0.43 -4.12,0.43 -5.23,0 -8.3,-3.05 -3.05,-3.05 -3.05,-8.24 0,-5.37 2.89,-8.52 2.91,-3.16 7.83,-3.16 4.41,0 6.97,2.85 2.58,2.83 2.58,7.71zM93.04,67.02q-0.04,-2.95 -1.66,-4.71 -1.6,-1.76 -4.26,-1.76 -3.01,0 -4.82,1.7 -1.8,1.7 -2.07,4.79z"
android:fillColor="#e6e6e6"/>
</vector>
58 changes: 58 additions & 0 deletions app/src/main/res/drawable/ic_quest_guidepost_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="138dp"
android:height="138dp"
android:viewportWidth="138"
android:viewportHeight="138">
<path
android:pathData="m133,69c0,35.35 -28.65,64 -64,64 -35.35,0 -64,-28.65 -64,-64 0,-35.35 28.65,-64 64,-64 35.35,0 64,28.65 64,64"
android:strokeWidth="0.2"
android:fillColor="#9bbe55"/>
<path
android:pathData="M61,21h16.04v112h-16.04z"
android:strokeLineJoin="miter"
android:strokeWidth="25.9658"
android:fillColor="#666666"
android:strokeColor="#00000000"
android:strokeLineCap="butt"/>
<path
android:pathData="m28.96,41c-4.43,0 -8,3.96 -8,8.87v38.27c0,4.91 3.57,8.87 8,8.87h79.99c4.43,0 8,-3.95 8,-8.87L116.95,49.87c0,-4.91 -3.57,-8.87 -8,-8.87z"
android:strokeAlpha="0.4"
android:strokeLineJoin="round"
android:strokeWidth="6.51836"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="0.2"
android:strokeLineCap="round"/>
<path
android:pathData="M29,37L109,37A8,8.87 0,0 1,117 45.87L117,84.13A8,8.87 0,0 1,109 93L29,93A8,8.87 0,0 1,21 84.13L21,45.87A8,8.87 0,0 1,29 37z"
android:strokeAlpha="0.4"
android:strokeLineJoin="round"
android:strokeWidth="6.51836"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:strokeLineCap="round"/>
<path
android:pathData="m29,53v24c4,0 8,4 8,8h64c0,-4 4.69,-8 8,-8v-24c-4,0 -8,-4 -8,-8h-64c0,4 -4,8 -8,8z"
android:strokeLineJoin="miter"
android:strokeWidth="5.0152"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:fillType="evenOdd"
android:strokeLineCap="butt"/>
<path
android:pathData="m51.15,63.85v6.63h-1.81v-6.58q0,-1.56 -0.61,-2.34 -0.61,-0.78 -1.83,-0.78 -1.46,0 -2.31,0.93 -0.84,0.93 -0.84,2.54v6.21L41.95,70.49L41.95,59.49h1.82v1.71q0.65,-0.99 1.52,-1.48 0.88,-0.49 2.03,-0.49 1.89,0 2.87,1.18 0.97,1.17 0.97,3.44z"
android:strokeWidth="0.502475"
android:fillColor="#e6e6e6"/>
<path
android:pathData="m59.75,64.96q-2.19,0 -3.03,0.5 -0.84,0.5 -0.84,1.71 0,0.96 0.63,1.53 0.64,0.56 1.73,0.56 1.5,0 2.4,-1.06 0.91,-1.07 0.91,-2.84v-0.4zM63.35,64.21v6.27h-1.81v-1.67q-0.62,1 -1.54,1.48 -0.92,0.47 -2.26,0.47 -1.69,0 -2.69,-0.94 -0.99,-0.95 -0.99,-2.54 0,-1.85 1.24,-2.8 1.25,-0.94 3.71,-0.94h2.53v-0.18q0,-1.25 -0.82,-1.92 -0.81,-0.69 -2.3,-0.69 -0.94,0 -1.84,0.23 -0.89,0.23 -1.72,0.68v-1.67q0.99,-0.38 1.92,-0.57 0.93,-0.2 1.82,-0.2 2.38,0 3.56,1.24 1.18,1.24 1.18,3.75z"
android:strokeWidth="0.502475"
android:fillColor="#e6e6e6"/>
<path
android:pathData="m75.63,61.6q0.68,-1.22 1.62,-1.8 0.94,-0.58 2.22,-0.58 1.72,0 2.65,1.21 0.93,1.2 0.93,3.42v6.63h-1.82v-6.58q0,-1.58 -0.56,-2.35 -0.56,-0.77 -1.71,-0.77 -1.4,0 -2.22,0.93 -0.81,0.93 -0.81,2.54v6.21h-1.82v-6.58q0,-1.59 -0.56,-2.35 -0.56,-0.77 -1.73,-0.77 -1.38,0 -2.2,0.94 -0.81,0.93 -0.81,2.53v6.21L67,70.49L67,59.49h1.82v1.71q0.62,-1.01 1.48,-1.49 0.86,-0.48 2.05,-0.48 1.2,0 2.03,0.61 0.84,0.61 1.25,1.77z"
android:strokeWidth="0.502475"
android:fillColor="#e6e6e6"/>
<path
android:pathData="m96.05,64.54v0.88h-8.3q0.12,1.86 1.12,2.85 1.01,0.97 2.81,0.97 1.04,0 2.01,-0.26 0.98,-0.26 1.94,-0.77v1.71q-0.97,0.41 -1.99,0.63 -1.02,0.22 -2.07,0.22 -2.63,0 -4.17,-1.53 -1.53,-1.53 -1.53,-4.14 0,-2.7 1.45,-4.28 1.46,-1.59 3.94,-1.59 2.22,0 3.5,1.43 1.3,1.42 1.3,3.88zM94.25,64.01q-0.02,-1.48 -0.83,-2.37 -0.8,-0.88 -2.14,-0.88 -1.51,0 -2.42,0.85 -0.9,0.85 -1.04,2.4z"
android:strokeWidth="0.502475"
android:fillColor="#e6e6e6"/>
</vector>
Loading