streetcomplete / StreetComplete

Easy to use OpenStreetMap editor for Android
https://streetcomplete.app
GNU General Public License v3.0
3.92k stars 358 forks source link

Allow for Country of current Quest to be visible and checked against in elementFilter #4528

Closed mnalis closed 2 years ago

mnalis commented 2 years ago

Use case

It has been suggested in smoking quest discussion that it might be useful to allow to check inside elementFilter in which country is the quest being asked. It would allow for more flexibility then defaultDisabledMessage = R.string.default_disabled_msg_go_inside_regional_warning; e.g. some extra conditions for quest to show (e.g. outdoor_seating != no) might be imposed only in some counties (e.g. UK) but only if some other matches are valid (e.g. amenity !~ nightclub|stripclub).

Such country-matching inside elementFilter might conceivably be used in other quests too where default_disabled_msg_go_inside_regional_warning is much too rigid.

Proposed Solution

That would require adding extra feature or splitting into separate quests, both are problematic.

It might be accomplished by SC automatically creating virtual tag like __QUEST_IS_IN_COUNTRY (which has value like UK or DE etc.), and then normal elementFilter operators might be used on it, e.g.:

elementFilter = """
  amenity ~ nightclub|stripclub 
  or amenity ~ restaurant|pub|bar and  (outdoor_seating != no or __QUEST_IS_IN_COUNTRY !~ UK|SE)
  and (!smoking or smoking older today -8 years) 
 [...]

Although, it might lead to quite complex elementFilter values though (example above is just a small grossly oversimplified chunk of smoking quest filter, to illustrate the possible usage if something like that were to be implemented)

(such virtual tags exist in other tools, e.g. ::user or ::id or ::type etc. in overpass-turbo which can be used in places where regular tags like name or highway are normally being used.)

mnalis commented 2 years ago

@Helium314 submitted this proof-of-concept on how to access the country of the current quest; but it would need to be made generic and implemented in core StreetComplete elementFilter parser to be actually readable/usable in quests generically.

westnordost commented 2 years ago

Yes, it can be done already, I see no reason to facilitate this with such hackery ("virtual tags"). Also, then every element filter would need a reverse country geocoder to function.

mnalis commented 6 months ago