| 1 |
|
|---|
| 2 | meta {
|
|---|
| 3 | title: "Hiking routes DEMO";
|
|---|
| 4 | description: "Demo/proof of concept for extended MapCSS rendering of route relations - requires JOSM patch";
|
|---|
| 5 | version: "0.1_2011-12-15";
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * Key element of this style is that, with the patch, rule declarations are executed for all matching relations,
|
|---|
| 10 | * not just the first one.
|
|---|
| 11 | * Based on osmc:symbol tag, see http://wiki.openstreetmap.org/wiki/Key:osmc:symbol.
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | way::osmc {
|
|---|
| 15 | _width: 10;
|
|---|
| 16 | _opacity: 0.6;
|
|---|
| 17 | _dashes_width: 6;
|
|---|
| 18 | _font_size: 9;
|
|---|
| 19 | _text_offset: 11;
|
|---|
| 20 |
|
|---|
| 21 | _count: 0;
|
|---|
| 22 | _index: 0;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | /*
|
|---|
| 26 | * Count matching parent relations and set dashes size accordingly
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | relation[type=route][route=hiking] > way::osmc,
|
|---|
| 30 | relation[type=route][route=foot] > way::osmc {
|
|---|
| 31 | _count: set_prop(_count, osmc, prop(_count, osmc) + 1);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | way::osmc {
|
|---|
| 35 | _dashes_space: (prop(_count) > 1) ? 2 : 0;
|
|---|
| 36 | _dashes: list(prop(_dashes_width), (prop(_dashes_width) * (prop(_count) - 1)) + prop(_dashes_space));
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | /*
|
|---|
| 40 | * dashed route lines
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | relation[osmc:symbol] > way::osmc {
|
|---|
| 44 | _color: regex("^([a-z]+):", parent_tag("osmc:symbol"));
|
|---|
| 45 | _color: (prop(_color) == "black") ? "white" : prop(_color);
|
|---|
| 46 | color: color(prop(_color));
|
|---|
| 47 | dashes: prop(_dashes, osmc);
|
|---|
| 48 | dashes-offset: prop(_index, osmc) * prop(_dashes_width, osmc);
|
|---|
| 49 | width: prop(_width, osmc);
|
|---|
| 50 | opacity: prop(_opacity, osmc);
|
|---|
| 51 | z-index: -1;
|
|---|
| 52 |
|
|---|
| 53 | _index: set_prop(_index, osmc, prop(_index, osmc) + 1);
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | relation[!osmc:symbol][type=route][route=hiking] > way::osmc_none,
|
|---|
| 57 | relation[!osmc:symbol][type=route][route=foot] > way::osmc_none {
|
|---|
| 58 | color: grey;
|
|---|
| 59 | dashes: prop(_dashes, osmc);
|
|---|
| 60 | dashes-offset: prop(_index, osmc) * prop(_dashes_width, osmc);
|
|---|
| 61 | width: prop(_width, osmc);
|
|---|
| 62 | opacity: prop(_opacity, osmc);
|
|---|
| 63 | z-index: -1;
|
|---|
| 64 |
|
|---|
| 65 | _index: set_prop(_index, osmc, prop(_index, osmc) + 1);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | * text z16-
|
|---|
| 70 | */
|
|---|
| 71 |
|
|---|
| 72 | way::osmc_text {
|
|---|
| 73 | _index: 0;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | relation[osmc:symbol] > way|z16-::osmc_text {
|
|---|
| 77 | text: parent_tag(name);
|
|---|
| 78 | _color: regex("^([a-z]+):", parent_tag("osmc:symbol"));
|
|---|
| 79 | _color: (prop(_color) == "black") ? "white" : prop(_color);
|
|---|
| 80 | text-color: color(prop(_color));
|
|---|
| 81 | text-offset: prop(_text_offset, osmc) * (prop(_index, osmc_text) + 1);
|
|---|
| 82 | font-size: prop(_font_size, osmc);
|
|---|
| 83 |
|
|---|
| 84 | _index: set_prop(_index, osmc_text, prop(_index, osmc_text) + 1);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | relation[!osmc:symbol][type=route][route=hiking] > way|z16-::osmc_none,
|
|---|
| 88 | relation[!osmc:symbol][type=route][route=foot] > way|z16-::osmc_none {
|
|---|
| 89 | text: parent_tag(name);
|
|---|
| 90 | text-color: grey;
|
|---|
| 91 | text-offset: prop(_text_offset, osmc) * (prop(_index, osmc_text) + 1);
|
|---|
| 92 | font-size: prop(_font_size, osmc);
|
|---|
| 93 |
|
|---|
| 94 | _index: set_prop(_index, osmc_text, prop(_index, osmc_text) + 1);
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | /*
|
|---|
| 98 | * text z14-15
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | way::osmc_text {
|
|---|
| 102 | _index: 0;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | relation[osmc:symbol] > way|z14-15::osmc_text {
|
|---|
| 106 | _ref: parent_tag(ref);
|
|---|
| 107 | /* osmc:symbol = waycolor:background:[foreground]:[foreground2:][text:textcolor]
|
|---|
| 108 | green:white::Vo:black
|
|---|
| 109 | blue:white:blue_cross
|
|---|
| 110 | */
|
|---|
| 111 | _text: regex("^[a-z]+:\\w+::(.*):[a-z]+", parent_tag("osmc:symbol"));
|
|---|
| 112 | _foreground: regex("^[a-z]+:\\w+:(\\w+)", parent_tag("osmc:symbol"));
|
|---|
| 113 | /* "any" function (MapCSS/0.2) would be nice here */
|
|---|
| 114 | text: (is_prop_set(_ref)) ? prop(_ref) : ((is_prop_set(_text)) ? prop(_text) : prop(_foreground));
|
|---|
| 115 | _color: regex("^([a-z]+):", parent_tag("osmc:symbol"));
|
|---|
| 116 | _color: (prop(_color) == "black") ? "white" : prop(_color);
|
|---|
| 117 | text-color: color(prop(_color));
|
|---|
| 118 | text-offset: prop(_text_offset, osmc) * (prop(_index, osmc_text) + 1);
|
|---|
| 119 | font-size: prop(_font_size, osmc);
|
|---|
| 120 |
|
|---|
| 121 | _index: set_prop(_index, osmc_text, prop(_index, osmc_text) + 1);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | relation[!osmc:symbol][type=route][route=hiking] > way|z14-15::osmc_none,
|
|---|
| 125 | relation[!osmc:symbol][type=route][route=foot] > way|z14-15::osmc_none {
|
|---|
| 126 | _ref: parent_tag(ref);
|
|---|
| 127 | _text: regex("^[a-z]+:\\w+::(.*):[a-z]+", parent_tag("osmc:symbol"));
|
|---|
| 128 | _foreground: regex("^[a-z]+:\\w+:(\\w+)", parent_tag("osmc:symbol"));
|
|---|
| 129 | /* "any" function (MapCSS/0.2) would be nice here */
|
|---|
| 130 | text: (is_prop_set(_ref)) ? prop(_ref) : ((is_prop_set(_text)) ? prop(_text) : prop(_foreground));
|
|---|
| 131 | text-color: grey;
|
|---|
| 132 | text-offset: prop(_text_offset, osmc) * (prop(_index, osmc_text) + 1);
|
|---|
| 133 | font-size: prop(_font_size, osmc);
|
|---|
| 134 |
|
|---|
| 135 | _index: set_prop(_index, osmc_text, prop(_index, osmc_text) + 1);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | /*
|
|---|
| 139 | * symbols (for this demo only one per way on middle node)
|
|---|
| 140 | */
|
|---|
| 141 |
|
|---|
| 142 | way::symbol {
|
|---|
| 143 | _symbol_drawn: false;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | /* icons, e.g. osmc:symbol=blue:white:blue_cross */
|
|---|
| 147 | relation[osmc:symbol=~/^[a-z]+:[a-z_]+:[a-z_]+/][eval(!prop(_symbol_drawn, symbol))]
|
|---|
| 148 | > way[JOSM_search("-(type:way nodes:-3)")]::icon_background {
|
|---|
| 149 |
|
|---|
| 150 | _icon_bg: regex("^[a-z]+:(\\w+):\\w+", parent_tag("osmc:symbol"));
|
|---|
| 151 | icon-image: concat("http://www.wanderreitkarte.de/symbols/base_", prop(_icon_bg), ".png");
|
|---|
| 152 | icon-width: 15;
|
|---|
| 153 | icon-height: 11;
|
|---|
| 154 | z-index: 1000;
|
|---|
| 155 | }
|
|---|
| 156 | relation[osmc:symbol=~/^[a-z]+:[a-z_]+:[a-z_]+/][eval(!prop(_symbol_drawn, symbol))]
|
|---|
| 157 | > way[JOSM_search("-(type:way nodes:-3)")]::icon_foreground {
|
|---|
| 158 |
|
|---|
| 159 | _icon_fg: regex("^[a-z]+:\\w+:(\\w+)$", parent_tag("osmc:symbol"));
|
|---|
| 160 | icon-image: concat("http://www.wanderreitkarte.de/symbols/icon_", prop(_icon_fg), ".png");
|
|---|
| 161 | z-index: 1001;
|
|---|
| 162 |
|
|---|
| 163 | _symbol_drawn: set_prop(_symbol_drawn, symbol, true);
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | /* text symbols, e.g. osmc:symbol=green:white::Vo:black */
|
|---|
| 167 | relation[osmc:symbol=~/^[a-z]+:[a-z_]+::.*:[a-z]+$/][eval(!prop(_symbol_drawn, symbol))]
|
|---|
| 168 | > way[JOSM_search("-(type:way nodes:-3)")]::icon_background {
|
|---|
| 169 |
|
|---|
| 170 | symbol-shape: square;
|
|---|
| 171 | symbol-size: 20;
|
|---|
| 172 | symbol-stroke-width: 1.5;
|
|---|
| 173 | symbol-stroke-color: color(regex("^([a-z]+):[a-z_]+::.*:[a-z]+$", parent_tag("osmc:symbol")));
|
|---|
| 174 | symbol-fill-color: color(regex("^[a-z]+:([a-z_]+)::.*:[a-z]+$", parent_tag("osmc:symbol")));
|
|---|
| 175 |
|
|---|
| 176 | text: regex("^[a-z]+:[a-z_]+::(.*):[a-z]+$", parent_tag("osmc:symbol"));
|
|---|
| 177 | text-color: color(regex("^[a-z]+:[a-z_]+::.*:([a-z]+)$", parent_tag("osmc:symbol")));
|
|---|
| 178 | text-anchor-vertical: center;
|
|---|
| 179 | text-anchor-horizontal: center;
|
|---|
| 180 | font-size: 12;
|
|---|
| 181 | font-weight: bold;
|
|---|
| 182 |
|
|---|
| 183 | z-index: 1000;
|
|---|
| 184 |
|
|---|
| 185 | _symbol_drawn: set_prop(_symbol_drawn, symbol, true);
|
|---|
| 186 | }
|
|---|