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

Summit register (#561) [ready for review, icon added] #2065

Merged
merged 5 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> {

override val commitMessage = "Add whether summit register is present"
override val wikiLink = "Key:summit:register"
override val icon = R.drawable.ic_quest_peak

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<String, String>) = 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(4).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()))

}
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_quest_peak.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector android:height="128dp" android:viewportHeight="33.86667"
android:viewportWidth="33.86667" android:width="128dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#9bbe55"
android:pathData="m33.8667,16.9333c0,9.352 -7.5814,16.9333 -16.9333,16.9333 -9.352,0 -16.9333,-7.5814 -16.9333,-16.9333 0,-9.352 7.5814,-16.9333 16.9333,-16.9333 9.352,0 16.9333,7.5814 16.9333,16.9333" android:strokeWidth="0.05291667"/>
<path android:fillColor="#646464"
android:pathData="m16.9333,8.4667c-6.2873,0 -12.0157,10.2368 -14.9236,16.4713 2.8567,5.3145 8.4675,8.9287 14.9236,8.9287 6.4562,0 12.067,-3.6141 14.9236,-8.9287 -2.9079,-6.2345 -8.6363,-16.4713 -14.9236,-16.4713z"
android:strokeColor="#00000000" android:strokeLineCap="butt"
android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
<path android:fillColor="#f0f0f0"
android:pathData="m16.9333,8.4667c-4.2358,0 -8.2215,4.6516 -11.2608,9.5937 1.6465,-0.5617 3.3886,-2.2181 5.0431,-2.1854 1.9142,0.0378 2.5846,2.3167 4.4979,2.249 1.4348,-0.0508 2.0075,-1.4865 3.4396,-1.5875 1.8668,-0.1317 2.7619,2.3569 4.6302,2.249 1.7557,-0.1015 2.9265,-0.9848 3.7595,-2.5053 -2.8629,-4.2225 -6.3887,-7.8135 -10.1095,-7.8135z"
android:strokeColor="#00000000" android:strokeLineCap="butt"
android:strokeLineJoin="miter" android:strokeWidth="0.26458332"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -889,5 +889,6 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="at_conscription_and_street_number">conscription number %1$s, orientation number %2$s:</string>
<string name="at_conscription_number">conscription number %s:</string>
<string name="at_housenumber">house number %s:</string>
<string name="quest_summit_register_title">Is there a summit register at %s?</string>

</resources>
38 changes: 29 additions & 9 deletions res/quest_icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.