CartoCSS -- modify already specified line-width by a percentage

I’m hoping to be modify my CartoCSS to reduce or expand the line-width of a style given some circumstance, i.e. to use the already assigned line-width in an expression to create a new line-width.

I haven’t been able to figure out if CartoCSS supports this. Does anyone know for certain one way or another?

For instance:

[keyA = 'valueA'] {
   line-width: 1;

   [keyB = 'valueB'] { // but not valueC og valueD!!
      line-width: @line-width * 0.9;
   }
}

I have not edited CartoCSS for some time - but can you declare variable and use it for base case and multiply its value for special case?

I can, but the assigned value already comes from a variable. A more complete example:

[keyA = 'valueA'] {
   [zoom = 12] { line-width: @zoom-12-width; }
   [zoom = 13] { line-width: @zoom-13-width; }
   [zoom = 14] { line-width: @zoom-14-width; }
   [zoom = 15] { line-width: @zoom-15-width; }
   [zoom = 16] { line-width: @zoom-16-width; }

   [keyB = 'valueB'] { // but not valueC og valueD!!
      line-width: @line-width * 0.9;
   }
}
1 Like

No, you will need to repeat the zoom logic for valueB
[zoom = 12] { line-width: @zoom-12-width * 0.9; }
etc.
You can put the scaling factor in a variable.

1 Like