Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osm-carto for TagInfo #961

Closed
sabas opened this issue Sep 19, 2014 · 37 comments
Closed

osm-carto for TagInfo #961

sabas opened this issue Sep 19, 2014 · 37 comments

Comments

@sabas
Copy link

sabas commented Sep 19, 2014

The new feature of Taginfo allows to give information about usage for a selected tag in a project
openstreetmap-carto is a natural fit
http://wiki.openstreetmap.org/wiki/Taginfo/Projects

I did a list some time ago, perhaps it's useful https://github.com/sabas/doesitrender/blob/gh-pages/taglist.md

@matthijsmelissen
Copy link
Collaborator

Hmm, interesting idea, but it would mean extra maintenance effort.

I don't think we can automatically generate it. Opinions?

@matkoniecz
Copy link
Contributor

It should be possible. AFAIK finding used tags in automatic way was already done to generate #204 (and it is using a simple regexp).

Generating optional fields would be harder, but even this may be doable.

@dieterdreist
Copy link

2014-09-19 17:48 GMT+02:00 math1985 [email protected]:

Hmm, interesting idea, but it would mean extra maintenance effort.

I don't think we can automatically generate it. Opinions?

maybe we can filter this from the "select" queries? Or from the filter
rules? Don't think it has to be detailed (i.e. not required to have the
zoomlevel shown). Generally this would be nice to have on one hand, and
encouraging tagging for the renderer on the other.

@pnorman
Copy link
Collaborator

pnorman commented Sep 19, 2014

maybe we can filter this from the "select" queries? Or from the filter rules?

Doubtful. We transform tags in the SQL, and thanks to the legacy SQL, we'll do stuff like transform aeroway=runway into rows with a highway column with a value of runway. The entire landcover layer gets put into a feature column. We regularly turn tags into INT- values, some of which aren't used by the corresponding MSS. See #939 as an example.

https://github.com/sabas/doesitrender checks for a pre-defined list of keys and finds values. And I bet it gets some of our usage wrong.

#204 had a fairly high error rate initially, which was solved by removing false positives from the list manually.

If someone wants to write code to produce a list, I'd welcome it, although I'm still not sure that within the repo is the best place to track it. I just don't think it's possible without interpreting the SQL and MSS in full.

@pnorman pnorman closed this as completed Sep 19, 2014
@HolgerJeromin
Copy link
Contributor

Is the code from
https://github.com/gravitystorm/mapnik-legendary
usable for this issue @gravitystorm ?

@gravitystorm
Copy link
Owner

I would say that @pnorman is correct that this is unlikely to be possible automatically given the reworking of tags in the SQL.

It is still a goal of mine to have a legend file for this repo, as I now have for other projects that I work on. The legend files are hand-curated but contain the 'output' of the tag-mangling, so won't be suitable for TagInfo either.

So we'll end up with two hand-maintained data files for the repo, but for me the legend file is a much higher priority (especially given that the legend on osm.org no longer matches the colours used here).

@matkoniecz
Copy link
Contributor

@sabas @dieterdreist

I made a script that works pretty well. But what should be done with tags that are changing rendering of other tags? For example name=* should be listed as rendered - but what about tags that have some effects in really weird combinations? Should it be listed or manually filtered?

For reference:

[barrier=hedge; historic=any_tag_value]
barrier hedge historic any_tag_value _19_closed_way

[barrier=hedge] with the same closed way
barrier hedge capital yes _19_closed_way

[aeroway=any_tag_value; amenity=place_of_worship; area=yes] - note missing icon for PoW - it may be fixed but it is probably better to work on other things

aeroway any_tag_value amenity place_of_worship area yes _19_closed_way

@HolgerJeromin
Copy link
Contributor

Taginfo is not build to be super precise but to give an overview that a project does something with the tag.

@sfkeller
Copy link

@mkoniecz I see some of the problems you mean (at least the last one with the
hiding icon).
The point is, that these issues are probably those 20 percents.
I think, most agree that it's not worth manually filtering a list.
But anyway: In order to discuss how good your script works, it would
be nice to see either the result of your script - or both, the script
and the result.

@matkoniecz
Copy link
Contributor

So first stage - generating a reliable list from OSM data is finished.

