Machine readable rules for assigning icons according to tags?

I am developing thematic map. I use OSM as background map and OverPassTurbo to collect data that is then displayed as another layer on top of map as clickable items. I use Leaflet to show map. It all works fine.

Now I need to set icon for each object according to what it is, based on tags.

There is list of symbols as used on OSM rendering Those are the very same symbols I want to use as icons on my map.

Now, question is, is this list available in machine readable form? That would help me avoid copying definitions manually and having to update manually if something in definitions changes.

It would be even better if there is tool or service that would provide symbol name for specific object, especially if it is PHP or JavaScript based.

This is a bit of a tricky question, very roughly there are two common ways to do this:

  • based on a map styling mechanism

  • based on presets (with an appropriate matching algorithm)

The later tend tend to handle a lot more different objects because by their very nature they are used to individually map the objects in question and the former tends to be more category orientated.

In any case the page you found in the wiki is very very old (trying to be nice here) and definitely totally out of date. I use icons from which is an extension of that specific icon set in my presets which is probably the closest you will get to a machine readable definition of when to use the specific set of icons. But likely that is way overkill for your application.

From an ease of use in an JS application potentially the iD presets might be a better starting point as they use a JSON format for preset definition, but different icons.

You are right. I years I stumbled number of times on issue of organizing objects in more usable manner. This is just another example.

Thanks for the tips, I believe this leads me in the right direction, athrough it seems it requires quite a lot of work.