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

Overriding the default style via req2params #508

Open
svancise opened this issue Nov 14, 2016 · 1 comment
Open

Overriding the default style via req2params #508

svancise opened this issue Nov 14, 2016 · 1 comment
Assignees
Labels

Comments

@svancise
Copy link

svancise commented Nov 14, 2016

Hello,

I've updated my windshaft install from 1.6.1 to 2.5.0 and have run into a problem with overriding a layer's styling via a req2params function.

With 1.6.1 I was able to add a new style key:value to req.params and have the layer rendered with that new style. With the upgrade I am no longer able to do that in the same way.

Currently I am extending the incoming request like so:

req.query.style = "arbitrary cartocss";
_.extend(req.params, req.query);

With 1.6.1 I am seeing the new style but with 2.5.0 I am still seeing the original style that I initialized the layer with. After some digging I think I may have found the cause, however, I am not sure if it is intentional and I just am not changing the style the proper way anymore.

At line 179 in the mapnik render factory the params are created using the defaults of mmlBuilderConfig and options.params. The issue seems to be that since the original mapConfig always contains the style param that any new style is ignored for the default. Switching var params = _.defaults(mmlBuilderConfig, options.params); to var params = _.defaults(options.params, mmlBuilderConfig); seems to correct this issue. This same issue would be relevant with any new sql passed during the req2params.

Thanks for all of the great work.

Edit: Noticed a newer version (2.6.2) on npm. Installed that and still have the same issue/fix.

@rochoa
Copy link
Contributor

rochoa commented Nov 30, 2016

I can confirm your report, we introduced this bug in a7562b1.

We have to fix it with a similar approach to your proposal. However, that would introduce other bugs related to the layers interactivity.

Thanks a lot for the heads-up @svancise.

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

No branches or pull requests

3 participants