simonpoole / OpeningHoursFragment

Android UI element for displaying and editing an opening hours value
MIT License
9 stars 2 forks source link

Opening hours templates depending on location/POI type #33

Open ltog opened 5 years ago

ltog commented 5 years ago

When creating opening hours we can choose from several templates, e.g. "Weekdays with lunch break". These templates use hardcoded values for opening and closing times (defined in https://github.com/simonpoole/OpeningHoursFragment/blob/015d0b49140a24eeb13cd839edca108e2affad32/lib/src/main/java/ch/poole/openinghoursfragment/TemplateDatabaseHelper.java AFAICS).

I'd like to propose a system, where the exact hours are depending on the user's current position (e.g. country) and the type of POI (e.g. bank, restaurant), which the user wants to edit. Rationale: Different types of POIs (e.g. bank and restaurant) likely will have differing opening hours (banks typically are closed at noon and in the evening, while restaurants are not). The exact hours will also depend on local laws and customs, therefore the position of the user should also be considered.

What opening hours should be contained in the templates? We can use existing OSM data to do some data mining and gather the most frequently used combinations. I can assist if wanted...

simonpoole commented 5 years ago

Just avoid a misunderstanding you can store any number of custom/private templates in the current implementation, what you can't do is associate them with a specific preset/top level key.

ltog commented 5 years ago

@simonpoole: I've never done it, but I guess it's not what I (and probably other users) want/need: These "profiles" I talk about should be transparently available to every user, not just me. If they don't pay close attention to the exact hours, they wouldn't even notice this feature.

I liked those few instances where the hours in the template matched a given object and my proposal would increase the chances of this happening.

simonpoole commented 5 years ago

The current way of working would be to walk up to say a bank, load an exiting template or build a spec from scratch and then, deciding it is typical for a bank, save it as a template giving it a descriptive name. With other words you build the set of best suiting presets as you go along.

Naturally semi-automatically preselecting specific templates is clearly a possibility. As said we already provide this for opening_hours vs. service_times vs. collection_times. The problem with doing this based on "object type" is that it is not so well defined as one might assume and in the end boils down to matching against a preset item or at least against a list of multiple tags for a specific object.

In any case I'll give it some thought (importing and exporting templates is something that got dropped from the initial release but is still something I would want to do that belongs in this context too).

ltog commented 5 years ago

@simonpoole : For the sake of completeness, here my idea of the workflow:

User walks around to go for a little mapping tour -> user finds a certain type of POI, lets say a bank -> user tags the object as amenity=bank -> user wants to add opening hours and opens the opening hours dialog -> user chooses a template, e.g. "Weekdays with lunch breaks" -> the user sees a pre-filled opening hours entry.

Important: This entry corresponds to the typical/most often used opening hour of a bank in this region that is open on weekdays and has lunch breaks.

To be able to make such a suggestion, one needs to do a statistical analysis beforehand:

  1. Define relevant borders, e.g. country borders
  2. Collect POIs (e.g. amenity=* with defined opening hours, services times, etc.)
  3. Group these POIs by spatial entity (e.g. country)
  4. Group these POIs further by type (e.g. one group for each value of amenity=*, maybe subgroups for different additional tags)
  5. Group all the (sub)groups further by the kind of template they correspond with, e.g. "Weekdays with lunch breaks", "Weekdays without lunchbreaks", etc.
  6. For each of these POIs with the same properties find the most often used values for the opening hours.
simonpoole commented 5 years ago

Basic support for the fields in the template database added in https://github.com/simonpoole/OpeningHoursFragment/commit/4482ab2c153a5d707fc235d6d26711a5bd61ee24