-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2065 from matkoniecz/summit_register
Summit register (#561) [ready for review, icon added]
- Loading branch information
Showing
5 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/de/westnordost/streetcomplete/quests/summit_register/AddSummitRegister.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.