-
-
Notifications
You must be signed in to change notification settings - Fork 412
street furniture overlay #5373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
westnordost
merged 48 commits into
streetcomplete:master
from
matkoniecz:street_furniture
Feb 14, 2024
Merged
street furniture overlay #5373
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
8854bc5
street furniture overlay
matkoniecz cc83416
add hiunting stand
matkoniecz c8a486f
remove unused method
westnordost d3f3861
fix typo
matkoniecz 28a65a4
refactoring popular shops
matkoniecz bdca6cc
add amenity=bicycle_wash
matkoniecz 721e642
lifecycle prefix handler
matkoniecz 9e01dd1
try to reconstruct from lifecycle prefix
matkoniecz e90acba
simplify syntax
matkoniecz d3149f6
fix syntax error
matkoniecz c217e9d
add values from systematic taginfo review
matkoniecz cbfa267
better marker
matkoniecz c7a289c
group strings
matkoniecz aa0014f
support table_soccer tables
matkoniecz 53ae3ae
move unit test
westnordost 5de8a9f
use bench as overlay icon
westnordost 9129808
remove unnecessary suspend function
westnordost 181b578
Merge branch 'master' into street_furniture
westnordost 228bfd1
use "plus" icon for adding a street furniture poi
westnordost 79a3c7c
Features without a dedicated icon shall fall back to a generic marker…
westnordost ef3ff23
remove duplicate
westnordost 99b3c6a
add comments about the number of usages
westnordost 1f6e108
Merge remote-tracking branch 'upstream/master' into street_furniture
matkoniecz c17951a
fix broken prefix
matkoniecz 165a784
fix map display
matkoniecz 49e4c47
better handle objects not in presets
matkoniecz 8d636db
Merge remote-tracking branch 'upstream/master' into street_furniture
matkoniecz ca95588
man mades together
matkoniecz 4243ef2
show also natural=spring as other water source features are shown
matkoniecz 1e94454
Merge branch 'master' into street_furniture
matkoniecz dc238ff
fix merge
westnordost 15e2dd9
refactor handling of disused
westnordost 917d05c
sort features alphabetically (consistent with Shop.kt)
westnordost 2db50bf
for added features, the geometry type is always POINT
westnordost 6eb6ddf
Extend "shops" category to "places" category (fixes #5152)
westnordost ab4aed4
add many street furniture POIs
westnordost 29db166
rename Shop to Place
westnordost 3d547fe
review list of quick-select features
westnordost 06fcff1
reorder overlays so that street furniture is next to shops
westnordost 566d0a5
add delete node answer
westnordost 732cc93
include a few more things
westnordost 46dbb6f
do not allow editing features
westnordost 46909c0
add playground equipment
westnordost 9ec2e55
use dot icon
westnordost 693307e
rename StreetFurniture to "Thing"
westnordost 6521238
rename StreetFurniture to "Thing"
westnordost 13bf845
simplify edit creation (because modification of feature is disabled)
westnordost f9c956a
remove unused imports
westnordost File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/src/main/java/de/westnordost/streetcomplete/osm/StreetFurniture.kt
This file contains hidden or 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,42 @@ | ||
| package de.westnordost.streetcomplete.osm | ||
|
|
||
| import de.westnordost.streetcomplete.data.elementfilter.toElementFilterExpression | ||
|
|
||
| fun isStreetFurnitureFragment(prefix: String? = null): String { | ||
| val amenities = listOf( | ||
| "bicycle_parking", "bicycle_rental", "bench", "longer", "bbq", "grit_bin", "toilets", | ||
|
westnordost marked this conversation as resolved.
Outdated
matkoniecz marked this conversation as resolved.
Outdated
|
||
| "public_bookcase", "give_box", "clock", "bicycle_repair_station", "charging_station", | ||
| "parcel_locker", "telephone", "drinking_water", "vending_machine", | ||
| "atm", "waste_basket", "trolley_bay", "hunting_stand", | ||
| // "post_box", "letter_box", - blocked by https://github.com/streetcomplete/StreetComplete/issues/4916 | ||
| // waiting for response in https://github.com/ideditor/schema-builder/issues/94 | ||
| // man_made = street_cabinet and street_cabinet = postal_service | ||
| // is also disabled to avoid bad data being added | ||
| ) | ||
| val p = if (prefix != null) "$prefix:" else "" | ||
| return ("""( | ||
| ${p}amenity ~ ${amenities.joinToString("|")} | ||
| or (${p}amenity = recycling and recycling_type = container) | ||
| or ${p}leisure ~ picnic_table|firepit | ||
| or ${p}man_made ~ water_tap|obelisk|cross|monitoring_station|flagpole|carpet_hanger|planter | ||
| or ${p}tourism ~ viewpoint|artwork | ||
| or (${p}tourism ~ information and information ~ guidepost|board|map|terminal) | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
| or ${p}historic ~ memorial|monument|wayside_shrine|wayside_cross|boundary_stone | ||
| or ${p}highway ~ milestone|street_lamp|emergency_access_point | ||
| or ${p}emergency ~ fire_hydrant|life_ring|phone|defibrillator|siren|lifeguard|assembly_point|access_point | ||
| or ${p}advertising | ||
| or ${p}leisure = pitch and sport ~ table_tennis|sport=chess | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
| or ${p}natural ~ tree | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
| or ${p}man_made = street_cabinet and street_cabinet != postal_service | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
| )""") | ||
| } | ||
| val IS_DISUSED_STREET_FURNITURE_EXPRESSION = """ | ||
| nodes, ways, relations with | ||
| ${isStreetFurnitureFragment("disused")} | ||
| """.toElementFilterExpression() | ||
|
|
||
| val IS_STREET_FURNITURE_INCLUDING_DISUSED_EXPRESSION = """ | ||
| nodes, ways, relations with | ||
| ${isStreetFurnitureFragment()} | ||
| or ${isStreetFurnitureFragment("disused")} | ||
| """.toElementFilterExpression() | ||
This file contains hidden or 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
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/de/westnordost/streetcomplete/overlays/street_furniture/DummyFeature.kt
This file contains hidden or 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,31 @@ | ||
| package de.westnordost.streetcomplete.overlays.street_furniture | ||
|
|
||
| import de.westnordost.osmfeatures.Feature | ||
| import de.westnordost.osmfeatures.GeometryType | ||
| import java.util.Locale | ||
|
|
||
| data class DummyFeature( | ||
| private val id: String, | ||
| private val name: String, | ||
| private val icon: String, | ||
| private val addTags: Map<String, String> | ||
| ) : Feature { | ||
| override fun getId() = id | ||
| override fun getTags() = addTags | ||
| override fun getGeometry() = listOf(GeometryType.POINT, GeometryType.AREA) | ||
| override fun getName() = name | ||
| override fun getIcon() = icon | ||
| override fun getImageURL() = null | ||
| override fun getNames() = listOf(name) | ||
| override fun getTerms() = emptyList<String>() | ||
| override fun getIncludeCountryCodes() = emptyList<String>() | ||
| override fun getExcludeCountryCodes() = emptyList<String>() | ||
| override fun isSearchable() = false | ||
| override fun getMatchScore() = 1.0 | ||
| override fun getAddTags() = addTags | ||
| override fun getRemoveTags() = emptyMap<String, String>() | ||
| override fun getCanonicalNames() = emptyList<String>() | ||
| override fun getCanonicalTerms() = emptyList<String>() | ||
| override fun isSuggestion() = false | ||
| override fun getLocale(): Locale = Locale.getDefault() | ||
| } |
66 changes: 66 additions & 0 deletions
66
...in/java/de/westnordost/streetcomplete/overlays/street_furniture/StreetFurnitureOverlay.kt
This file contains hidden or 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,66 @@ | ||
| package de.westnordost.streetcomplete.overlays.street_furniture | ||
|
|
||
| import androidx.core.content.ContentProviderCompat.requireContext | ||
| import de.westnordost.osmfeatures.Feature | ||
| 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.Node | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.filter | ||
| import de.westnordost.streetcomplete.data.user.achievements.EditTypeAchievement | ||
| import de.westnordost.streetcomplete.osm.IS_DISUSED_STREET_FURNITURE_EXPRESSION | ||
| import de.westnordost.streetcomplete.osm.IS_STREET_FURNITURE_INCLUDING_DISUSED_EXPRESSION | ||
| import de.westnordost.streetcomplete.overlays.Color | ||
| import de.westnordost.streetcomplete.overlays.Overlay | ||
| import de.westnordost.streetcomplete.overlays.PointStyle | ||
| import de.westnordost.streetcomplete.overlays.PolygonStyle | ||
| import de.westnordost.streetcomplete.util.getNameLabel | ||
|
|
||
| class StreetFurnitureOverlay(private val getFeature: (tags: Map<String, String>) -> Feature?) : Overlay { | ||
|
|
||
| override val title = R.string.overlay_street_furniture | ||
| override val icon = R.drawable.ic_quest_apple // TODO | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
| override val changesetComment = "Survey street furniture and similar objects" | ||
| override val wikiLink: String = "Street furniture" | ||
| override val achievements = listOf(EditTypeAchievement.CITIZEN) | ||
| override val isCreateNodeEnabled = true | ||
|
|
||
| override val sceneUpdates = listOf( | ||
| "layers.buildings.draw.buildings-style.extrude" to "false", | ||
| "layers.buildings.draw.buildings-outline-style.extrude" to "false" | ||
| ) | ||
|
|
||
| override fun getStyledElements(mapData: MapDataWithGeometry) = | ||
| mapData | ||
| .filter(IS_STREET_FURNITURE_INCLUDING_DISUSED_EXPRESSION) | ||
| .mapNotNull { element -> | ||
| val feature = getFeature(element.tags) | ||
| val iconIdentifier = feature?.icon | ||
| if ( iconIdentifier == null) { | ||
| if (IS_DISUSED_STREET_FURNITURE_EXPRESSION.matches(element)) { | ||
| val icon = "ic_preset_maki_marker_stroked" | ||
| val label = null | ||
| val style = if (element is Node) { | ||
| PointStyle(icon, label) | ||
| } else { | ||
| PolygonStyle(Color.INVISIBLE, icon, label) | ||
| } | ||
| element to style | ||
| } else { | ||
| null | ||
| } | ||
| } else { | ||
| val icon = "ic_preset_" + iconIdentifier.replace('-', '_') | ||
| val label = getNameLabel(element.tags) | ||
|
|
||
| val style = if (element is Node) { | ||
| PointStyle(icon, label) | ||
| } else { | ||
| PolygonStyle(Color.INVISIBLE, icon, label) | ||
| } | ||
| element to style | ||
| } | ||
| } | ||
|
|
||
| override fun createForm(element: Element?) = StreetFurnitureOverlayForm() | ||
| } | ||
159 changes: 159 additions & 0 deletions
159
...ava/de/westnordost/streetcomplete/overlays/street_furniture/StreetFurnitureOverlayForm.kt
This file contains hidden or 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,159 @@ | ||
| package de.westnordost.streetcomplete.overlays.street_furniture | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.View | ||
| import androidx.core.content.ContentProviderCompat | ||
| import de.westnordost.osmfeatures.Feature | ||
| import de.westnordost.streetcomplete.R | ||
| import de.westnordost.streetcomplete.data.osm.edits.ElementEditAction | ||
| import de.westnordost.streetcomplete.data.osm.edits.create.CreateNodeAction | ||
| import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder | ||
| import de.westnordost.streetcomplete.data.osm.edits.update_tags.UpdateElementTagsAction | ||
| import de.westnordost.streetcomplete.data.osm.geometry.ElementGeometry | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.Element | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.LatLon | ||
| import de.westnordost.streetcomplete.data.osm.mapdata.Node | ||
| import de.westnordost.streetcomplete.databinding.FragmentOverlayStreetFurnitureBinding | ||
| import de.westnordost.streetcomplete.osm.IS_DISUSED_STREET_FURNITURE_EXPRESSION | ||
| import de.westnordost.streetcomplete.osm.IS_STREET_FURNITURE_INCLUDING_DISUSED_EXPRESSION | ||
| import de.westnordost.streetcomplete.overlays.AbstractOverlayForm | ||
| import de.westnordost.streetcomplete.util.getLocalesForFeatureDictionary | ||
| import de.westnordost.streetcomplete.util.getLocationLabel | ||
| import de.westnordost.streetcomplete.util.ktx.geometryType | ||
| import de.westnordost.streetcomplete.util.ktx.viewLifecycleScope | ||
| import de.westnordost.streetcomplete.view.controller.FeatureViewController | ||
| import de.westnordost.streetcomplete.view.dialogs.SearchFeaturesDialog | ||
| import kotlinx.coroutines.launch | ||
|
|
||
| class StreetFurnitureOverlayForm : AbstractOverlayForm() { | ||
|
|
||
| override val contentLayoutResId = R.layout.fragment_overlay_street_furniture | ||
| private val binding by contentViewBinding(FragmentOverlayStreetFurnitureBinding::bind) | ||
|
|
||
| private var originalFeature: Feature? = null | ||
|
|
||
| private lateinit var featureCtrl: FeatureViewController | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| val element = element | ||
| originalFeature = element?.let { | ||
| if (IS_DISUSED_STREET_FURNITURE_EXPRESSION.matches(element)) { | ||
| DummyFeature( | ||
| "street_furniture/unknown_disused", | ||
| requireContext().getString(R.string.unknown_disused_street_furniture), | ||
| "ic_preset_maki_marker_stroked", | ||
| element.tags | ||
| ) | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
| } else { | ||
| featureDictionary | ||
| .byTags(element.tags) | ||
| .forLocale(*getLocalesForFeatureDictionary(resources.configuration)) | ||
| .forGeometry(element.geometryType) | ||
| .inCountry(countryOrSubdivisionCode) | ||
| .find() | ||
| .firstOrNull() | ||
| // if not found anything in the iD presets, then something weird happened | ||
| ?: DummyFeature( | ||
| "street_furniture/unknown", | ||
| requireContext().getString(R.string.unknown_street_furniture), | ||
| "ic_preset_maki_marker_stroked", | ||
| element.tags | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
|
|
||
| // title hint label with name is a duplication, it is displayed in the UI already | ||
| setTitleHintLabel(element?.tags?.let { getLocationLabel(it, resources) }) | ||
| setMarkerIcon(R.drawable.ic_quest_apple) | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
|
|
||
| featureCtrl = FeatureViewController(featureDictionary, binding.featureTextView, binding.featureIconView) | ||
| featureCtrl.countryOrSubdivisionCode = countryOrSubdivisionCode | ||
| featureCtrl.feature = originalFeature | ||
|
|
||
| binding.featureView.setOnClickListener { | ||
| SearchFeaturesDialog( | ||
| requireContext(), | ||
| featureDictionary, | ||
| element?.geometryType, | ||
| countryOrSubdivisionCode, | ||
| featureCtrl.feature?.name, | ||
| ::filterOnlyStreetFurniture, | ||
| ::onSelectedFeature, | ||
| listOf( | ||
| // ordered by popularity, skipping trees as there are multiple variants of them | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
| "highway/street_lamp", | ||
| "amenity/bench", | ||
| "emergency/fire_hydrant", | ||
| "amenity/bicycle_parking", | ||
| "amenity/shelter", | ||
| "amenity/toilets", | ||
| // "amenity/post_box", | ||
| // blocked by https://github.com/streetcomplete/StreetComplete/issues/4916 | ||
| // waiting for response in https://github.com/ideditor/schema-builder/issues/94 | ||
| "amenity/drinking_water", | ||
| "leisure/picnic_table", | ||
|
|
||
| // popular, a bit less than some competing entries | ||
| // but interesting and worth promoting | ||
| "emergency/defibrillator", | ||
| ) | ||
| ).show() | ||
| } | ||
| } | ||
|
|
||
| override fun onSaveInstanceState(outState: Bundle) { | ||
| super.onSaveInstanceState(outState) | ||
| } | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
|
|
||
| private fun filterOnlyStreetFurniture(feature: Feature): Boolean { | ||
| val fakeElement = Node(-1L, LatLon(0.0, 0.0), feature.tags, 0) | ||
| return IS_STREET_FURNITURE_INCLUDING_DISUSED_EXPRESSION.matches(fakeElement) | ||
| } | ||
|
|
||
| private fun onSelectedFeature(feature: Feature) { | ||
| featureCtrl.feature = feature | ||
| checkIsFormComplete() | ||
| } | ||
|
|
||
| override fun hasChanges(): Boolean = | ||
| originalFeature != featureCtrl.feature | ||
|
|
||
| override fun isFormComplete(): Boolean = featureCtrl.feature != null | ||
|
|
||
| override fun onClickOk() { | ||
| viewLifecycleScope.launch { | ||
|
westnordost marked this conversation as resolved.
Outdated
|
||
| applyEdit(createEditAction( | ||
| element, geometry, | ||
| featureCtrl.feature!!, originalFeature, | ||
| )) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private suspend fun createEditAction( | ||
| element: Element?, | ||
| geometry: ElementGeometry, | ||
| newFeature: Feature, | ||
| previousFeature: Feature? | ||
| ): ElementEditAction { | ||
| val tagChanges = StringMapChangesBuilder(element?.tags ?: emptyMap()) | ||
|
|
||
| for ((key, value) in previousFeature?.removeTags.orEmpty()) { | ||
| tagChanges.remove(key) | ||
| } | ||
| for ((key, value) in newFeature.addTags) { | ||
| tagChanges[key] = value | ||
| } | ||
|
|
||
| return if (element != null) { | ||
| UpdateElementTagsAction(element, tagChanges.create()) | ||
| } else { | ||
| CreateNodeAction(geometry.center, tagChanges) | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
15 changes: 15 additions & 0 deletions
15
app/src/main/java/de/westnordost/streetcomplete/quests/shop_type/ShopUtils.kt
This file contains hidden or 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,15 @@ | ||
| package de.westnordost.streetcomplete.quests.shop_type | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
|
|
||
| fun topFeatureCodesOfPopularShoplikePOIs(): List<String> { | ||
| // ordered by usage number according to taginfo | ||
| return listOf( | ||
|
matkoniecz marked this conversation as resolved.
Outdated
|
||
| "amenity/restaurant", | ||
| "shop/convenience", | ||
| "amenity/cafe", | ||
| "shop/supermarket", | ||
| "amenity/fast_food", | ||
| "amenity/pharmacy", | ||
| "shop/clothes", | ||
| "shop/hairdresser" | ||
| ) | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.