This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Override inner SVG parameters by definition in .mss files

1

Hi, In general I try to override colour of motorway shield, but there are many of SVG's files with already defined background colour.
What I want to achieve is not to edit all SVG's but instead of that I would like to define that values directly in .mss files. I got familiar with mapnik documentation but I couldn't find anything related to my problem.
In general the SVG of road shield looks like that:
alt text
(I'm sorry byt I've got problems with pasting that structure as a code..)
And as you can see the colour of shield (fill) and stroke around (stroke) is already defined in file.
Is there a way to override that values directly from style files?

asked 29 Mar '21, 10:30

engopy's gravatar image

engopy
126101015
accept rate: 0%

edited 29 Mar '21, 10:31


One Answer:

3

If you are using openstreetmap-carto as a base for your custom style, there is a script called generate_shields.py ( https://github.com/gravitystorm/openstreetmap-carto/blob/master/scripts/generate_shields.py ) that is responsible for the generation of those svg files. And that script refers to generate_road_colours.py ( https://github.com/gravitystorm/openstreetmap-carto/blob/master/scripts/generate_road_colours.py ) and that one uses values as defined in road-colors.yaml ( https://github.com/gravitystorm/openstreetmap-carto/blob/master/road-colors.yaml ).

So to change the appearance of road colours and attached shields, you would have to edit the road-colors.yaml and than run those scripts again to get the svg shield files and the road-colours-generated.mss

answered 29 Mar '21, 15:37

Spiekerooger's gravatar image

Spiekerooger
3.1k22356
accept rate: 16%

2

Yes I use carto by gravitystorm. Thanks, it completely solved my problem.

(30 Mar '21, 11:09) engopy

Source code available on GitHub .