[JT] Jochen Topf's Blog
Mon 2013-02-25 19:31

Using Taginfo to Create Map Feature Tables

The Map Features wiki page is one of the oldest pages on the OSM wiki and it has been getting larger and larger over time. And more and more wiki templates are used to create it and its language variants. Very similar tables can also be found on many “Key:*” pages on the wiki to list the tags used with this key.

The Problem

All these lists are hard to maintain. You have to dig through multiple levels of wiki templates to understand what is going on. It is practically impossible to keep this information consistent throughout the different places in the wiki.

At the recent Karlsruhe Hack Weekend Andreas (Andi) Hubel and I had a good discussion about this issue and possible ways to improve the situation.

Andi did some statistics and found out that there are about 3800 templates and about 15000 cases where one template includes another template! Much of that is due to the Map Features pages. This is not only hard do understand for a human, it is hard on the MediaWiki software, too, because changes in one page affect other pages and MediaWiki has to keep track of all this, re-render them when needed etc.

Using Taginfo

An obvious solution would be to auto-generate the tables on the Map Features pages using taginfo. Taginfo gets most of the necessary information already from the “Key:*” and “Tag:*” wiki pages. (The only information missing is the little map snippets that show how features are rendered. This picture is currently not referenced from the infoboxes on the key and tag pages where taginfo gets its information.) If taginfo generates those tables, we’d make sure the information is always consistent. And we can get rid of lots of unwieldy templates. What we do need in this case are wiki pages for all tags with info boxes on them so that taginfo can find all this information.

So I gave it a try and added a new API call to taginfo that allows easy access to this information in JSON format and I created a test web page that takes this information and displays it in a form similar to the current Map Features pages. You can give it a try at mf.jochentopf.com (Update: not available any more, have a look at https://wiki.openstreetmap.org/wiki/Taginfo/Taglists instead).

You can set the language you want the descriptions in by entering the usual language code. If the description is not available in that language it falls back to the English description.

To choose which tags to show there are several possible ways. If you just enter a key such as highway or boundary you will get all tags with that key that are documented in the wiki. Or you can enter a comma-separated list of tags in the form KEY=VALUE. If you just give a VALUE in the list it uses the KEY from the tag before. So boundary=administrative,national_park,landuse=residential will show you both boundary tags and the landuse=residential tag.

All of this is just a quick proof-of-concepts. There are multiple problems still to be resolved. Feel free to play around and give me feedback.

What now?

To completely replace the existing Map Features lists we have to decide where to place those autogenerated lists. We could either include them in the wiki somehow or they could live on a separate web page (for instance the taginfo web page).

If we integrate them in the wiki users will see the lists they are already used to and they can edit the text around those lists which would be a big plus. But it needs more work to make this possible. We’d probably need some kind of MediaWiki plugin that creates those tables from the JSON delivered by taginfo. We could include an iframe in the wiki page that gets its content from an external site. We already do this for those little taginfo info boxes on some pages in the wiki. Unfortunately we can’t make this seemless because the main page doesn’t know how big the iframe should be, so this isn’t that great a solution.

Maybe you have an idea how to do this?

Tags: openstreetmap · osmwiki · taginfo