OpenStreetMap

Opening Hours

Posted by mvexel on 17 July 2014 in English (English)

Mapping opening hours correctly can be a pain; the format for the opening_hours key can be hard to remember. I didn't use to do it much for that reason. Until I recently discovered that there's a JOSM plugin for that! It works really well, let me show you how I added hours of a local restaurant in seconds.

First, of course, make sure you have the plugin installed:

install

Then, select the thing you want to add opening hours for:

select

And select 'Edit Opening Hours' from the Data menu (or use the keyboard shortcut).

menu

If the plugin detects an existing opening_hours tag, it will offer to edit that, or you can create it. It will then offer a graphical interface for setting the hours:

interface

You can move and drag blocks as you would expect. The plugin will parse it in the expected format. A nice little extra is that it supports the 'open end' hours in the format 17:00+ - useful for places that don't have a set closing hour but instead say 'open till late' or something similar.

Perhaps old news to y'all, but it made me happy :)

A Word Of Caution

Several people have pointed out (link is to the German forum) that the plugin is limited in what it can do. It will not cover most complex cases, like exceptions for public holidays and month to month variations) and does not seem to properly cover some of the simpler cases.

I still feel that it is good for a lot of basic opening hours tagging, but please review the opening_hours specification.

There is also a validator tool that I don't quite understand how to use, perhaps someone can explain in the comments?

Comment from flohoff on 17 July 2014 at 18:47

The Editor gets a little strange when you have e.g. Restaurants which have Tu-Th 18:00 to 2:00 and Fr-Sa 18:00 to 5:00 Su/Mo Closed.

Results look strange IMHO whenever you cross the 24h/0h boundary.

Flo

Hide this comment

Comment from EdLoach on 18 July 2014 at 08:56

I found this plugin quite handy for adding opening_hours for some of the local fast food places. It was so easy I even added delivery_hours for them as well.

Hide this comment

Comment from mvexel on 25 July 2014 at 16:35

Flo - yes they do look strange, I agree. I think the convention is to map this as Tu-Th 18:00-02:00 and the plugin will create two separate intervals instead. It's not really invalid, it's just not optimal, in my opinion.

Hide this comment

Comment from MKnight on 30 July 2014 at 01:23

mvexel: my english is not the best; but

the validator-tool:

put your (wrong) range in it, and it shows in most cases the right. Additionally you can select (some) date to check.

P.s. The tool is additionally integrated in the josm-validator; the contributor (ypid) answers (technical) Questions at most of the time in one day ... via PM in OSM or in GitHub and sometimes in the OSM-Forum.

Hide this comment

Comment from ypid on 31 July 2014 at 11:01

Reading through the weekly news on the osm blog I noticed your blog post (nice one btw.). The OpeningHoursEditor plugin is a good tool if you encoutner simple opening hours and/or if you know it‘s limits as mentioned by MKnight (although I personally don‘t use it). If there is anything more complex I would encourage you to check out the evaluation_tool on which I spend quite some effort to make it powerful and error tolerant. You can check out the opening_hours value you used in this post on the evaluation tool if you like and try to edit the value and see the result. I can imagine that the tool is a bit overwhelming at first but I hope that it can be used intuitively after you know your way around with the thing. Also note that JOSM does use the same tool in the background for verification of the opening_hours value (meaning that the warnings you will see if the value is not correct are the same as given by the evaluation tool). Feel free to ask if you have more questions about it.

Hide this comment

Comment from ypid on 31 July 2014 at 11:04

Here is the correct link for the opening_hours value: Mo-Fr 07:00-18:00; Sa,Su 08:00-18:00.

Hide this comment

Comment from mvexel on 2 August 2014 at 20:21

Thanks ypid for adding information on the evaluation tool!

Hide this comment

Comment from SimonPoole on 4 August 2014 at 05:54

The basic problem is that the grammar is just to complex. While it is nice that you can specify nearly everything it is riddled with special cases that make a complete implementation a pain. Further the available grammar spec seems to have errors (missing definition of ) and doesn't cover things that seem to be in use, like using "," as delimiters between rule-squences. WHich btw doesn't seem to be documented.

And then there is stuff like if you are reasonably lenient about what you accept, for example allowing naked hour values without ":", a legal spec like "11" becomes ambiguous.

Hide this comment

Comment from SimonPoole on 4 August 2014 at 13:36

Markdown managed to eat a bit of my comment, that should have been: ..(missing definiton od TIME)

Hide this comment

Comment from ypid on 8 August 2014 at 14:06

@SimonPoole: I knew that the specification that you where probably referring to did (and still does) not yet cover everything which can be expressed as it was stated in the first sentence of the page: "This specification corresponds (not in every detail yet) to opening_hours.js"

I had this on my todo list for a while and finally did it yesterday.

While it is nice that you can specify nearly everything it is riddled with special cases that make a complete implementation a pain.

I get that but that‘s how reality is, right? (Better get used to it ;) ) If you want to cover all the tricky parts with such a syntax (and a software library which implements it) it is inevitable that it will get complected. If someone would reimplement a parser for this in a different language than I guess it could be done much quicker because there is already one implementation which covers it all. One ray of hope, you don’t have to use all the power if you don‘t need it. You will come pretty far with the basic stuff like Mo-Fr 12:00-18:00; Sa 12:00-17:00; We off

Further the available grammar spec seems to have errors (missing definition of ) and doesn't cover things that seem to be in use, like using "," as delimiters between rule-squences. WHich btw doesn't seem to be documented.

Netzwolf introduced them to the syntax but somehow forgot to add them to the specification. It is now covered.

And then there is stuff like if you are reasonably lenient about what you accept, for example allowing naked hour values without ":", a legal spec like "11" becomes ambiguous.

This was never part of the specification and never will be. It is just part of the error tolerance of opening_hours.js which I added to make fixing of values easier. Note that only something like: 11-18 can be interpreted. (You may refer to the opening_hours bot which can do that but is not in use (at least by me) for now.)

Hide this comment

Leave a comment

Parsed with Markdown

  • Headings

    # Heading
    ## Subheading

  • Unordered list

    * First item
    * Second item

  • Ordered list

    1. First item
    2. Second item

  • Link

    [Text](URL)
  • Image

    ![Alt text](URL)

Login to leave a comment