Skip to content

Commit e7d79d1

Browse files
authored
New Quest: AddFerryAccessBicycle (#6718)
1 parent 7152a42 commit e7d79d1

File tree

9 files changed

+153
-0
lines changed

9 files changed

+153
-0
lines changed

app/src/androidMain/kotlin/de/westnordost/streetcomplete/quests/QuestsModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import de.westnordost.streetcomplete.quests.diet_type.AddVegetarian
8888
import de.westnordost.streetcomplete.quests.drinking_water.AddDrinkingWater
8989
import de.westnordost.streetcomplete.quests.drinking_water_type.AddDrinkingWaterType
9090
import de.westnordost.streetcomplete.quests.existence.CheckExistence
91+
import de.westnordost.streetcomplete.quests.ferry.AddFerryAccessBicycle
9192
import de.westnordost.streetcomplete.quests.ferry.AddFerryAccessMotorVehicle
9293
import de.westnordost.streetcomplete.quests.ferry.AddFerryAccessPedestrian
9394
import de.westnordost.streetcomplete.quests.fire_hydrant.AddFireHydrantType
@@ -459,6 +460,7 @@ fun questTypeRegistry(
459460
// ferry: usually visible from looking at the boat, but not always...
460461
101 to AddFerryAccessPedestrian(),
461462
102 to AddFerryAccessMotorVehicle(),
463+
196 to AddFerryAccessBicycle(),
462464

463465
// aerial way: usually visible from looking at the aerial way, but not always...
464466
184 to AddAerialwayBicycleAccess(),
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package de.westnordost.streetcomplete.quests.ferry
2+
3+
import de.westnordost.streetcomplete.R
4+
import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression
5+
import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry
6+
import de.westnordost.streetcomplete.data.osm.mapdata.Element
7+
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry
8+
import de.westnordost.streetcomplete.data.osm.mapdata.Way
9+
import de.westnordost.streetcomplete.data.osm.mapdata.filter
10+
import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType
11+
import de.westnordost.streetcomplete.data.quest.AndroidQuest
12+
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement
13+
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.RARE
14+
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder
15+
16+
class AddFerryAccessBicycle :
17+
OsmElementQuestType<FerryBicycleAccess>,
18+
AndroidQuest {
19+
20+
private val filter by lazy {
21+
"ways, relations with route = ferry and !bicycle and !bicycle:signed"
22+
.toElementFilterExpression()
23+
}
24+
25+
override val changesetComment = "Specify ferry access for bicycles"
26+
override val wikiLink = "Tag:route=ferry"
27+
override val icon = R.drawable.ic_quest_ferry_bicycle
28+
override val hasMarkersAtEnds = true
29+
override val achievements = listOf(RARE, EditTypeAchievement.BICYCLIST)
30+
31+
override fun getTitle(tags: Map<String, String>) =
32+
R.string.quest_ferry_bicycle_title
33+
34+
override fun createForm() = AddFerryAccessBicycleForm()
35+
36+
override fun applyAnswerTo(
37+
answer: FerryBicycleAccess,
38+
tags: StringMapChangesBuilder,
39+
geometry: ElementGeometry,
40+
timestampEdited: Long
41+
) {
42+
when (answer) {
43+
FerryBicycleAccess.YES ->
44+
tags["bicycle"] = "yes"
45+
46+
FerryBicycleAccess.NO ->
47+
tags["bicycle"] = "no"
48+
49+
FerryBicycleAccess.NOT_SIGNED ->
50+
tags["bicycle:signed"] = "no"
51+
}
52+
}
53+
54+
override fun getApplicableElements(
55+
mapData: MapDataWithGeometry
56+
): Iterable<Element> {
57+
val wayIdsInFerryRoutes = wayIdsInFerryRoutes(mapData.relations)
58+
return mapData
59+
.filter(filter)
60+
.filter { it !is Way || it.id !in wayIdsInFerryRoutes }
61+
.asIterable()
62+
}
63+
64+
override fun isApplicableTo(element: Element): Boolean? {
65+
if (!filter.matches(element)) return false
66+
if (element is Way) return null
67+
return true
68+
}
69+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package de.westnordost.streetcomplete.quests.ferry
2+
3+
import de.westnordost.streetcomplete.R
4+
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
5+
import de.westnordost.streetcomplete.quests.AnswerItem
6+
7+
class AddFerryAccessBicycleForm :
8+
AbstractOsmQuestForm<FerryBicycleAccess>() {
9+
10+
override val buttonPanelAnswers = listOf(
11+
AnswerItem(R.string.quest_generic_hasFeature_no) {
12+
applyAnswer(FerryBicycleAccess.NO)
13+
},
14+
AnswerItem(R.string.quest_generic_hasFeature_yes) {
15+
applyAnswer(FerryBicycleAccess.YES)
16+
}
17+
)
18+
19+
override val otherAnswers = listOf(
20+
AnswerItem(R.string.quest_generic_answer_noSign) {
21+
applyAnswer(FerryBicycleAccess.NOT_SIGNED)
22+
}
23+
)
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package de.westnordost.streetcomplete.quests.ferry
2+
3+
enum class FerryBicycleAccess {
4+
YES,
5+
NO,
6+
NOT_SIGNED
7+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="128dp"
3+
android:height="128dp"
4+
android:viewportWidth="128"
5+
android:viewportHeight="128">
6+
<path
7+
android:pathData="M119.4,96c-17.7,30.6 -56.8,41.1 -87.4,23.4C1.4,101.7 -9.1,62.6 8.6,32 26.3,1.4 65.4,-9.1 96,8.6c30.6,17.7 41.1,56.8 23.4,87.4"
8+
android:fillColor="#ca72e2"/>
9+
<path
10+
android:fillColor="#FF000000"
11+
android:pathData="M30.4,40c-0.9,0 -1.6,0.4 -1.6,0.8v1.6c0,0.4 0.7,0.8 1.5,0.8l-2.7,18.9h2.8c0.9,0 1.6,0.7 1.6,1.6v4.2H10.1c2.2,7.5 8,16 8,16 1.6,2.4 3.7,4.9 5.2,6.2 15.8,14.5 88.8,5.8 88.8,5.8 0,0 1.6,-5.3 3,-12 0,0 3,-11 3,-16h-19.9v-4.2c0,-0.9 0.7,-1.6 1.6,-1.6h6l-1.3,-6.3h-50.4v-12.6c0.9,0 1.6,-0.4 1.6,-0.8v-1.6c0,-0.4 -0.7,-0.8 -1.6,-0.8h-23.6Z"
12+
android:fillAlpha="0.2"/>
13+
<path
14+
android:pathData="M18,80c1.6,2.4 3.7,4.9 5.2,6.2 15.8,14.5 88.8,5.8 88.8,5.8 0,0 1.6,-5.3 3,-12H18Z"
15+
android:fillColor="#dd2e44"/>
16+
<path
17+
android:pathData="M49.3,23.5c-0.9,0 -1.6,0.7 -1.6,1.6v12.6c0,0.3 0.1,0.7 0.3,0.9h-3.5v-7.2c0,-0.9 -0.7,-1.6 -1.6,-1.6s-1.6,0.7 -1.6,1.6v7.2h-11l-2.8,19.6h2.8c0.9,0 1.6,0.7 1.6,1.6v4.2H10c2.2,7.5 8,16 8,16h97s3,-11 3,-16h-19.9v-4.2c0,-0.9 0.7,-1.6 1.6,-1.6h6l-1.3,-6.3h-50.4v-13.3h-3.5c0.2,-0.3 0.3,-0.6 0.3,-0.9v-12.6c0,-0.9 -0.7,-1.6 -1.6,-1.6h0Z"
18+
android:fillColor="#ccd6dd"/>
19+
<path
20+
android:pathData="M29.9,42.4l-0.9,6.3h12.5v-6.3h-11.5ZM44.5,42.4v6.3h4.7c0.9,0 1.6,-0.7 1.6,-1.6v-3.2c0,-0.9 -0.7,-1.6 -1.6,-1.6h-4.7ZM36.7,58.2c-0.9,0 -1.6,0.7 -1.6,1.6v4.2h15.8v-4.2c0,-0.9 -0.7,-1.6 -1.6,-1.6h-12.6ZM58.7,58.2c-0.9,0 -1.6,0.7 -1.6,1.6v4.2h15.8v-4.2c0,-0.9 -0.7,-1.6 -1.6,-1.6h-12.6ZM80.8,58.2c-0.9,0 -1.6,0.7 -1.6,1.6v4.2h15.8v-4.2c0,-0.9 -0.7,-1.6 -1.6,-1.6h-12.6ZM27.2,70.8c-0.9,0 -1.6,0.7 -1.6,1.6v3.2c0,0.9 0.7,1.6 1.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,88.4c5.2,12.8 14.5,24 27.3,31.5 7.8,4.5 16.1,7.1 24.4,8.1h15.1c19.3,-2.3 37.4,-13.4 47.9,-31.6 1.5,-2.6 2.8,-5.3 3.9,-8 -10,-2 -19.7,-1.6 -29.7,0 -10.1,1.6 -21.6,2.2 -29.7,0 -18,-4.8 -22.9,1.9 -29.7,0 -5.7,-1.6 -14.6,-9.3 -17.1,-0.4l-12.5,0.4Z"
27+
android:fillColor="#3e74c9"/>
28+
<path
29+
android:fillColor="#FF000000"
30+
android:pathData="M21.7,88.1c-1,0 -2,0.3 -2.8,1.1 1.5,2.1 3.2,4.1 4.5,5.2 15.8,14.5 88.8,5.8 88.8,5.8 0,0 1.1,-3.6 2.2,-8.6 -6.9,-0.5 -13.8,0 -20.8,1.1 -10.1,1.6 -21.6,2.2 -29.7,0 -18,-4.8 -22.9,1.9 -29.7,0 -3.7,-1.1 -8.8,-4.7 -12.6,-4.6h0Z"
31+
android:fillAlpha="0.1"/>
32+
</vector>

app/src/androidMain/res/values-en/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,8 @@ A level counts as a roof level when its windows are in the roof. Subsequently, r
11441144

11451145
<string name="quest_ferry_motor_vehicle_title">Does this ferry route transport motor vehicles?</string>
11461146

1147+
<string name="quest_ferry_bicycle_title">Are bicycles allowed on this ferry?</string>
1148+
11471149
<string name="quest_fireHydrant_diameter_title">What diameter is specified on the sign for this fire hydrant?</string>
11481150
<string name="quest_fireHydrant_diameter_unusualInput_confirmation_description2">This diameter looks implausible, it is usually between %1$d and %2$d.</string>
11491151

app/src/androidMain/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,8 @@ A level counts as a roof level when its windows are in the roof. Subsequently, r
11441144

11451145
<string name="quest_ferry_motor_vehicle_title">Does this ferry route transport motor vehicles?</string>
11461146

1147+
<string name="quest_ferry_bicycle_title">Are bicycles allowed on this ferry?</string>
1148+
11471149
<string name="quest_fireHydrant_diameter_title">What diameter is specified on the sign for this fire hydrant?</string>
11481150
<string name="quest_fireHydrant_diameter_unusualInput_confirmation_description2">This diameter looks implausible, it is usually between %1$d and %2$d.</string>
11491151

app/src/commonMain/composeResources/values-en/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,8 @@ A level counts as a roof level when its windows are in the roof. Subsequently, r
11441144

11451145
<string name="quest_ferry_motor_vehicle_title">Does this ferry route transport motor vehicles?</string>
11461146

1147+
<string name="quest_ferry_bicycle_title">Are bicycles allowed on this ferry?</string>
1148+
11471149
<string name="quest_fireHydrant_diameter_title">What diameter is specified on the sign for this fire hydrant?</string>
11481150
<string name="quest_fireHydrant_diameter_unusualInput_confirmation_description2">This diameter looks implausible, it is usually between %1$d and %2$d.</string>
11491151

Lines changed: 13 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)