mapnik / mapnik-support

Use the issues queue here to ask questions and offer help on using Mapnik (maybe if this works well we can retire the mailing list at http://mapnik.org/contact/?)
6 stars 6 forks source link

scaleDenominator as variable #133

Closed zdila closed 4 years ago

zdila commented 4 years ago

Hello,

Is there a reason why scaleDenominator is not a variable? We could then use it like stroke-width="[scaleDenominator] / 1000".

lightmare commented 4 years ago

It could be implemented, but I doubt the usefulness of that. For example: on a map twice as detailed, roads appear thicker, but not twice as thick (assuming you meant the inverse calculation X / scale).

zdila commented 4 years ago

Yes, I meant it inversed.

Usefullness would be added with adding support also for math functions like pow, exp, log. Currently we are generating different styles for each "zoom" - example for valleys seen on www.freemap.sk generated using JsNik.

HotPepperDaddy commented 4 years ago

Hi guys, we are also changing stroke-width and stroke opacity based on scale denominator with different styles (property lines on https://www.viewpoint.ca/map). I'm not sure if we'd change those styles to be dynamic but having scale denominator as a variable could be useful in other areas as well, such as selecting a different file source in PointSymbolizer.

talaj commented 4 years ago

It is possible to calculate scale denominator outside of Mapnik and then pass it to the rendering. I know that @zdila is using node-mapnik. There is a parameter for that (test case). C++ and Python have the same parameters.

zdila commented 4 years ago

@talaj oh, this is a good idea. Thanks!

I think it answers a question for my use-case so let me close it.

Still having it directly as a Mapnik variable along with added math functions and "case when ... then ... else" operator would be AFAIK a good addition.

talaj commented 4 years ago

Mapnik supports those math functions: https://github.com/mapnik/mapnik/blob/cfa5809cd228d11299f2652c7b24004426e1b376/include/mapnik/expression_grammar_x3_def.hpp#L239-L269

zdila commented 4 years ago

Great to hear that. Then currently I am now missing just case operator to solve #132 in more elegant way.

zdila commented 4 years ago

@talaj not sure if you could help me or recommend somebody who could. I am trying to implement if-then-else operator (cond ? expA : expB) but I am struggling with it - it doesn't compile. It fails here: https://github.com/zdila/mapnik/commit/52662d0dbcbe90ea80e836574f714b1d8021b0e0#diff-3996f0d1923aa026786a301913ead1e6R122

Also, do you think it is a good approach?

talaj commented 4 years ago

@artemp would know.