From abc62e2e0c8be23671a35a9f824afb0f02099205 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Sep 2020 11:49:43 +0200 Subject: [PATCH 1/5] ask about summit register fixes #561 --- .../streetcomplete/quests/QuestModule.kt | 2 + .../summit_register/AddSummitRegister.kt | 74 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 77 insertions(+) create mode 100644 app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.kt index da021d7dff..c05535a845 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.kt @@ -57,6 +57,7 @@ import de.westnordost.streetcomplete.quests.postbox_collection_times.AddPostboxC import de.westnordost.streetcomplete.quests.postbox_ref.AddPostboxRef import de.westnordost.streetcomplete.quests.powerpoles_material.AddPowerPolesMaterial import de.westnordost.streetcomplete.quests.railway_crossing.AddRailwayCrossingBarrier +import de.westnordost.streetcomplete.quests.railway_crossing.AddSummitRegister import de.westnordost.streetcomplete.quests.recycling.AddRecyclingType import de.westnordost.streetcomplete.quests.recycling_glass.DetermineRecyclingGlass import de.westnordost.streetcomplete.quests.recycling_material.AddRecyclingContainerMaterials @@ -177,6 +178,7 @@ object QuestModule // ↓ 8. defined in the wiki, but not really used by anyone yet. Just collected for // the sake of mapping it in case it makes sense later + AddSummitRegister(o, r), AddCyclewayPartSurface(o, r), AddFootwayPartSurface(o, r), AddMotorcycleParkingCover(o), diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt new file mode 100644 index 0000000000..d007cace7f --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt @@ -0,0 +1,74 @@ +package de.westnordost.streetcomplete.quests.railway_crossing + +import de.westnordost.osmapi.map.data.BoundingBox +import de.westnordost.osmapi.map.data.Element +import de.westnordost.streetcomplete.R +import de.westnordost.streetcomplete.data.elementfilter.filters.RelativeDate +import de.westnordost.streetcomplete.data.elementfilter.filters.TagOlderThan +import de.westnordost.streetcomplete.data.osm.elementgeometry.ElementGeometry +import de.westnordost.streetcomplete.data.osm.osmquest.OsmElementQuestType +import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder +import de.westnordost.streetcomplete.data.osm.mapdata.OverpassMapDataAndGeometryApi +import de.westnordost.streetcomplete.data.elementfilter.getQuestPrintStatement +import de.westnordost.streetcomplete.data.elementfilter.toGlobalOverpassBBox +import de.westnordost.streetcomplete.data.meta.updateWithCheckDate +import de.westnordost.streetcomplete.data.quest.NoCountriesExcept +import de.westnordost.streetcomplete.quests.YesNoQuestAnswerFragment +import de.westnordost.streetcomplete.settings.ResurveyIntervalsStore + +class AddSummitRegister( + private val overpassMapDataApi: OverpassMapDataAndGeometryApi, + private val r: ResurveyIntervalsStore +) : OsmElementQuestType { + + override val commitMessage = "Add whatever summit register is present" + override val wikiLink = "Key:summit:register" + override val icon = R.drawable.ic_quest_railway + + override val enabledInCountries = NoCountriesExcept( + // regions gathered in + // https://github.com/westnordost/StreetComplete/issues/561#issuecomment-325623974 + + // Europe + "AT", "DE", "CZ", "ES", "IT", "FR", "GR", "SI", "CH", "RO", "SK", + + //Americas + "US", "AR", "PE" + ) + + override fun getTitle(tags: Map) = R.string.quest_summit_register_title + + override fun createForm() = YesNoQuestAnswerFragment() + + override fun download(bbox: BoundingBox, handler: (element: Element, geometry: ElementGeometry?) -> Unit): Boolean { + return overpassMapDataApi.query(getOverpassQuery(bbox), handler) + } + + override fun isApplicableTo(element: Element): Boolean? = null + + override fun applyAnswerTo(answer: Boolean, changes: StringMapChangesBuilder) { + if (answer) { + changes.updateWithCheckDate("summit:register", "yes") + } else { + changes.updateWithCheckDate("summit:register", "no") + } + } + + private fun getOverpassQuery(bbox: BoundingBox) = """ + ${bbox.toGlobalOverpassBBox()} + + ( + relation["route"="hiking"]; + )->.hiking; + node(around.hiking:10)[natural=peak][!"summit:register"][name] -> .summits_with_unknown_status; + node(around.hiking:10)["summit:register"][name]${olderThan(8).toOverpassQLString()} -> .summits_with_old_status; + + (.summits_with_unknown_status; .summits_with_old_status;); + + ${getQuestPrintStatement()} + """.trimIndent() + + private fun olderThan(years: Int) = + TagOlderThan("summit:register", RelativeDate(-(r * 365 * years).toFloat())) + +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a2670e44a6..9d15c967c2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -889,5 +889,6 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards conscription number %1$s, orientation number %2$s: conscription number %s: house number %s: + Is there a summit register at %s? From f0171d737d07586a67d28ce288ebf5f05dc8937d Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Sep 2020 14:41:21 +0200 Subject: [PATCH 2/5] add TODO note about placeholder --- .../streetcomplete/quests/summit_register/AddSummitRegister.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt index d007cace7f..bb7b492c95 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt @@ -23,7 +23,7 @@ class AddSummitRegister( override val commitMessage = "Add whatever summit register is present" override val wikiLink = "Key:summit:register" - override val icon = R.drawable.ic_quest_railway + override val icon = R.drawable.ic_quest_railway //TODO fix blatant placeholder override val enabledInCountries = NoCountriesExcept( // regions gathered in From cdff0f860000cb388575fbbb5c887fef2a001735 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Sep 2020 16:24:10 +0200 Subject: [PATCH 3/5] add attempt to draw a mountain --- res/quest_icons.svg | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/res/quest_icons.svg b/res/quest_icons.svg index c5e46eac91..5aeb6454e9 100644 --- a/res/quest_icons.svg +++ b/res/quest_icons.svg @@ -13,7 +13,7 @@ viewBox="0 0 1536 1536" id="svg4497" sodipodi:docname="quest_icons.svg" - inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)" inkscape:export-filename="C:\Users\Newton\AndroidStudioProjects\streetcomplete\res\quest_icons.svg.png" inkscape:export-xdpi="95.983444" inkscape:export-ydpi="95.983444"> @@ -367,17 +367,17 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1137" + inkscape:window-width="1366" + inkscape:window-height="708" id="namedview4499" showgrid="true" - inkscape:zoom="0.5" - inkscape:cx="743.99669" - inkscape:cy="716.20451" - inkscape:window-x="1912" - inkscape:window-y="-8" + inkscape:zoom="2" + inkscape:cx="1488.1839" + inkscape:cy="467.96591" + inkscape:window-x="0" + inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="svg4497" + inkscape:current-layer="playground-3" showguides="true" inkscape:lockguides="true" inkscape:snap-global="true" @@ -11353,4 +11353,24 @@ style="fill:none;fill-opacity:1;stroke:#a6a6a6;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" /> + + + + + From e0d06f5556711efc18ea8f55d5bfdf5569e4f27a Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Sep 2020 16:33:17 +0200 Subject: [PATCH 4/5] peak icon exported and used --- .../quests/summit_register/AddSummitRegister.kt | 2 +- app/src/main/res/drawable/ic_quest_peak.xml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/ic_quest_peak.xml diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt index bb7b492c95..97cac33f1a 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt @@ -23,7 +23,7 @@ class AddSummitRegister( override val commitMessage = "Add whatever summit register is present" override val wikiLink = "Key:summit:register" - override val icon = R.drawable.ic_quest_railway //TODO fix blatant placeholder + override val icon = R.drawable.ic_quest_peak override val enabledInCountries = NoCountriesExcept( // regions gathered in diff --git a/app/src/main/res/drawable/ic_quest_peak.xml b/app/src/main/res/drawable/ic_quest_peak.xml new file mode 100644 index 0000000000..caaa38f87a --- /dev/null +++ b/app/src/main/res/drawable/ic_quest_peak.xml @@ -0,0 +1,13 @@ + + + + + From 0b969fe8bcd91396edb9aeead8634ef8ef1890f1 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Sep 2020 21:00:28 +0200 Subject: [PATCH 5/5] changes based on feedback --- .../quests/summit_register/AddSummitRegister.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt index 97cac33f1a..d959fe4b71 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt @@ -21,7 +21,7 @@ class AddSummitRegister( private val r: ResurveyIntervalsStore ) : OsmElementQuestType { - override val commitMessage = "Add whatever summit register is present" + override val commitMessage = "Add whether summit register is present" override val wikiLink = "Key:summit:register" override val icon = R.drawable.ic_quest_peak @@ -61,7 +61,7 @@ class AddSummitRegister( relation["route"="hiking"]; )->.hiking; node(around.hiking:10)[natural=peak][!"summit:register"][name] -> .summits_with_unknown_status; - node(around.hiking:10)["summit:register"][name]${olderThan(8).toOverpassQLString()} -> .summits_with_old_status; + node(around.hiking:10)["summit:register"][name]${olderThan(4).toOverpassQLString()} -> .summits_with_old_status; (.summits_with_unknown_status; .summits_with_old_status;);