Here is an example of adding customization code to the script. I used the Outdoor theme from locus store which works with v3 maps because it is a very small and simple theme (only 1400 lines).
In the customisation section of the script is uses the keys and values of rules in the theme to isolate and apply specific modifications to certain tags and their attributes, e.g.:
if inscope(current_keys, "highway") then
if current(current_vals) = "motorway_junction" then
if current_tag = "circle" then
line = update_tag(line, "r", 1.5, 0)
line = update_tag(line, "stroke-width", 2, 0)
end if
if current_tag = "caption" then
line = update_tag(line, "font-size", 1, 3)
if instr(line,"caption k="+Chr(34)+"addr:housenumber"+Chr(34)) > 0 then
line = update_tag(line, "dy", 0, 0)
end if
end if
end if
end if
This looks for lines of the theme that are in scope of k="highway" v="motorway_junction" and then tweaks:
- the circle's radius and stroke-width
- its caption's font-size and dy offset (but only for addr:housenumbers captions).
Here is the theme content before from v3:
<!-- highway exits -->
<rule e="node" k="highway" v="motorway_junction" zoom-min="11" zoom-max="13">
<circle r="6" scale-radius="false" fill="#dFdFFF" stroke="#FF0000" stroke-width="2.0"/>
</rule>
<rule e="node" k="highway" v="motorway_junction" zoom-min="14">
<circle r="6" scale-radius="true" fill="#dFdFFF" stroke="#FF0000" stroke-width="1.2"/>
<caption k="addr:housenumber" display="always" dx="-2" dy="10" priority="95" font-style="bold" font-size="6dp" fill="#FF0000" stroke="#FFFF00" stroke-width="1.2dp" scale-font-size="14,1.3"/>
<caption k="name" display="always" dy="-14dp" scale-dy-size="16,1.2" font-style="bold" font-size="7dp" fill="#0100C8" stroke="#FFFFFF" stroke-width="1.2dp" scale-font-size="14,1.3"/>
</rule>
and after in the converted v4 version:
<!-- highway exits -->
<rule e="node" k="highway" v="motorway_junction" zoom-min="10" zoom-max="12">
<circle r="2.7" scale-radius="false" fill="#dFdFFF" stroke="#FF0000" stroke-width="0.9"/>
</rule>
<rule e="node" k="highway" v="motorway_junction" zoom-min="13">
<circle r="2.7" scale-radius="true" fill="#dFdFFF" stroke="#FF0000" stroke-width="0.54"/>
<caption k="addr:housenumber" display="always" dy="0" priority="95" font-style="bold" font-size="9" fill="#FF0000" stroke="#FFFF00" stroke-width="1.08" />
<caption k="name" display="always" dy="-14" font-style="bold" font-size="10" fill="#0100C8" stroke="#FFFFFF" stroke-width="1.08" />
</rule>
I should point out that the stroke-width of circles also have a scale of 0.9 and 0.25 applied to it elsewhere in the script, hence 2 * 0.9 * 0.25 * 2 = 0.9. As you can guess, I was just applying correction by trial error until things looked reasonable...
Note the parameters for update_tag are:
- update_tag( line, tag_name, scale, offset )
and it applies a scale and offset to numerical tag values. E.g. The following line:
line = update_tag(line, "font-size", 2, -4)
when applied to the following theme line:
<pathText k="name" font-style="bold" font-size="9" fill="#606060" stroke="#ffffff" stroke-width="2.0"/>
will result in the font-size being processed as: new-font-size = (old-font-size * 2) - 4 = 14. i.e.:
<pathText k="name" font-style="bold" font-size="14" fill="#606060" stroke="#ffffff" stroke-width="2.0"/>.
The script has a variable called "zoom_offset" which is set to -1 in this example. It subtracts 1 from all the zoom-min and zoom-max values to readjust the v4 converted theme to look similar in scales as the original v3 theme. Of course, if there are map elements that appear at zoom level 14, the will not appear at zoom level 13 in the v4 map.
The screenshots show the original v3 Outdoor theme, converted to v4 theme and the original OutdoorV4 theme.
I'm posting the converted outdoor theme only as an example of what the script can do. I haven't checked it extensively and you are probably better off using the official OutdoorV4 theme.
In the customisation section of the script is uses the keys and values of rules in the theme to isolate and apply specific modifications to certain tags and their attributes, e.g.:
if inscope(current_keys, "highway") then
if current(current_vals) = "motorway_junction" then
if current_tag = "circle" then
line = update_tag(line, "r", 1.5, 0)
line = update_tag(line, "stroke-width", 2, 0)
end if
if current_tag = "caption" then
line = update_tag(line, "font-size", 1, 3)
if instr(line,"caption k="+Chr(34)+"addr:housenumber"+Chr(34)) > 0 then
line = update_tag(line, "dy", 0, 0)
end if
end if
end if
end if
This looks for lines of the theme that are in scope of k="highway" v="motorway_junction" and then tweaks:
- the circle's radius and stroke-width
- its caption's font-size and dy offset (but only for addr:housenumbers captions).
Here is the theme content before from v3:
<!-- highway exits -->
<rule e="node" k="highway" v="motorway_junction" zoom-min="11" zoom-max="13">
<circle r="6" scale-radius="false" fill="#dFdFFF" stroke="#FF0000" stroke-width="2.0"/>
</rule>
<rule e="node" k="highway" v="motorway_junction" zoom-min="14">
<circle r="6" scale-radius="true" fill="#dFdFFF" stroke="#FF0000" stroke-width="1.2"/>
<caption k="addr:housenumber" display="always" dx="-2" dy="10" priority="95" font-style="bold" font-size="6dp" fill="#FF0000" stroke="#FFFF00" stroke-width="1.2dp" scale-font-size="14,1.3"/>
<caption k="name" display="always" dy="-14dp" scale-dy-size="16,1.2" font-style="bold" font-size="7dp" fill="#0100C8" stroke="#FFFFFF" stroke-width="1.2dp" scale-font-size="14,1.3"/>
</rule>
and after in the converted v4 version:
<!-- highway exits -->
<rule e="node" k="highway" v="motorway_junction" zoom-min="10" zoom-max="12">
<circle r="2.7" scale-radius="false" fill="#dFdFFF" stroke="#FF0000" stroke-width="0.9"/>
</rule>
<rule e="node" k="highway" v="motorway_junction" zoom-min="13">
<circle r="2.7" scale-radius="true" fill="#dFdFFF" stroke="#FF0000" stroke-width="0.54"/>
<caption k="addr:housenumber" display="always" dy="0" priority="95" font-style="bold" font-size="9" fill="#FF0000" stroke="#FFFF00" stroke-width="1.08" />
<caption k="name" display="always" dy="-14" font-style="bold" font-size="10" fill="#0100C8" stroke="#FFFFFF" stroke-width="1.08" />
</rule>
I should point out that the stroke-width of circles also have a scale of 0.9 and 0.25 applied to it elsewhere in the script, hence 2 * 0.9 * 0.25 * 2 = 0.9. As you can guess, I was just applying correction by trial error until things looked reasonable...
Note the parameters for update_tag are:
- update_tag( line, tag_name, scale, offset )
and it applies a scale and offset to numerical tag values. E.g. The following line:
line = update_tag(line, "font-size", 2, -4)
when applied to the following theme line:
<pathText k="name" font-style="bold" font-size="9" fill="#606060" stroke="#ffffff" stroke-width="2.0"/>
will result in the font-size being processed as: new-font-size = (old-font-size * 2) - 4 = 14. i.e.:
<pathText k="name" font-style="bold" font-size="14" fill="#606060" stroke="#ffffff" stroke-width="2.0"/>.
The script has a variable called "zoom_offset" which is set to -1 in this example. It subtracts 1 from all the zoom-min and zoom-max values to readjust the v4 converted theme to look similar in scales as the original v3 theme. Of course, if there are map elements that appear at zoom level 14, the will not appear at zoom level 13 in the v4 map.
The screenshots show the original v3 Outdoor theme, converted to v4 theme and the original OutdoorV4 theme.
I'm posting the converted outdoor theme only as an example of what the script can do. I haven't checked it extensively and you are probably better off using the official OutdoorV4 theme.