This is a suggestion + a working example for proof of concept, that you may find interesting ... or not .
There are currently a lot of redundancies in .mapcss files : the same patterns are repeated many times ... just because we must provide different values for lines width and dashes, depending on zoom
The idea is to define generic patterns like line|z11-[highway=path][_path_grade=difficult] {width: @WIDTHdifficult; } where a .csv file will define the appropriate value for @WIDTHdifficult depending on the zoom
Benefits:
- less redundancy
- much less lines in .mapcss files
- easier tuning of values
- it is easier to have a 'global view' by viewing the .csv with an Excel-like reader
Notes:
- the impact on Kothic code is very limited and well isolated
- it is very easy to check that using this mechanism generates exactly the same result ( see README )
- using this new mechanism can be done step by step
Example
Hereafter the example, inside Roads.mapcss, applied on highway-path-difficult and highway-path-expert for the outdoors style
/*---------- demo for Csvcss mechanism ----------------*/
/*
line|z11[highway=path][_path_grade=difficult],
line|z11[highway=path][_path_grade=expert],
{width: 1; dashes: 1,2; opacity: 0.7;}
line|z12[highway=path][_path_grade=difficult],
line|z12[highway=path][_path_grade=expert],
{width: 1.1; dashes: 1,2; opacity: 0.8;}
line|z13[highway=path][_path_grade=difficult],
{width: 1.3; dashes: 1.5,2.5;}
line|z14[highway=path][_path_grade=difficult],
{width: 1.6; dashes: 1.5,2.5;}
line|z15[highway=path][_path_grade=difficult],
{width: 2; dashes: 2.5,4;}
line|z16[highway=path][_path_grade=difficult],
{width: 2.6; dashes: 2.5,4;}
line|z17[highway=path][_path_grade=difficult],
{width: 3.3; dashes: 3.6,5;}
line|z18-[highway=path][_path_grade=difficult],
{width: 4; dashes: 3.6,5;}
line|z13[highway=path][_path_grade=expert],
{width: 1.3; dashes: 1.4,5;}
line|z14[highway=path][_path_grade=expert],
{width: 1.6; dashes: 1.4,5;}
line|z15[highway=path][_path_grade=expert],
{width: 2; dashes: 2.3,9;}
line|z16[highway=path][_path_grade=expert],
{width: 2.6; dashes: 2.3,9;}
line|z17[highway=path][_path_grade=expert],
{width: 3.3; dashes: 3.5,11;}
line|z18-[highway=path][_path_grade=expert],
{width: 4; dashes: 3.5,11;}
*/
line|z11-[highway=path][_path_grade=difficult]
{width: @WIDTHpathgrade; dashes: @DASHpathdifficult; }
line|z11-[highway=path][_path_grade=expert]
{width: @WIDTHpathgrade; dashes: @DASHpathexpert; }
line|z11-12[highway=path][_path_grade=difficult],
line|z11-12[highway=path][_path_grade=expert],
{opacity: @OPACpathgrade;}
Next improvement
We are currently obliged to redefine dashes values, each time the line width changes ...
I guess that defining dashes as percentages of line width, might greatly simplify this
Implementation Notes
- The
style directory provided in this example, contains files to be copied to the appropriate location in data/styles
I have applied a similar mechanism for a personal clone of www.cyclosm.org ... and the result was there : 3000 lines of .css code deleted !
Signed-off-by: bmgru bmgru@noreply.codeberg.org
This is a suggestion + a working example for proof of concept, that you may find interesting ... or not .
There are currently a lot of redundancies in .mapcss files : the same patterns are repeated many times ... just because we must provide different values for lines width and dashes, depending on zoom
The idea is to define generic patterns like `line|z11-[highway=path][_path_grade=difficult] {width: @WIDTHdifficult; }` where a .csv file will define the appropriate value for `@WIDTHdifficult` depending on the zoom
**Benefits:**
- less redundancy
- much less lines in .mapcss files
- easier tuning of values
- it is easier to have a 'global view' by viewing the .csv with an Excel-like reader
**Notes:**
- the impact on Kothic code is very limited and well isolated
- it is very easy to check that using this mechanism generates exactly the same result ( see README )
- using this new mechanism can be done step by step
**Example**
Hereafter the example, inside `Roads.mapcss`, applied on `highway-path-difficult` and `highway-path-expert` for the `outdoors` style
```
/*---------- demo for Csvcss mechanism ----------------*/
/*
line|z11[highway=path][_path_grade=difficult],
line|z11[highway=path][_path_grade=expert],
{width: 1; dashes: 1,2; opacity: 0.7;}
line|z12[highway=path][_path_grade=difficult],
line|z12[highway=path][_path_grade=expert],
{width: 1.1; dashes: 1,2; opacity: 0.8;}
line|z13[highway=path][_path_grade=difficult],
{width: 1.3; dashes: 1.5,2.5;}
line|z14[highway=path][_path_grade=difficult],
{width: 1.6; dashes: 1.5,2.5;}
line|z15[highway=path][_path_grade=difficult],
{width: 2; dashes: 2.5,4;}
line|z16[highway=path][_path_grade=difficult],
{width: 2.6; dashes: 2.5,4;}
line|z17[highway=path][_path_grade=difficult],
{width: 3.3; dashes: 3.6,5;}
line|z18-[highway=path][_path_grade=difficult],
{width: 4; dashes: 3.6,5;}
line|z13[highway=path][_path_grade=expert],
{width: 1.3; dashes: 1.4,5;}
line|z14[highway=path][_path_grade=expert],
{width: 1.6; dashes: 1.4,5;}
line|z15[highway=path][_path_grade=expert],
{width: 2; dashes: 2.3,9;}
line|z16[highway=path][_path_grade=expert],
{width: 2.6; dashes: 2.3,9;}
line|z17[highway=path][_path_grade=expert],
{width: 3.3; dashes: 3.5,11;}
line|z18-[highway=path][_path_grade=expert],
{width: 4; dashes: 3.5,11;}
*/
line|z11-[highway=path][_path_grade=difficult]
{width: @WIDTHpathgrade; dashes: @DASHpathdifficult; }
line|z11-[highway=path][_path_grade=expert]
{width: @WIDTHpathgrade; dashes: @DASHpathexpert; }
line|z11-12[highway=path][_path_grade=difficult],
line|z11-12[highway=path][_path_grade=expert],
{opacity: @OPACpathgrade;}
```
**Next improvement**
We are currently obliged to redefine dashes values, each time the line width changes ...
I guess that defining dashes as percentages of line width, might greatly simplify this
**Implementation Notes**
- The `style` directory provided in this example, contains files to be copied to the appropriate location in data/styles
I have applied a similar mechanism for a personal clone of www.cyclosm.org ... and the result was there : 3000 lines of .css code deleted !
Signed-off-by: bmgru <bmgru@noreply.codeberg.org>