Skip to content

Overriding the default style via req2params #508

@svancise

Description

@svancise

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions