Skip to content

Commit

Permalink
Merge pull request #4008 from FloEdelmann/bicycle-rental-capacity
Browse files Browse the repository at this point in the history
Add bicycle rental capacity quest
  • Loading branch information
westnordost authored May 15, 2022
2 parents fdb8b96 + 51314f5 commit 5e90700
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import de.westnordost.streetcomplete.quests.bench_backrest.AddBenchBackrest
import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacity
import de.westnordost.streetcomplete.quests.bike_parking_cover.AddBikeParkingCover
import de.westnordost.streetcomplete.quests.bike_parking_type.AddBikeParkingType
import de.westnordost.streetcomplete.quests.bike_rental_capacity.AddBikeRentalCapacity
import de.westnordost.streetcomplete.quests.bike_rental_type.AddBikeRentalType
import de.westnordost.streetcomplete.quests.board_type.AddBoardType
import de.westnordost.streetcomplete.quests.bollard_type.AddBollardType
Expand Down Expand Up @@ -323,6 +324,7 @@ fun questTypeRegistry(
AddBikeParkingType(), // used by OsmAnd
AddBikeParkingAccess(),
AddBikeParkingFee(),
AddBikeRentalCapacity(), // less ambiguous than bike parking
AddBikeParkingCapacity(), // used by cycle map layer on osm.org, OsmAnd

// address: usually only visible when just in front + sometimes requires to take "other answer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AddBikeParkingCapacity : OsmFilterQuestType<Int>() {
override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes, ways with amenity = bicycle_parking")

override fun createForm() = AddBikeParkingCapacityForm()
override fun createForm() = AddBikeParkingCapacityForm.create(showClarificationText = true)

override fun applyAnswerTo(answer: Int, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("capacity", answer.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package de.westnordost.streetcomplete.quests.bike_parking_capacity

import android.os.Bundle
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.widget.doAfterTextChanged
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.databinding.QuestBikeParkingCapacityBinding
Expand All @@ -17,6 +19,8 @@ class AddBikeParkingCapacityForm : AbstractQuestFormAnswerFragment<Int>() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val showClarificationText = arguments?.getBoolean(ARG_SHOW_CLARIFICATION) ?: false
binding.clarificationText.isGone = !showClarificationText
binding.capacityInput.doAfterTextChanged { checkIsFormComplete() }
}

Expand All @@ -25,4 +29,14 @@ class AddBikeParkingCapacityForm : AbstractQuestFormAnswerFragment<Int>() {
override fun onClickOk() {
applyAnswer(capacity)
}

companion object {
private const val ARG_SHOW_CLARIFICATION = "show_clarification"

fun create(showClarificationText: Boolean): AddBikeParkingCapacityForm {
val form = AddBikeParkingCapacityForm()
form.arguments = bundleOf(ARG_SHOW_CLARIFICATION to showClarificationText)
return form
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.westnordost.streetcomplete.quests.bike_rental_capacity

import de.westnordost.streetcomplete.R
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.osm.osmquests.Tags
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.BICYCLIST
import de.westnordost.streetcomplete.osm.updateWithCheckDate
import de.westnordost.streetcomplete.quests.bike_parking_capacity.AddBikeParkingCapacityForm

class AddBikeRentalCapacity : OsmFilterQuestType<Int>() {

override val elementFilter = """
nodes, ways with
amenity = bicycle_rental
and access !~ private|no
and bicycle_rental = docking_station
and (!capacity or capacity older today -6 years)
"""

override val changesetComment = "Add bicycle rental capacities"
override val wikiLink = "Tag:amenity=bicycle_rental"
override val icon = R.drawable.ic_quest_bicycle_rental_capacity
override val isDeleteElementEnabled = true
override val questTypeAchievements = listOf(BICYCLIST)

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

override fun getHighlightedElements(element: Element, getMapData: () -> MapDataWithGeometry) =
getMapData().filter("nodes, ways with amenity = bicycle_rental")

override fun createForm() = AddBikeParkingCapacityForm.create(showClarificationText = false)

override fun applyAnswerTo(answer: Int, tags: Tags, timestampEdited: Long) {
tags.updateWithCheckDate("capacity", answer.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.westnordost.streetcomplete.quests.getNameLabel
"atm" -> return R.drawable.ic_pin_money
"bench" -> return R.drawable.ic_pin_bench
"bicycle_parking" -> return R.drawable.ic_pin_bicycle_parking
"bicycle_rental" -> return R.drawable.ic_pin_bicycle_rental
"bicycle_repair_station" -> {
if (map["service:bicycle:pump"] == "yes") return R.drawable.ic_pin_bicycle_pump
}
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/ic_pin_bicycle_rental.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="m9.3642,4.5455h21.272c1.8134,0 3.2733,1.4599 3.2733,3.2733v24.363c0,1.8134 -1.4599,3.2733 -3.2733,3.2733h-21.272c-1.8134,0 -3.2733,-1.4599 -3.2733,-3.2733v-24.363c0,-1.8134 1.4599,-3.2733 3.2733,-3.2733z"
android:strokeWidth="3"
android:fillColor="#495aad"
android:strokeColor="#fff"/>
<path
android:pathData="m17.703,27.947a3.8926,3.8926 0,0 1,-3.8926 3.8926,3.8926 3.8926,0 0,1 -3.8926,-3.8926 3.8926,3.8926 0,0 1,3.8926 -3.8926,3.8926 3.8926,0 0,1 3.8926,3.8926m12.685,-0.0007a3.8926,3.8926 0,0 1,-3.8926 3.8926,3.8926 3.8926,0 0,1 -3.8926,-3.8926 3.8926,3.8926 0,0 1,3.8926 -3.8926,3.8926 3.8926,0 0,1 3.8926,3.8926m-14.413,-5.9952 l4.9196,5.9736h5.6228l-3.8656,-5.9736h-6.6768m6.6768,-1.4056 l1.7126,-0.0035m-3.4696,7.3826 l1.757,-7.3795m-8.7851,7.3795 l2.9288,-8.7198h2.8112"
android:strokeWidth="1.3527"
android:fillColor="#00000000"
android:strokeColor="#fff"/>
<path
android:pathData="m29.274,10.126c-0.8883,-0.8865 -2.115,-1.4299 -3.4692,-1.4198 -2.2398,0 -4.1805,1.5122 -4.8118,3.524h-10.588l-1.2217,1.2192v0.8128l2.0362,2.0321h1.2217l1.2217,-1.2192h0.4072l1.2217,1.2192h2.4434l1.2217,-1.2192h2.0362c0.5905,2.0524 2.5313,3.4661 4.7507,3.4457 2.7489,0.0203 4.9682,-2.1945 4.9682,-4.9176 0,-1.3615 -0.5498,-2.5911 -1.4381,-3.4776zM28.3199,12.557c0.2698,0.2693 0.4379,0.6402 0.4379,1.0466 0.0204,0.8332 -0.6517,1.5038 -1.5069,1.5038 -0.8145,0 -1.4866,-0.6708 -1.4866,-1.4836 0,-0.8128 0.672,-1.4835 1.5069,-1.5038 0.4072,0 0.7789,0.1677 1.0487,0.437z"
android:fillColor="#fff"/>
</vector>
34 changes: 34 additions & 0 deletions app/src/main/res/drawable/ic_quest_bicycle_rental_capacity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="128dp"
android:height="128dp"
android:viewportWidth="128"
android:viewportHeight="128">
<path
android:pathData="m128,64c0,35.346 -28.654,64 -64,64s-64,-28.654 -64,-64 28.654,-64 64,-64 64,28.654 64,64"
android:strokeWidth=".2"
android:fillColor="#ca72e2"/>
<path
android:pathData="m36.222,24h55.056c4.694,0 8.472,3.779 8.472,8.472v63.056c0,4.694 -3.779,8.472 -8.472,8.472h-55.056c-4.694,0 -8.472,-3.779 -8.472,-8.472v-63.056c0,-4.694 3.779,-8.472 8.472,-8.472z"
android:strokeAlpha="0.2"
android:strokeWidth="8"
android:fillColor="#00000000"
android:strokeColor="#000"/>
<path
android:pathData="m36.347,20.111h55.056c4.694,0 8.472,3.779 8.472,8.472v63.056c0,4.694 -3.779,8.472 -8.472,8.472h-55.056c-4.694,0 -8.472,-3.779 -8.472,-8.472v-63.056c0,-4.694 3.779,-8.472 8.472,-8.472z"
android:strokeAlpha="0.98995"
android:strokeWidth="8"
android:fillColor="#495aad"
android:strokeColor="#fff"/>
<path
android:pathData="m87.877,34.851c-2.299,-2.295 -5.474,-3.701 -8.979,-3.675 -5.797,0 -10.82,3.914 -12.454,9.121h-27.405l-3.162,3.156v2.104l5.27,5.26h3.162l3.162,-3.156h1.054l3.162,3.156h6.324l3.162,-3.156h5.27c1.528,5.312 6.552,8.971 12.296,8.918 7.115,0.053 12.859,-5.68 12.859,-12.728 0,-3.524 -1.423,-6.706 -3.722,-9.001zM85.408,41.143c0.698,0.697 1.133,1.657 1.133,2.709 0.053,2.156 -1.687,3.892 -3.9,3.892 -2.108,0 -3.848,-1.736 -3.848,-3.84s1.739,-3.84 3.9,-3.892c1.054,0 2.016,0.434 2.714,1.131z"
android:strokeWidth=".74457"
android:fillColor="#fff"/>
<path
android:pathData="m39.599,67.319c2.299,-2.295 5.474,-3.701 8.979,-3.675 5.797,0 10.82,3.914 12.454,9.121h27.405l3.162,3.156v2.104l-5.27,5.26h-3.162l-3.162,-3.156h-1.054l-3.162,3.156h-6.324l-3.162,-3.156h-5.27c-1.528,5.312 -6.552,8.971 -12.296,8.918 -7.115,0.053 -12.859,-5.68 -12.859,-12.728 0,-3.524 1.423,-6.706 3.722,-9.001zM42.068,73.611c-0.698,0.697 -1.133,1.657 -1.133,2.709 -0.053,2.156 1.687,3.892 3.9,3.892 2.108,0 3.848,-1.736 3.848,-3.84s-1.739,-3.84 -3.9,-3.892c-1.054,0 -2.016,0.434 -2.714,1.131z"
android:strokeWidth=".74457"
android:fillColor="#fff"/>
<path
android:pathData="m36.348,16.111c-6.84,0 -12.473,5.63 -12.473,12.471v63.057c0,6.84 5.632,12.473 12.473,12.473h55.055c6.84,0 12.473,-5.632 12.473,-12.473v-63.057c0,-6.84 -5.632,-12.471 -12.473,-12.471zM36.348,24.111h55.055c2.547,0 4.473,1.924 4.473,4.471v63.057c0,2.547 -1.926,4.473 -4.473,4.473h-55.055c-2.547,0 -4.473,-1.926 -4.473,-4.473v-63.057c0,-2.547 1.926,-4.471 4.473,-4.471z"
android:fillColor="#fff"
android:fillAlpha="0.98995"/>
</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ However, before uploading your changes, the app checks with a &lt;a href=\"https
<string name="quest_bicycle_parking_type_building">Building</string>
<string name="quest_bicycle_parking_type_handlebarholder">Handlebar holder</string>


<string name="quest_bicycle_rental_capacity_title">How many rental bike spaces are here?</string>

<string name="quest_bicycle_rental_type_title">What type of bicycle rental is this?</string>
<string name="quest_bicycle_rental_type_docking_station">Docking station which locks bikes</string>
<string name="quest_bicycle_rental_type_dropoff_point">Designated spot (bikes locked individually)</string>
Expand Down
6 changes: 6 additions & 0 deletions res/graphics/pins/bicycle_rental.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions res/graphics/quest/bicycle_rental_capacity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5e90700

Please sign in to comment.