Skip to content

Commit

Permalink
Merge pull request #4010 from FloEdelmann/bicycle-rental-type
Browse files Browse the repository at this point in the history
Add bicycle rental type quest
  • Loading branch information
westnordost authored May 15, 2022
2 parents 1ca1410 + 374c046 commit fdb8b96
Show file tree
Hide file tree
Showing 23 changed files with 131 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_type.AddBikeRentalType
import de.westnordost.streetcomplete.quests.board_type.AddBoardType
import de.westnordost.streetcomplete.quests.bollard_type.AddBollardType
import de.westnordost.streetcomplete.quests.bridge_structure.AddBridgeStructure
Expand Down Expand Up @@ -316,8 +317,9 @@ fun questTypeRegistry(

/* ↓ 2.solvable when right in front of it but takes longer to input --------------------- */

// bike parking: would be higher up if not for bike parking capacity which is usually not solvable when moving past
// bike parking/rental: would be higher up if not for bike parking/rental capacity which is usually not solvable when moving past
AddBikeParkingCover(), // used by OsmAnd in the object description
AddBikeRentalType(), // generally less overlap of possible types/fewer choices/simpler to answer
AddBikeParkingType(), // used by OsmAnd
AddBikeParkingAccess(),
AddBikeParkingFee(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.westnordost.streetcomplete.quests.bike_rental_type

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

class AddBikeRentalType : OsmFilterQuestType<BikeRentalTypeAnswer>() {

override val elementFilter = """
nodes, ways with
amenity = bicycle_rental
and access !~ private|no
and (!bicycle_rental or bicycle_rental = yes)
and !shop
"""
override val changesetComment = "Add bicycle rental type"
override val wikiLink = "Key:bicycle_rental"
override val icon = R.drawable.ic_quest_bicycle_rental
override val isDeleteElementEnabled = true
override val questTypeAchievements = listOf(BICYCLIST)

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

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

override fun createForm() = AddBikeRentalTypeForm()

override fun applyAnswerTo(answer: BikeRentalTypeAnswer, tags: Tags, timestampEdited: Long) {
when (answer) {
is BikeRentalType -> {
tags["bicycle_rental"] = answer.osmValue
if (answer == BikeRentalType.HUMAN) {
tags["shop"] = "rental"
}
}
is BikeShopWithRental -> {
tags.remove("amenity")
tags["shop"] = "bicycle"
tags["service:bicycle:rental"] = "yes"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.westnordost.streetcomplete.quests.bike_rental_type

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AImageListQuestAnswerFragment
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.DOCKING_STATION
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.DROPOFF_POINT
import de.westnordost.streetcomplete.quests.bike_rental_type.BikeRentalType.HUMAN
import de.westnordost.streetcomplete.view.image_select.Item

class AddBikeRentalTypeForm : AImageListQuestAnswerFragment<BikeRentalTypeAnswer, BikeRentalTypeAnswer>() {

override val items: List<Item<BikeRentalTypeAnswer>> = listOf(
Item(DOCKING_STATION, R.drawable.bicycle_rental_docking_station, R.string.quest_bicycle_rental_type_docking_station),
Item(DROPOFF_POINT, R.drawable.bicycle_rental_dropoff_point, R.string.quest_bicycle_rental_type_dropoff_point),
Item(HUMAN, R.drawable.bicycle_rental_human, R.string.quest_bicycle_rental_type_human),
Item(BikeShopWithRental, R.drawable.bicycle_rental_shop_with_rental, R.string.quest_bicycle_rental_type_shop_with_rental),
)

override val itemsPerRow = 2
override val moveFavoritesToFront = false

override fun onClickOk(selectedItems: List<BikeRentalTypeAnswer>) {
applyAnswer(selectedItems.single())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.westnordost.streetcomplete.quests.bike_rental_type

sealed interface BikeRentalTypeAnswer

enum class BikeRentalType(val osmValue: String) : BikeRentalTypeAnswer {
DOCKING_STATION("docking_station"),
DROPOFF_POINT("dropoff_point"),
HUMAN("shop"),
}

object BikeShopWithRental : BikeRentalTypeAnswer
5 changes: 5 additions & 0 deletions app/src/main/res/authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ bicycle_parking_type_stand.jpg CC0 Mateusz Konieczny https://commo
bicycle_parking_type_wheel... CC-BY-SA 4.0 Joxemai https://commons.wikimedia.org/wiki/File:Bizikletak_lotzekoa.JPG
bicycle_parking_type_handl... CC-BY-SA 4.0 Hiddewie https://commons.wikimedia.org/wiki/File:Bicycle_parking_handlebar_holder.jpg

bicycle_rental_docking_stat... CC-BY-SA 3.0 Siyuwj https://commons.wikimedia.org/wiki/File:Bicycle_rental_site_of_Tiangongyuan_Station.JPG
bicycle_rental_dropoff_poin... CC-BY-SA 4.0 Alexander Migl https://commons.wikimedia.org/wiki/File:Stuttgart-Vaihingen_Train_Station_Mobility_Hub_IMG_5767.jpg
bicycle_rental_human.jpg CC-BY-SA 2.0 TijsB https://commons.wikimedia.org/wiki/File:Tel_Aviv-_bike_rental_(5889990605).jpg
bicycle_rental_shop_with_re... CC-BY-SA 2.0 Darb02 https://commons.wikimedia.org/wiki/File:Rydjor_Bike_Shop_and_Antique_Bike_Museum.jpg

bollard_fixed.jpg CC-BY-SA 4.0 Matija Nalis https://github.com/streetcomplete/StreetComplete/issues/3657#issuecomment-1020666101
bollard_flexible.jpg CC0 Ruben Kelevra https://commons.wikimedia.org/wiki/File:Flexible_bollard.jpg
bollard_foldable.jpg CC-BY-SA 3.0 Hauke Stieler https://wiki.openstreetmap.org/wiki/File:Bollard_foldable.jpg
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions app/src/main/res/drawable/ic_quest_bicycle_rental.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<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="m57.93,80.679a10.075,10.075 0,0 1,-10.075 10.075,10.075 10.075,0 0,1 -10.075,-10.075 10.075,10.075 0,0 1,10.075 -10.075,10.075 10.075,0 0,1 10.075,10.075m32.832,-0.002a10.075,10.075 0,0 1,-10.075 10.075,10.075 10.075,0 0,1 -10.075,-10.075 10.075,10.075 0,0 1,10.075 -10.075,10.075 10.075,0 0,1 10.075,10.075m-37.305,-15.517 l12.733,15.461h14.553l-10.005,-15.461h-17.281m17.281,-3.638 l4.433,-0.009m-8.98,19.108 l4.548,-19.1m-22.738,19.1 l7.581,-22.569h7.276"
android:strokeLineJoin="round"
android:strokeWidth="3.5012"
android:fillColor="#00000000"
android:strokeColor="#fff"
android:strokeLineCap="round"/>
<path
android:pathData="m87.877,34.554c-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,40.846c0.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.84 0,-2.104 1.739,-3.84 3.9,-3.892 1.054,0 2.016,0.434 2.714,1.131z"
android:strokeWidth=".74457"
android:fillColor="#fff"/>
</vector>
6 changes: 6 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,12 @@ 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_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>
<string name="quest_bicycle_rental_type_human">Human-operated bike rental</string>
<string name="quest_bicycle_rental_type_shop_with_rental">Bike store that also rents bikes</string>

<string name="quest_bikeParkingCapacity_title">"How many bikes can be parked here?"</string>
<string name="quest_bikeParkingCapacity_hint">"Note that most normal stands can be used from both sides to park each one bike."</string>

Expand Down

0 comments on commit fdb8b96

Please sign in to comment.