A repository for testing purposes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
8.1 KiB

  1. query: |
  2. (
  3. way[highway=cycleway];
  4. way["cycleway:width"];
  5. way["cycleway:left"]["cycleway:left"!~"(no|separate)"];
  6. way["cycleway:right"]["cycleway:right"!~"(no|separate)"];
  7. way["cycleway:both"]["cycleway:both"!~"(no|separate)"];
  8. )
  9. feature:
  10. pre: |
  11. {% set driving_side = 'right' %}
  12. {% set width = attribute(tags, 'cycleway:width') %}
  13. {% if width matches "/'$/" %}
  14. {% set width = (width|slice(0, -1)) * 0.3048 %}
  15. {% endif %}
  16. {% set leftCycle = attribute(tags, 'cycleway:left')|default(attribute(tags, 'cycleway:both')) %}
  17. {% if leftCycle in ['no', 'separate'] %}
  18. {% set leftCycle = '' %}
  19. {% endif %}
  20. {% set leftOneway = attribute(tags, 'cycleway:left:oneway')|default(attribute(tags, 'cycleway:both:oneway')) %}
  21. {% if not leftOneway or leftOneway in ['yes'] %}
  22. {% set leftOneway = driving_side ? -1 : 1 %}
  23. {% elseif leftOneway in ['no'] %}
  24. {% set leftOneway = 0 %}
  25. {% endif %}
  26. {% set leftWidth = attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) %}
  27. {% if leftWidth matches "/'$/" %}
  28. {% set leftWidth = (leftWidth|slice(0, -1)) * 0.3048 %}
  29. {% endif %}
  30. {% set rightCycle = attribute(tags, 'cycleway:right')|default(attribute(tags, 'cycleway:both')) %}
  31. {% if rightCycle in ['no', 'separate'] %}
  32. {% set rightCycle = '' %}
  33. {% endif %}
  34. {% set rightOneway = attribute(tags, 'cycleway:right:oneway')|default(attribute(tags, 'cycleway:both:oneway')) %}
  35. {% if not rightOneway or rightOneway in ['yes'] %}
  36. {% set rightOneway = driving_side ? 1 : -1 %}
  37. {% elseif rightOneway in ['no'] %}
  38. {% set rightOneway = 0 %}
  39. {% endif %}
  40. {% set rightWidth = attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) %}
  41. {% if rightWidth matches "/'$/" %}
  42. {% set rightWidth = (rightWidth|slice(0, -1)) * 0.3048 %}
  43. {% endif %}
  44. styles: default{% if leftCycle %},left{% endif %}{% if rightCycle %},right{% endif %}
  45. style:
  46. width: 4
  47. opacity: |
  48. {{ tags.highway == 'cycleway' or attribute(tags, 'cycleway:width') ? 1 : 0 }}
  49. color: |
  50. {% set minWidth = tags.oneway in ['yes', 1, -1] ? const.minWidthOneway : const.minWidthBoth %}
  51. {% set optWidth = tags.oneway in ['yes', 1, -1] ? const.optWidthOneway : const.optWidthBoth %}
  52. {% if width %}
  53. {{ colorInterpolate(const.colorScheme, (width - minWidth) / (optWidth - minWidth)) }}
  54. {% else %}black
  55. {% endif %}
  56. lineCap: |
  57. {{ tags.oneway in ['yes', 1, -1] ? 'butt' : 'round' }}
  58. dashArray: |
  59. {{ tags.oneway in ['yes', 1, -1] ? '27,8' : '' }}
  60. dashOffset: |
  61. {{ tags.oneway in [-1] ? 28 : 0 }}
  62. noClip: |
  63. {{ tags.oneway in ['yes', 1, -1] }}
  64. pattern: |
  65. {% if tags.highway == 'cycleway' or attribute(tags, 'cycleway:width') %}
  66. {% if tags.oneway in ['yes', 1, -1] %}arrowHead{% endif %}
  67. {% endif %}
  68. pattern-offset: |
  69. {{ tags.oneway in [-1] ? 4 : 30.5 }}
  70. pattern-repeat: 35
  71. pattern-polygon: true
  72. pattern-pixelSize: 9
  73. pattern-angleCorrection: |
  74. {{ tags.oneway in [-1] ? 180 : 0 }}
  75. pattern-path-width: 0
  76. pattern-path-color: |
  77. {% if width %}
  78. {{ colorInterpolate(const.colorScheme, (width - minWidth) / (optWidth - minWidth)) }}
  79. {% else %}black
  80. {% endif %}
  81. pattern-path-fillOpacity: 1
  82. style:left:
  83. offset: -5
  84. width: |
  85. {{ leftCycle in ['no', 'separate'] ? 0 : 3 }}
  86. color: |
  87. {% set minWidth = const.minWidthOneway %}
  88. {% set optWidth = const.optWidthOneway %}
  89. {% if leftWidth %}
  90. {{ colorInterpolate(const.colorScheme, (leftWidth - minWidth) / (optWidth - minWidth)) }}
  91. {% else %}black
  92. {% endif %}
  93. lineCap: |
  94. {{ leftOneway ? 'butt' : 'round' }}
  95. dashArray: |
  96. {{ leftOneway ? '27,8' : '' }}
  97. dashOffset: |
  98. {{ leftOneway in [-1] ? 28 : 0 }}
  99. noClip: |
  100. {{ leftOneway }}
  101. pattern: |
  102. {% if leftOneway %}arrowHead{% endif %}
  103. pattern-offset: |
  104. {{ leftOneway == -1 ? 4 : 30.5 }}
  105. pattern-lineOffset: -5
  106. pattern-repeat: 35
  107. pattern-polygon: true
  108. pattern-pixelSize: 9
  109. pattern-angleCorrection: |
  110. {{ leftOneway == -1 ? 180 : 0 }}
  111. pattern-path-width: 0
  112. pattern-path-color: |
  113. {% if leftWidth %}
  114. {{ colorInterpolate(const.colorScheme, (leftWidth - minWidth) / (optWidth - minWidth)) }}
  115. {% else %}black
  116. {% endif %}
  117. pattern-path-fillOpacity: 1
  118. style:right:
  119. offset: 5
  120. width: |
  121. {{ rightCycle in ['no', 'separate'] ? 0 : 3 }}
  122. color: |
  123. {% set minWidth = const.minWidthOneway %}
  124. {% set optWidth = const.optWidthOneway %}
  125. {% if rightWidth %}
  126. {{ colorInterpolate(const.colorScheme, (rightWidth - minWidth) / (optWidth - minWidth)) }}
  127. {% else %}black
  128. {% endif %}
  129. lineCap: |
  130. {{ rightOneway ? 'butt' : 'round' }}
  131. dashArray: |
  132. {{ rightOneway ? '27,8' : '' }}
  133. dashOffset: |
  134. {{ rightOneway in [-1] ? 28 : 0 }}
  135. noClip: |
  136. {{ rightOneway }}
  137. pattern: |
  138. {% if rightOneway %}arrowHead{% endif %}
  139. pattern-offset: |
  140. {{ rightOneway == -1 ? 4 : 30.5 }}
  141. pattern-lineOffset: 5
  142. pattern-repeat: 35
  143. pattern-polygon: true
  144. pattern-pixelSize: 9
  145. pattern-angleCorrection: |
  146. {{ rightOneway == -1 ? 180 : 0 }}
  147. pattern-path-width: 0
  148. pattern-path-color: |
  149. {% if rightWidth %}
  150. {{ colorInterpolate(const.colorScheme, (rightWidth - minWidth) / (optWidth - minWidth)) }}
  151. {% else %}black
  152. {% endif %}
  153. pattern-path-fillOpacity: 1
  154. markerSymbol: false
  155. listMarkerSymbol: line
  156. description: |
  157. {{ tagTrans('highway', tags.highway) }}
  158. details: |
  159. {% if not attribute(tags, 'cycleway:width') %}
  160. {% elseif attribute(tags, 'cycleway:width') matches "/'$/" %}
  161. {{ attribute(tags, 'cycleway:width') }}
  162. {% else %}
  163. {{ attribute(tags, 'cycleway:width') }}m
  164. {% endif %}
  165. body: |
  166. <ul>
  167. {% if tags.highway in ['cycleway'] or attribute(tags, 'cycleway:width') %}
  168. <li>
  169. {{ keyTrans('cycleway:width') }}:
  170. {% if not attribute(tags, 'cycleway:width') %}
  171. {{ trans('unknown') }}
  172. {% elseif attribute(tags, 'cycleway:width') matches "/(m|')$/" %}
  173. {{ attribute(tags, 'cycleway:width') }}
  174. {% else %}
  175. {{ attribute(tags, 'cycleway:width') }}m
  176. {% endif %}
  177. </li>
  178. {% endif %}
  179. {% if leftCycle %}
  180. <li>
  181. {{ keyTrans('cycleway:left:width') }}:
  182. {% if not leftWidth %}
  183. {{ trans('unknown') }}
  184. {% elseif attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) matches "/(m|')$/" %}
  185. {{ attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) }}
  186. {% else %}
  187. {{ leftWidth }}m
  188. {% endif %}
  189. </li>
  190. {% endif %}
  191. {% if rightCycle %}
  192. <li>
  193. {{ keyTrans('cycleway:right:width') }}:
  194. {% if not rightWidth %}
  195. {{ trans('unknown') }}
  196. {% elseif attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) matches "/(m|')$/" %}
  197. {{ attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) }}
  198. {% else %}
  199. {{ rightWidth }}m
  200. {% endif %}
  201. </li>
  202. {% endif %}
  203. </ul>
  204. info: |
  205. <table>
  206. <tr>
  207. <th>Symbol</th>
  208. <th>{{ keyTrans('oneway') }}={{ tagTrans('oneway', 'yes') }}</th>
  209. <th>{{ keyTrans('oneway') }}={{ tagTrans('oneway', 'no') }}</th>
  210. </tr>
  211. {% for v in range(0, 1, 0.25) %}
  212. <tr>
  213. <td>
  214. {{ markerLine({ width: 4, color: colorInterpolate(const.colorScheme, v) }) }}
  215. </td>
  216. <td>
  217. {% if v == 0 %}<={% elseif v == 1 %}>={% endif %}
  218. {{ (const.minWidthOneway + (v * (const.optWidthOneway - const.minWidthOneway)))|number_format(2) }}m
  219. </td>
  220. <td>
  221. {% if v == 0 %}<={% elseif v == 1 %}>={% endif %}
  222. {{ (const.minWidthBoth + (v * (const.optWidthBoth - const.minWidthBoth)))|number_format(2) }}m
  223. </td>
  224. </tr>
  225. {% endfor %}
  226. </table>
  227. const:
  228. minWidthBoth: 1.5
  229. optWidthBoth: 5
  230. minWidthOneway: 0.75
  231. optWidthOneway: 3
  232. colorScheme: ['#ff0000', '#ff00ff', '#0000ff']