Skip to content

Commit

Permalink
Merge pull request #5533 from matkoniecz/confusing
Browse files Browse the repository at this point in the history
covered by building answer in AddIsAmenityIndoor
  • Loading branch information
westnordost authored Mar 13, 2024
2 parents a4aa674 + 3d06c2c commit 4d593d2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import de.westnordost.streetcomplete.data.osm.geometry.ElementPolygonsGeometry
import de.westnordost.streetcomplete.data.osm.mapdata.Element
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataWithGeometry
import de.westnordost.streetcomplete.data.osm.osmquests.OsmElementQuestType
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.*
import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement.CITIZEN
import de.westnordost.streetcomplete.osm.Tags
import de.westnordost.streetcomplete.quests.YesNoQuestForm
import de.westnordost.streetcomplete.util.ktx.containsAll
import de.westnordost.streetcomplete.util.ktx.toYesNo
import de.westnordost.streetcomplete.util.math.LatLonRaster
import de.westnordost.streetcomplete.util.math.contains
import de.westnordost.streetcomplete.util.math.isCompletelyInside
import de.westnordost.streetcomplete.util.math.isInMultipolygon

class AddIsAmenityIndoor(private val getFeature: (Element) -> Feature?) :
OsmElementQuestType<Boolean> {
OsmElementQuestType<IsAmenityIndoorAnswer> {

private val nodesFilter by lazy { """
nodes with
Expand All @@ -30,6 +28,7 @@ class AddIsAmenityIndoor(private val getFeature: (Element) -> Feature?) :
)
and access !~ private|no
and !indoor and !location and !level and !level:ref
and covered != yes
""".toElementFilterExpression() }

/* small POIs that tend to be always attached to walls (and where the location is very useful
Expand Down Expand Up @@ -102,9 +101,13 @@ class AddIsAmenityIndoor(private val getFeature: (Element) -> Feature?) :
return getMapData().filter { it.tags.containsAll(feature.tags) }.asSequence()
}

override fun createForm() = YesNoQuestForm()
override fun createForm() = IsAmenityIndoorForm()

override fun applyAnswerTo(answer: Boolean, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
tags["indoor"] = answer.toYesNo()
override fun applyAnswerTo(answer: IsAmenityIndoorAnswer, tags: Tags, geometry: ElementGeometry, timestampEdited: Long) {
when (answer) {
IsAmenityIndoorAnswer.INDOOR -> tags["indoor"] = "yes"
IsAmenityIndoorAnswer.OUTDOOR -> tags["indoor"] = "no"
IsAmenityIndoorAnswer.COVERED -> tags["covered"] = "yes"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package de.westnordost.streetcomplete.quests.amenity_indoor

enum class IsAmenityIndoorAnswer { INDOOR, OUTDOOR, COVERED }
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.westnordost.streetcomplete.quests.amenity_indoor

import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.quests.AbstractOsmQuestForm
import de.westnordost.streetcomplete.quests.AnswerItem

class IsAmenityIndoorForm : AbstractOsmQuestForm<IsAmenityIndoorAnswer>() {
override val buttonPanelAnswers = listOf(
AnswerItem(R.string.quest_generic_hasFeature_no) { applyAnswer(IsAmenityIndoorAnswer.OUTDOOR) },
AnswerItem(R.string.quest_generic_hasFeature_yes) { applyAnswer(IsAmenityIndoorAnswer.INDOOR) }
)

override val otherAnswers = listOf(
AnswerItem(R.string.quest_isAmenityIndoor_outside_covered) { applyAnswer(IsAmenityIndoorAnswer.COVERED) }
)
}
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 @@ -1747,5 +1747,6 @@ Alternatively, you can leave a note (with a photo)."</string>
<string name="label_log_older_than">To</string>
<string name="label_log_message_contains">Message contains</string>
<string name="title_logs_filters">Filter messages</string>
<string name="quest_isAmenityIndoor_outside_covered">Not inside, but covered</string>

</resources>

0 comments on commit 4d593d2

Please sign in to comment.