Browse Source

railway-maxspeed: handle maxspeed:forward and maxspeed:backward

places
parent
commit
41853b5bf5
  1. 79
      railway-maxspeed.json

79
railway-maxspeed.json

@ -14,36 +14,67 @@
}, },
"feature": { "feature": {
"pre": [ "pre": [
"{% if tags.maxspeed is not defined %}",
"{% set maxspeedKmh = null %}", "{% set maxspeedKmh = null %}",
"{% set maxspeed = null %}", "{% set maxspeed = null %}",
"{% set unit = null %}", "{% set unit = null %}",
"{% else %}",
"", "",
"{% if tags.maxspeed|matches(\"^[0-9]+$\") %}",
"{% set maxspeedKmh = tags.maxspeed %}",
"{% set maxspeed = tags.maxspeed %}",
"{% set unit = \"km/h\" %}",
"{% if tags.maxspeed is defined %}",
" {% if tags.maxspeed|matches(\"^[0-9]+$\") %}",
" {% set maxspeedKmh = tags.maxspeed %}",
" {% set maxspeed = tags.maxspeed %}",
" {% set unit = \"km/h\" %}",
" {% elseif tags.maxspeed|matches( \"(^[0-9]+) mph$\") %}",
" {% set m = tags.maxspeed|matches(\"(^[0-9]+) mph$\") %}",
" {% set maxspeedKmh = m[1] * 1.60934 %}",
" {% set maxspeed = m[1] %}",
" {% set unit = \"mph\" %}",
" {% endif %}",
"{% endif %}", "{% endif %}",
"", "",
"",
"{% set m = tags.maxspeed|matches(\"(^[0-9]+) mph$\") %}",
"{% if m %}",
"{% set maxspeedKmh = m[1] * 1.60934 %}",
"{% set maxspeed = m[1] %}",
"{% set unit = \"mph\" %}",
"{% if attribute(tags, 'maxspeed:forward') is defined %}",
" {% if attribute(tags, 'maxspeed:forward')|matches(\"^[0-9]+$\") %}",
" {% set maxspeedFKmh = attribute(tags, 'maxspeed:forward') %}",
" {% set maxspeedF = attribute(tags, 'maxspeed:forward') %}",
" {% set unit = \"km/h\" %}",
" {% elseif attribute(tags, 'maxspeed:forward')|matches(\"^[0-9]+ mph$\") %}",
" {% set m = attribute(tags, 'maxspeed:forward')|matches(\"(^[0-9]+) mph$\") %}",
" {% set maxspeedFKmh = m[1] * 1.60934 %}",
" {% set maxspeedF = m[1] %}",
" {% set unit = \"mph\" %}",
" {% endif %}",
"{% endif %}", "{% endif %}",
"", "",
"{% if attribute(tags, 'maxspeed:backward') is defined %}",
" {% if attribute(tags, 'maxspeed:backward')|matches(\"^[0-9]+$\") %}",
" {% set maxspeedBKmh = attribute(tags, 'maxspeed:backward') %}",
" {% set maxspeedB = attribute(tags, 'maxspeed:backward') %}",
" {% set unit = \"km/h\" %}",
" {% elseif attribute(tags, 'maxspeed:backward')|matches(\"^[0-9]+ mph$\") %}",
" {% set m = attribute(tags, 'maxspeed:backward')|matches(\"(^[0-9]+) mph$\") %}",
" {% set maxspeedBKmh = m[1] * 1.60934 %}",
" {% set maxspeedB = m[1] %}",
" {% set unit = \"mph\" %}",
" {% endif %}",
"{% endif %}", "{% endif %}",
"", "",
"{% if not maxspeedKmh %}", "{% if not maxspeedKmh %}",
"{% set color = \"#404040\" %}", "{% set color = \"#404040\" %}",
"{% else %}", "{% else %}",
"{% set color = colorInterpolate(const.colorMap, (maxspeedKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}", "{% set color = colorInterpolate(const.colorMap, (maxspeedKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
"{% endif %}",
"",
"{% if maxspeedFKmh %}",
"{% set colorF = colorInterpolate(const.colorMap, (maxspeedFKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
"{% endif %}",
"",
"{% if maxspeedBKmh %}",
"{% set colorB = colorInterpolate(const.colorMap, (maxspeedBKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
"{% endif %}" "{% endif %}"
], ],
"description": [ "description": [
"{% if maxspeed %}",
"{% if maxspeedF or maxspeedB %}",
"<span style='color: {{ colorB }}'>{{ maxspeedB|default(trans('unknown')) }}</span> / <span style='color: {{ colorF }}'>{{ maxspeedF|default(trans('unknown')) }}</span> {{ unit }}",
"{% elseif maxspeed %}",
"<span style='color: {{ color }}'>{{ maxspeed }} {{ unit }}</span>", "<span style='color: {{ color }}'>{{ maxspeed }} {{ unit }}</span>",
"{% elseif tags.maxspeed %}", "{% elseif tags.maxspeed %}",
"{{ tags.maxspeed }}", "{{ tags.maxspeed }}",
@ -53,12 +84,30 @@
], ],
"markerSymbol": null, "markerSymbol": null,
"listMarkerSymbol": "line", "listMarkerSymbol": "line",
"styles": "{% if maxspeedB or maxspeedF %}left,right,default{% else %}default{% endif %}",
"style": { "style": {
"width": "3",
"width": "{% if maxspeedB or maxspeedF %}0{% else %}4{% endif %}",
"color": "{{ color }}", "color": "{{ color }}",
"text": "{{ maxspeed }} ",
"text": [
"{% if maxspeedB or maxspeedF %}",
" {% if maxspeedB %}🡸 {{ maxspeedB }} {% endif %}|{% if maxspeedF %} {{ maxspeedF }} 🡺{% endif %} ",
"{% else %}",
" {{ maxspeed }} ",
"{% endif %}"
],
"textRepeat": "1", "textRepeat": "1",
"textOffset": "4",
"textFontWeight": "bold" "textFontWeight": "bold"
},
"style:left": {
"width": "2",
"color": "{{ colorB|default('#404040') }}",
"offset": "-1"
},
"style:right": {
"width": "2",
"color": "{{ colorF|default('#404040') }}",
"offset": "1"
} }
}, },
"const": { "const": {

Loading…
Cancel
Save