| 1 |
// |
| 2 |
// This is the list of variable filters. |
| 3 |
// |
| 4 |
.List of all substitution filters |
| 5 |
[width="100%",grid="rows",cols="<1,<1,4a",options="header"] |
| 6 |
|======= |
| 7 |
| Name | Arguments | Description |
| 8 |
| def | `default` | |
| 9 |
If the variable is not set, then use the argument as a default value. |
| 10 |
This means that the variable will never be `unset' in places where that |
| 11 |
matters. |
| 12 |
|
| 13 |
`${oneway\|def:"no"}` |
| 14 |
|
| 15 |
| conv | `m=>ft` | |
| 16 |
Use for conversions between units. |
| 17 |
With the argument +m\=\>ft+ the value is converted into feet, with the |
| 18 |
value being assumed to be in meters, unless the value includes a unit |
| 19 |
already. |
| 20 |
If any of the units are not recognised then the value is unchanged. |
| 21 |
|
| 22 |
`${height\|conv:"m=>ft"}` |
| 23 |
|
| 24 |
So if +height+ is 10, then the result is 33, and if +height+ is 10ft, |
| 25 |
then the result is 10, as it is already in feet. |
| 26 |
|
| 27 |
The possible units are: |
| 28 |
|
| 29 |
* Length: m, km, ft (feet), feet, mi (miles). |
| 30 |
* Speed: mph, km/h (or kmh, kmph), knots |
| 31 |
* Weight: t, kg, lb (or lbs) |
| 32 |
|
| 33 |
| subst | `from=>to` + |
| 34 |
`from~>to`| |
| 35 |
Substitutes all occurrences of the string +from+ with the string +to+ in |
| 36 |
the tag value. The +`=>`+ operator can be used for an exact matches while +`~>`+ accepts |
| 37 |
regular expressions in the +from+ attribute. |
| 38 |
|
| 39 |
+to+ can be empty to remove the +from+ string altogether. |
| 40 |
|
| 41 |
Example, if name ="Queen Street" |
| 42 |
|
| 43 |
`${name\|subst:"Queen=>"}` returns " Street" |
| 44 |
|
| 45 |
`${name\|subst:"Queen=>King"}` returns "King Street" |
| 46 |
|
| 47 |
`${name\|subst:".*\s~>"}` returns "Street" |
| 48 |
|
| 49 |
| part | `separator operator partnumber` | |
| 50 |
Split a value in parts and returns one or more part(s) of it. If +partnumber+ is negative, the part returned is counted from the end of the split |
| 51 |
|
| 52 |
If not specified, the default separator is ';' and the first part is returned (i.e. `${name\|part:""}`=`${name\|part:";:1"}`). |
| 53 |
|
| 54 |
If the operator is `:` the part specified by +partnumber+ is returned. |
| 55 |
|
| 56 |
If the operator is `<` or `>` the correspondent number of parts before or after the +partnumber+ are returned |
| 57 |
|
| 58 |
Example: if the value is "Aa#Bb#Cc#Dd#Ee" |
| 59 |
|
| 60 |
`${name\|part:"#:1"}` returns Aa |
| 61 |
|
| 62 |
`${name\|part:"#:-1"}` returns Ee |
| 63 |
|
| 64 |
`${name\|part:"#:2"}` returns Bb |
| 65 |
|
| 66 |
`${name\|part:"#:-2"}` returns Dd |
| 67 |
|
| 68 |
`${name\|part:"#>1"}` returns Bb#Cc#Dd#Ee# |
| 69 |
|
| 70 |
`${name\|part:"#<5"}` returns Aa#Bb#Cc#Dd# |
| 71 |
|
| 72 |
`${name\|part:"#<-1"}` returns Aa#Bb#Cc#Dd# |
| 73 |
|
| 74 |
This can be especially useful for tags like ref, exit_to and destination or to switch words, |
| 75 |
example if value is "word1 word2 ... wordN-1 wordN" |
| 76 |
|
| 77 |
`${name\|part:" :-1"}, ${name\|part:" <-1"}` returns "wordN, word1 word2 ... wordN-1 " |
| 78 |
|
| 79 |
| highway-symbol | `symbol:max-num:max-alpha` | |
| 80 |
Prepares the value as a highway reference such as "A21" "I-80" and so |
| 81 |
on. |
| 82 |
A code is added to the front of the string so that a highway shield is |
| 83 |
displayed, any ";" are replaced by "/" and spaces are removed. |
| 84 |
|
| 85 |
`${ref\|highway-symbol:"box:4:8"}` |
| 86 |
|
| 87 |
See below for a list of the +highway-symbol+ values. |
| 88 |
|
| 89 |
The first number is the maximum number of characters to allow for |
| 90 |
references that contain numbers and letters. |
| 91 |
The second is the maximum length of references that do not contain numbers. |
| 92 |
If there is just the one number then it is used in both cases. |
| 93 |
If no numbers are given, the default value 8 is used. |
| 94 |
|
| 95 |
If the reference, after spaces have been removed, is longer than the maximum length |
| 96 |
then the filter passes the string onwards unchanged; the highway-symbol is not prepended. |
| 97 |
|
| 98 |
| height | `m=>ft` | |
| 99 |
This is exactly the same as the +conv+ filter, except that it prepends a special |
| 100 |
separation character before the value which is intended for elevations so that |
| 101 |
the Garmin software can convert it to the unit configured by the user. |
| 102 |
If no argument is given the default is `m=>ft`, else the target unit |
| 103 |
must be ft (foot). |
| 104 |
|
| 105 |
`${ele\|height:"m=>ft"}` |
| 106 |
|
| 107 |
| country-ISO | | |
| 108 |
Use to normalize country names to the 3 character ISO 1366 code. |
| 109 |
The filter has no arguments. It uses the list in LocatorConfig.xml. |
| 110 |
Possible inputs are country names, or ISO codes in 2 or 3 characters, |
| 111 |
for example "Deutschland", "Germany", "Bundesrepublik Deutschland", or "DE" |
| 112 |
will all return "DEU", also different cases like "GERMANY" or " germany " |
| 113 |
will work. |
| 114 |
|
| 115 |
If the value is not found in the list, then the value is unchanged. |
| 116 |
|
| 117 |
| not-equal | `tag` | |
| 118 |
Used to check for duplicate tags. If the value of this tag is equal to |
| 119 |
the value of the tag named as the argument to +not-equal+, then value |
| 120 |
of this tag is set to undefined. |
| 121 |
|
| 122 |
.... |
| 123 |
place=* { |
| 124 |
name '${name} (${int_name\|not-equal:"name"})' |
| 125 |
\| '${name}' |
| 126 |
} |
| 127 |
.... |
| 128 |
|
| 129 |
In that example, if the international name is different to the name then it will be placed |
| 130 |
in parenthesis after the name. Otherwise there will just be the name as given in the "name" tag. |
| 131 |
|
| 132 |
| substring | `start:end` | |
| 133 |
Extract part of the string. The start and end positions |
| 134 |
are counted starting from zero and the end position is not included. |
| 135 |
|
| 136 |
`${name\|substring:"2:5"}` |
| 137 |
If the "name" was "Dorset Lane", then the result is "rse". If there is just the one number, |
| 138 |
then the substring starts from that character until the end of the string. |
| 139 |
|
| 140 |
| not-contained | `separator:tag` | |
| 141 |
Used to check for duplicate values. If the value of this tag is contained in the list being |
| 142 |
the value of the tag named as the argument to +not-contained+, then value |
| 143 |
of this tag is set to undefined. |
| 144 |
|
| 145 |
.... |
| 146 |
type=route & route=bus & ref=* { |
| 147 |
apply { |
| 148 |
set route_ref= |
| 149 |
'$(route_ref),${ref\|not-contained:",:route_ref"}' |
| 150 |
\| '$(route_ref)' \| '${ref}'; |
| 151 |
} |
| 152 |
} |
| 153 |
.... |
| 154 |
|
| 155 |
Here, +ref+ value is only added to +route_ref+ when it is not already contained in that list |
| 156 |
(with separator ','). Otherwise, the value of +route_ref+ is unchanged. |
| 157 |
This helps to get correct labeling (no duplicates) for public transport lines where there can be multiple relations |
| 158 |
with the same +ref+ attribute (e.g. one for the forward and one for the backward direction). |
| 159 |
|
| 160 |
For example, if +route_ref+ was already "1,2,150" and +ref+ would again be "150", |
| 161 |
this value would not be added to the list as it is already there. |
| 162 |
In contrast, +ref+ equal to "229" would be added, so after that +route_ref+ would have the value "1,2,150,229" |
| 163 |
|===== |
| 164 |
|
| 165 |
=== Symbol codes |
| 166 |
Here is a list of all the symbols that can be created with images to give an |
| 167 |
idea of where they should be used. |
| 168 |
The actual symbol will depend on the device that it is displayed on. |
| 169 |
|
| 170 |
.Highway symbol codes |
| 171 |
[width="60%",cols="1,1,2",options="header"] |
| 172 |
|===== |
| 173 |
| Shield name | Symbol | Description |
| 174 |
| interstate | image:img/sym-interstate.png[] | US Interstate, digits only |
| 175 |
| shield | image:img/sym-shield.png[] | US Highway shield, digits only |
| 176 |
| round | image:img/sym-round.png[] | US Highway round, digits only |
| 177 |
| hbox | image:img/sym-hbox.png[] | Box for major roads |
| 178 |
| box | image:img/sym-box.png[] | Box for medium roads |
| 179 |
| oval | image:img/sym-oval.png[] | Box for smaller roads |
| 180 |
|==== |
| 181 |
|