From a22ff2f36b50beff89975d85521ebf63cf7dfada Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 26 Apr 2022 10:30:19 +0200 Subject: [PATCH] More climbing styling --- .../layers/climbing_area/climbing_area.json | 2 +- .../layers/climbing_route/climbing_route.json | 11 +- assets/themes/climbing/climbing.css | 44 ++++++++ assets/themes/climbing/climbing.json | 100 +++--------------- assets/themes/climbing/css-test.html | 23 ++++ 5 files changed, 91 insertions(+), 89 deletions(-) create mode 100644 assets/themes/climbing/climbing.css create mode 100644 assets/themes/climbing/css-test.html diff --git a/assets/layers/climbing_area/climbing_area.json b/assets/layers/climbing_area/climbing_area.json index 22c0d2884..22b694ba5 100644 --- a/assets/layers/climbing_area/climbing_area.json +++ b/assets/layers/climbing_area/climbing_area.json @@ -93,7 +93,7 @@ }, "calculatedTags": [ "_contained_climbing_routes_properties=feat.overlapWith('climbing_route').map(f => f.feat.properties).map(p => {return {id: p.id, name: p.name, 'climbing:grade:french': p['climbing:grade:french'], 'climbing:length': p['climbing:length']} })", - "_contained_climbing_routes=feat.get('_contained_climbing_routes_properties')?.map(p => `
  • ${p.name ?? 'climbing route'} (${p['climbing:grade:french'] ?? 'unknown difficulty'}, ${p['climbing:length'] ?? 'unkown length'} meter)
  • `).join('')", + "_contained_climbing_routes=feat.get('_contained_climbing_routes_properties')?.map(p => `
  • ${p.name ?? 'climbing route'} (${p['climbing:grade:french'] ?? 'unknown difficulty'}, ${p['climbing:length'] ?? 'unkown length'} meter)
  • `).join('')", "_contained_climbing_route_ids=feat.get('_contained_climbing_routes_properties')?.map(p => p.id)", "_difficulty_hist=feat.get('_contained_climbing_routes_properties')?.map(p => p['climbing:grade:french'])?.filter(p => (p ?? null) !== null)?.sort()", "_difficulty_max=feat.get('_difficulty_hist')?.at(-1)", diff --git a/assets/layers/climbing_route/climbing_route.json b/assets/layers/climbing_route/climbing_route.json index a562c753c..d95d5748b 100644 --- a/assets/layers/climbing_route/climbing_route.json +++ b/assets/layers/climbing_route/climbing_route.json @@ -217,9 +217,18 @@ ], "label": { "mappings": [ + { + "if": { + "and": [ + "climbing:grade:french~*", + "name~*" + ] + }, + "then": "
    {name} {climbing:grade:french}
    " + }, { "if": "name~*", - "then": "
    {name}
    " + "then": "
    {name}
    " } ] } diff --git a/assets/themes/climbing/climbing.css b/assets/themes/climbing/climbing.css new file mode 100644 index 000000000..b27086c6f --- /dev/null +++ b/assets/themes/climbing/climbing.css @@ -0,0 +1,44 @@ +/* a few extra colours, mostly colours difficulties. Debuggable in css-test.html */ + +.climbing- { + /*Fallback in case of unrecognized difficulty*/ + background: white; + border: 1px solid black; +} + +.climbing-2 { + background: #a2ff00; +} + +.climbing-3 { + background: #a2ff00; +} + +.climbing-4 { + background: yellow; +} + +.climbing-5 { + background: blue; + color: white; +} + +.climbing-6 { + background: red; + color: white; +} + +.climbing-7 { + background: fuchsia; +} + +.climbing-8 { + background: black; + color: white; +} + +.climbing-9 { + background: black; + color: white; +} + diff --git a/assets/themes/climbing/climbing.json b/assets/themes/climbing/climbing.json index 043485b54..66a53b182 100644 --- a/assets/themes/climbing/climbing.json +++ b/assets/themes/climbing/climbing.json @@ -42,16 +42,17 @@ "startLon": 0, "startZoom": 1, "widenFactor": 1.5, + "customCss": "./assets/themes/climbing/climbing.css", "layers": [ { "builtin": [ - "climbing_club", - "climbing_gym", - "climbing_route", - "climbing_area", - "climbing_opportunity" + "climbing_club", + "climbing_gym", + "climbing_route", + "climbing_area", + "climbing_opportunity" ], - "override": { + "override": { "allowMove": { "enableRelocation": false, "enableImproveAccuracy": true @@ -76,93 +77,15 @@ { "id": "Min difficulty", "condition": "__difficulty_min~*", - "then": "
    {__difficulty_min}
    ", - - "mappings": [ - { - "if": "__difficulty_min~(2|3).*", - "then": "
    {__difficulty_min}
    " - }, - { - "if": "__difficulty_min~4.*", - "then": "
    {__difficulty_min}
    " - }, - { - "if": "__difficulty_min~5.*", - "then": "
    {__difficulty_min}
    " - }, - { - "if": "__difficulty_min~6.*", - "then": "
    {__difficulty_min}
    " - }, - { - "if": "__difficulty_min~(7|8).*", - "then": "
    {__difficulty_min}
    " - }, - { - "if": "__difficulty_min~*", - "then": "
    {__difficulty_min}
    " - } - ] + "render": "
    {__difficulty_min}
    " }, { "id": "max difficulty", "condition": "__difficulty_max~*", - "then": "
    {__difficulty_max}
    ", - "mappings": [ - { - "if": "__difficulty_max~(2|3).*", - "then": "
    {__difficulty_max}
    " - }, - { - "if": "__difficulty_max~4.*", - "then": "
    {__difficulty_max}
    " - }, - { - "if": "__difficulty_max~5.*", - "then": "
    {__difficulty_max}
    " - }, - { - "if": "__difficulty_max~6.*", - "then": "
    {__difficulty_max}
    " - }, - { - "if": "__difficulty_max~(7|8).*", - "then": "
    {__difficulty_max}
    " - }, - { - "if": "__difficulty_max~*", - "then": "
    {__difficulty_max}
    " - } - ] + "render": "
    {__difficulty_max}
    " }, { - "mappings": [ - { - "if": "climbing:grade:french~3.*", - "then": "
    {climbing:grade:french}
    " - }, - { - "if": "climbing:grade:french~4.*", - "then": "
    {climbing:grade:french}
    " - }, - { - "if": "climbing:grade:french~5.*", - "then": "
    {climbing:grade:french}
    " - }, - { - "if": "climbing:grade:french~6.*", - "then": "
    {climbing:grade:french}
    " - }, - { - "if": "climbing:grade:french~7.*", - "then": "
    {climbing:grade:french}
    " - }, - { - "if": "climbing:grade:french~*", - "then": "
    {climbing:grade:french}
    " - } - ] + "render": "
    {climbing:grade:french}
    " } ], "+calculatedTags": [ @@ -176,6 +99,9 @@ "_embedding_feature:id=feat.get('_embedding_features_with_access')?.id", "__difficulty_max= feat.properties['climbing:grade:french:max'] ?? feat.properties['_difficulty_max']", "__difficulty_min= feat.properties['climbing:grade:french:min'] ?? feat.properties['_difficulty_min']", + "__difficulty_max:char= feat.properties['__difficulty_max']?.at(0)", + "__difficulty_min:char= feat.properties['__difficulty_min']?.at(0)", + "__difficulty:char= feat.properties['climbing:grade:french']?.at(0)", "__bolts_max= feat.get('climbing:bolts:max') ?? feat.get('climbing:bolts') ?? feat.get('_bolts_max')" ], "units+": [ diff --git a/assets/themes/climbing/css-test.html b/assets/themes/climbing/css-test.html new file mode 100644 index 000000000..f96887813 --- /dev/null +++ b/assets/themes/climbing/css-test.html @@ -0,0 +1,23 @@ + + + + + CSS-debugging for climbing theme + + + + + +
    2
    + +
    3
    +
    4
    +
    5
    +
    6
    +
    7
    +
    8
    +
    9
    +
    X
    + + + \ No newline at end of file