On https://github.com/mkoniecz/CartoCSSHelper/blob/master/style_specific/default_osm_style.rb there is a list of OSM tags considered by style, tag may be in one of three categories:

  • primary: tag is rendered (highway=cycleway)
  • composite: tag is not rendered but it changes how other tags are rendered (access=private)
  • ignored: tag is not rendered (railway=INT-preserved-ssy) - these are bad guesses of heuristics looking for potential tags

Each tag is listed as 'Status.new('key', 'value', :category, example_of_composite_tags_if_relevant),'

It is possible that some of rendered tags are missing - in this case feedback would be really useful.

Note that it is not exactly what is rendered by style - list was modified to hide effects of some bugs - for example matkoniecz/CartoCSSHelper@d1fc159

Tags that are acting like area=yes (except area=yes) are not listed (see #961 (comment) for description of the problem).

In the near future I will be unable to work on the second stage - converting this list into format usable by Taginfo.

@nebulon42
Copy link
Contributor

@giggls proposed an alternative in #2614. To manually create the file and then make sure that each change updates it. Still there is the risk that the file gets outdated. Would this be worth a try?

@giggls
Copy link

giggls commented Apr 18, 2017

I don't think that keeping such a file in line with the current version of the style would be a problem, if pull requests would require changing this file as well. The main effort would certainly be the creation of the initial version.

@imagico
Copy link
Collaborator

imagico commented Apr 18, 2017

A few thoughts on the matter:

  • to have this would be good and IMO worth a bit of work in maintenance when making changes to the style.
  • it would be an obvious and fairly trivial byproduct of generating a map style legend so it certainly makes no sense to separately maintain a legend and a taginfo list. Since we currently have no legend this is not really practically relevant at the moment of course.
  • having a plain list of tags a taginfo json file is produced from via script is probably easier to maintain than writing a json file by hand.
  • it might make maintenance easier if we'd structure the list by layer - which would of course require removing duplicates in processing.

@giggls
Copy link

giggls commented Apr 18, 2017

I like the Idea of having a Text file which is ordered by layer and a script which will generate the Taginfo file. In this case it would even be possible to add tag combinations which are currently not supported in Taginfo project format.

@pnorman
Copy link
Collaborator

pnorman commented Apr 18, 2017

I'm iffy on if this is worth the maintenance burden. If we do do it, we should make sure that we can build a legend from it, and that we're not doing it as JSON, because that will lead to difficult to solve merge conflicts.

@kocio-pl
Copy link
Collaborator

While it would be nice to have osm-carto on Taginfo, this is beyond our manpower and nobody seems to be interested to even start, so I close it now. If there will be some automatic solution or somebody ready to take care of it, it can be reopened.

@ImreSamu
Copy link

My "poor man" suggestions: just add the osm keys:

not perfect - Proof Of Concept :

$ cat project.mml | grep -oP "tags[^']*'.+?'"  | cut -d"'" -f2 | cut -d"=" -f1 | sed 's/"//g' | sort -u
addr:unit
advertising
capital
denomination
ele
emergency
entrance
ford
generator:source
height
highspeed
iata
icao
indoor
intermittent
leaf_type
memorial
operator
population
power_source
public_transport
recycling_type
seasonal
tower:construction
tower:type
usage
wetland
$ cat openstreetmap-carto.style |  grep '^[[:blank:]]*[^[:blank:]#;]' | tr -s ' ' | cut -d' ' -f2 | awk '!/(z_order|way_area)/' | sort -u
access
addr:housename
addr:housenumber
addr:interpolation
admin_level
aerialway
aeroway
amenity
barrier
bicycle
boundary
bridge
building
construction
covered
foot
highway
historic
horse
junction
landuse
layer
leisure
lock
man_made
military
name
natural
oneway
place
power
railway
ref
religion
route
service
shop
surface
tourism
tracktype
tunnel
water
waterway

for detecting the object_types ( node,way,area,...) need some extra magic.

@kocio-pl
Copy link
Collaborator

OK, more automatic tools would be needed. What would be the goal however, just the information in Taginfo that osm-carto uses this tag or what?

@HolgerJeromin
Copy link
Contributor

@ImreSamu
highway is missing.
man_made, landuse, leisure is quite useless imo.
Examples that this is not easy to pull out of the sources. 8-/

@ImreSamu
Copy link

ImreSamu commented Mar 27, 2018

Sorry for not being clear enough

My idea:

  • openstreetmap-carto.style - parsed for the database column ( and the highway is here ! )
  • project.mml parsed for HSTORE osm keys ( always start with tags ) some example:
    • tags->'advertising'
    • tags->'memorial'
    • tags @> 'ford=>stepping_stones'
    • tags @> '"generator:source"=>wind'
    • tags?'ele'
  • merge the two result + format

My Minimal result :

  • openstreetmap-carto - taginfo_project.json
  • example screenshot ( on my test taginfo ) what you can expect:
    screenshot from 2018-03-27 19-17-56

Extra: We need a strict SQL guideline for a good parsing.

imho:

  • this is useful for the average OSM mappers, not for the project members.
  • the minimal version is better than the nothing
  • later we can improve: Iterative and incremental development

@HolgerJeromin :

highway is missing.

Sorry for the confusion...
this on the second part ... ( see after $ cat openstreetmap-carto.style ... )

man_made, landuse, leisure is quite useless imo.

imho: there are another minimal project descriptions here

and according to the "taginfo"
"This table shows all projects known to taginfo that use OSM tags in some way." - and IMHO it is useful for the new mappers, that this key is used by the "openstreetmap-carto" project.

@kocio-pl
Copy link
Collaborator

I agree that you can start with this and fine tune it later on. What would you need from this project to make it happen in Taginfo? I guess you can make it on your own, because the source is publicly available, but if there is something you need, just tell and we can think (and I will reopen this ticket). We could host the script, but maybe it's more related to Taginfo?

@ImreSamu
Copy link

@kocio-pl

my simple code is here

#!/bin/bash
set -o errexit

NOW=$(date +%Y%m%dT%H%m%SZ)
tempfile=$(mktemp /tmp/_taginfo_.XXXXXXXXX)

cat project.mml               | grep -oP "tags[^']*'.+?'"  | cut -d"'" -f2 | cut -d"=" -f1 | sed 's/"//g'                     >  $tempfile
cat openstreetmap-carto.style | grep '^[[:blank:]]*[^[:blank:]#;]' | tr -s ' ' | cut -d' ' -f2 | awk '!/(z_order|way_area)/'  >> $tempfile
sort -u $tempfile -o $tempfile

cat << EOT  > taginfo.json
{
    "data_format": 1,
    "data_updated": "$NOW",
    "project": {
        "name": "openstreetmap-carto keys",
        "description": "A general-purpose OpenStreetMap mapnik style, in CartoCSS",
        "project_url": "https://github.com/gravitystorm/openstreetmap-carto",
        "contact_name": "",
        "contact_email": ""
    },
    "tags": [
EOT

cat $tempfile |  awk 'NR > 1 { printf(",") } { printf("{\"key\": \"%s\" }\n ", $1) }'   >> taginfo.json

cat << EOT  >> taginfo.json
    ]
   }
EOT

rm -f "$tempfile"

this is working for the current code in this repo, but has some limitations

  • don't know HSTORE + ARRAY tags @> ARRAY['building',...]
    • need an extra line
  • or don't know some crazy PG syntax ( two adjacent single quotes ) : tags->''entrance''
  • and there are other hstore operators

so sometimes need a little tunning on the Regexp.

So

  • need a code for generating taginfo.json file
    • like my simple bash code (if you need, I can create a pull request )
    • or can be reimplemented in python
  • re-run every release.
  • need a simple registering in https://github.com/taginfo/taginfo-projects repo.

if the project team prefer the python implementations, there are some basic examples ( need to add some project.mml parsing )

@kocio-pl
Copy link
Collaborator

I prefer Python, since it makes it more platform independent. You think it's better to add it into the style then develop and run it independently?

This way or another I reopen the issue, since there is a genuine progress.

@kocio-pl kocio-pl reopened this Mar 28, 2018
@HolgerJeromin
Copy link
Contributor

The json file could be updated before release (like the chicago preview image here in the repository).

@ImreSamu
Copy link

I have started working on this ...

  • rewritten in Python
  • added some extra

see more : #3151

Don't expect fast result ...

@kocio-pl kocio-pl added the code label Mar 29, 2018
@kocio-pl kocio-pl added this to the New features milestone Mar 29, 2018
@ImreSamu
Copy link

Demo version: http://as-af.taginfo-dev.opengeodata.hu/projects/osmcartov2#tags

@kocio-pl
Copy link
Collaborator

The name should be changed like "openstreetmap.org carto keys" -> "OpenStreetMap Carto keys".

@HolgerJeromin
Copy link
Contributor

And remove "mapnik" from the title. It is not complete wrong worded, but there are too many which calls this style still "mapnik"

@kocio-pl
Copy link
Collaborator

Right, I would change it like this:
"OpenStreetMap.org mapnik style, in CartoCSS" -> "Default OpenStreetMap.org style using CartoCSS"

@ImreSamu
Copy link

ImreSamu commented Apr 3, 2018

a little statistics ...

"new keys" == new keys in the ~ taginfo-project file

version change N of "new keys" List of "new keys"
v4.0.0 - v4.1.0 2 iata, icao
v4.1.0 - v4.2.0 4 highspeed, leaf_type, memorial, usage
v4.2.0 - v4.3.0 2 emergency, ford
v4.3.0 - v4.4.0 1 addr:unit
v4.4.0 - v4.5.0 1 public_transport
v4.5.0 - v4.6.0 0
v4.6.0 - v4.7.0 4 entrance, indoor, recycling_type, seasonal
v4.7.0 - v4.7.1 0
v4.7.1 - v4.8.0 0
v4.8.0 - v4.9.0 4 advertising, height, tower:construction, tower:type

@ImreSamu
Copy link

updated statistics ...

version change N of "new osm keys" New osm keys Removed osm keys
v4.0.0 - v4.1.0 2 iata, icao
v4.1.0 - v4.2.0 4 highspeed, leaf_type, memorial, usage
v4.2.0 - v4.3.0 2 emergency, ford
v4.3.0 - v4.4.0 1 addr:unit
v4.4.0 - v4.5.0 1 public_transport
v4.5.0 - v4.6.0 0
v4.6.0 - v4.7.0 4 entrance, indoor, recycling_type, seasonal
v4.7.0 - v4.7.1 0
v4.7.1 - v4.8.0 0
v4.8.0 - v4.9.0 4 advertising, height, tower:construction, tower:type
v4.9.0 - v4.10.0 2 castle_type, office
v4.10.0 - v4.11.0 1 location
v4.11.0 - v4.12.0 2 information, lock_name
v4.12.0 - v4.12.1 0
v4.12.1 - v4.13.0 0
v4.13.0 - v4.14.0 0
v4.14.0 - v4.15.0 1 attraction
v4.15.0 - v4.16.0 1 sport
v4.16.0 - v4.17.0 5 artwork_type, basin, parking, telescope:diameter, telescope:type
v4.17.0 - v4.18.0 (+2) + (-1) healthcare, station power_source

@jeisenbe
Copy link
Collaborator

The demo project above is no longer at the link (http://as-af.taginfo-dev.opengeodata.hu/projects/osmcartov2#tags), and the related PR was closed (#3151).

It does not look like there is an easy way to do this.

There is now a maintained legend of most features rendered in this style at:

And most feature pages on the wiki have a rendering sample, which can be used by taginfo's taglists.

So, is this still needed, or can we close this issue?

@pnorman
Copy link
Collaborator

pnorman commented Jul 8, 2022

Closing for the reasons above.

@pnorman pnorman closed this as completed Jul 8, 2022
@SomeoneElseOSM
Copy link
Contributor

Whilst there may not be the appetite for the OSM Carto developers to advertise what keys and values this style uses at taginfo, I think it's worth sharing my experience of doing exactly the same thing with a map style derived from OSM Carto:

  • Yes, it was relatively easy to do. There's an amount of work to do initially (look at keys and values in the .mml, and for wildcards like amenity the .mss) but it's not technically difficult and would actually make a great way for a newcomer to OSM Carto to contribute.
  • Yes, when changes to the style add new keys or values taginfo.json needs to be updated, but that is literally just a text file. Json validity can easily be checked with jsonlint prior to update.
  • No, some wiki pages such as https://wiki.openstreetmap.org/wiki/OpenStreetMap_Carto/Symbols are not a substitute. They don't appear to be regularly maintained with the style and don't show actual usage.
  • I've found https://taginfo.openstreetmap.org/projects/someoneelse_style#tags extremely useful as a style developer to show what tags actually get used and how many times.

@imagico
Copy link
Collaborator

imagico commented Apr 17, 2023

I have written about the matter extensively some time ago here and have to disagree with @SomeoneElseOSM here on some points. An accurate index of what tags are affecting rendering and how is hard to produce for most non-trivial map styles.

What you have produced for your map style might be useful for you as the style developer in a single developer project to organize your notes on features and keep track of them. But if you compare this with the analysis on

https://imagico.de/map/styleinfo/#style=ajt&section=style

which is fairly incomplete due to the complex tag interpretation you do with its many catch-alls - you will see that it covers only a small part of the logic based on which tags are interpreted and affect the rendering result. For example for access=no you have

https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/c5e22985caa375857f93cb6c27882e719162a239/taginfo.json#L27

which only describes the interpretation of the tag on roads, not on various POI types where it affects rendering as well. Usefulness of such a selective documentation in a larger project like this would be rather limited.

It also seems a bit weird that you reject the hand maintained style documentation on the wiki because it is not regularly maintained but at the same time promote a system of hand maintained documentation in the hope that it will be more regularly maintained despite obviously being less accessible for editing for the average style user.

I do not want to discourage anyone from analyzing the way OSM-Carto interprets tags in a systematic fashion and to publish the result. This is done way too little and the more work (manual human work) in that direction is done the better (for OSM-Carto but also for OSM in general). But for producing a machine readable index of what tags OSM-Carto interprets and how (which is what a taginfo.json file is in a very simplified form) i have little doubt that systematic automated testing is the most viable approach.

@SomeoneElseOSM
Copy link
Contributor

SomeoneElseOSM commented Apr 17, 2023

@imagico As an aside, perhaps it's worth writing about https://imagico.de/map/styleinfo/ somewhere a bit more public so that more people know about it? As an aside, I've no idea what https://imagico.de/map/styleinfo/#style=ajt&section=style is showing, and do wonder whether it's taking into account the lua preprocessing that that style uses at all.

You have said that "An accurate index of what tags are affecting rendering and how is hard to produce for most non-trivial map styles". To be clear, "and how" is something you have added to the requirement yourself there, and that can be complicated (especially when tags are used in combination - "access=private; foot=yes" for example) but the what ("does style X know about tag Y") is not difficult.

I don't entirely understand the rest of your comment but it seems to be "doing a perfect job would be hard"? If that's what you're trying to say I don't disagree, but it's not really relevant.

@imagico
Copy link
Collaborator

imagico commented Apr 17, 2023

@imagico As an aside, perhaps it's worth writing about https://imagico.de/map/styleinfo/ somewhere a bit more public so that more people know about it?

I am not sure what you mean by 'more public'. I don't remember if this specifically was mentioned on weeklyOSM - but most people involved in OSM map style design read my blog so are aware of this.

As an aside, I've no idea what https://imagico.de/map/styleinfo/#style=ajt&section=style is showing, and do wonder whether it's taking into account the lua preprocessing that that style uses at all.

Of course it does, as written in the blog post - the analysis can only exclude the database import step if the database content fairly directly represents the OSM data. That is not the case with your style. Which makes the analysis several times slower than for the other OSM-Carto forks.

If the Styleinfo UI does not work for you you can use the API directly - for example

https://imagico.de/map/styleinfo/api/ajt/renderings/?key=amenity&zoom=19&secondary_key=brand

gets you all the renderings of amenity=* at z19 where brand=* affects the rendering results.

https://imagico.de/map/styleinfo/api/ajt/preview/?key=amenity&value=pharmacy&ftype=polygon&zoom=19&secondary_key=brand

will get you the rendering of amenity=pharmacy with brand=* at z19 on polygons:

amenity=pharmacy

You have said that "An accurate index of what tags are affecting rendering and how is hard to produce for most non-trivial map styles". To be clear, "and how" is something you have added to the requirement yourself there, and that can be complicated (especially when tags are used in combination - "access=private; foot=yes" for example) but the what ("does style X no about tag Y") is not difficult.

The 'how' is primarily about if a tag is interpreted as a primary tag or as a secondary tag. But also just producing a list of tags that - when they exist in the data - under some circumstances affect the rendering result, is not much easier if it is supposed to be reliable. In other words: A detailed how is essentially an automatic byproduct of reliably determining if.

Of course just producing a list of tags that might be interpreted by the style because there is code somewhere literally referencing these tags is much easier. Not as easy as the list of keys (as discussed above) because you need to look at both the SQL and the MSS code but still easy compared to determining what actually leads to a rendering difference. Between #3731 and #4591 we had for example code in the style referencing healthcare tags without there being actual rendering based on those. Therefore such a list is practically of rather limited use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests