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

Automatically add additional attributes #1

Open
gravitystorm opened this issue Sep 4, 2013 · 0 comments
Open

Automatically add additional attributes #1

gravitystorm opened this issue Sep 4, 2013 · 0 comments

Comments

@gravitystorm
Copy link
Owner

92a63df shows a problem with the current approach of creating the datasource. In a complex layer, there will be many rules referring to many attributes. We currently have to list all the attributes in the legend.json file, but a better approach would involve only listing e.g. "highway": "motorway"

Given we can assume that unmentioned attributes should be null (or equivalent), we could

  • modify the csv datasource and add an "assume missing attributes are null" option
  • figure out the full list of attributes mentioned in the style

For the latter, I've spent a while going through the mapnik source code, to see how it works. We already have access to the list of expressions (aka filters) e.g.

[13] pry(main)> map.styles["aerialways"].rules.first.filter
=> ([aerialway]='j-bar')

To get a list of attributes from a filter (which can be fairly complex) mapnik uses the attribute_collector (which happens during rendering at feature_style_processor_impl.hpp#L373).

Perhaps with some more ruby-mapnik bindings (specifically for attribute_collector), we could create our own attribute_collector instance to gather the attributes, then merge the missing ones in with the ones from legend.json and use the combined list when creating the datasource.

Other ideas welcome!

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

No branches or pull requests

1 participant