logo separator

[mkgmap-dev] Enhancement on SubstitutionFilter.java to handle regexp (filter "subst:")

From Enrico Liboni eliboni at gmail.com on Tue Aug 13 22:46:35 BST 2013

WanMil, Steve, attached the updated rules-filters.txt (and the
correspondent html version w/ asciidoc).

Thanks for committing this change as well!

Enrico



On Tue, Aug 13, 2013 at 12:24 PM, WanMil <wmgcnfg at web.de> wrote:

> Hi Enrico,
>
> thanks for your contributions! I am sure Steve will commit the
> PartFilter patch soon (I was not yet able to test it).
>
> It would be great if you could add some documentation to the mkgmap
> (official) documentation (not the wiki).
> Your parts are documented in the rules.txt file:
>
> http://www.mkgmap.org.uk/websvn/listing.php?repname=mkgmap&path=%2Ftrunk%2Fdoc%2Fstyles%2F&#ac8732844627e5545690d79e215f71dba
>
> The format is asciidoc (http://powerman.name/doc/asciidoc).
>
> Thanks!
> WanMil
>
> > Glad to hear this! Did you test also the PartFilter one?
> >
> > Enrico
> >
> >
> > On Sun, Aug 11, 2013 at 8:38 PM, Carlos Dávila <cdavilam at orangecorreo.es
> > <mailto:cdavilam at orangecorreo.es>> wrote:
> >
> >     I have just started to use the new SubstitutionFilter. It's saving a
> lot
> >     of code, checks for errors, etc. Thanks a lot Enrico.
> >     _______________________________________________
> >     mkgmap-dev mailing list
> >     mkgmap-dev at lists.mkgmap.org.uk <mailto:
> mkgmap-dev at lists.mkgmap.org.uk>
> >     http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> >
> >
> >
> >
> > _______________________________________________
> > mkgmap-dev mailing list
> > mkgmap-dev at lists.mkgmap.org.uk
> > http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
> >
>
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev at lists.mkgmap.org.uk
> http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20130813/c3f7f0c2/attachment-0002.html 
-------------- next part --------------
//
// This is the list of variable filters.
//
.List of all substitution filters
[width="100%",grid="rows",cols="<1,<1,3a",options="header"]
|=======
| Name | Arguments | Description
| def | `default` |
If the variable is not set, then use the argument as a default value.
This means that the variable will never be `unset' in places where that
matters. 

`${oneway\|def:no}`

| conv | `factor` |
Use for conversions between units. The only supported version is from meters to feet
number. It is multiplied by the argument.

`${height\|conv:m=>ft}`

| subst | `from=>to` +
`from~>to`|
Substitutes all occurrences of the string +from+ with the string +to+ in
the tag value. The +`=>`+ operator can be used for an exact matches while +`~>`+ accepts
regular expressions in the +from+ attribute.

+to+ can be empty to remove the +from+ string altogether.

Example, if name ="Queen Street" 

`${name\|subst:Queen=>}` returns " Street" 

`${name\|subst:Queen=>King}` returns "King Street" 

`${name\|subst:.*\s~>}` returns "Street" 

| part | `separator operator partnumber` |
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

If not specified, the default separator is ';' and the first part is returned (i.e. `${name\|part:}`=`${name\|part:;:1}`).

If the operator is `:` the part specified by +partnumber+ is returned.

If the operator is `<` or `>` the correspondent number of parts before or after the +partnumber+ are returned

Example: if the value is "Aa#Bb#Cc#Dd#Ee"

`${name\|part:#:1}`  returns Aa

`${name\|part:#:-1}` returns Ee

`${name\|part:#:2}`  returns Bb

`${name\|part:#:-2}` returns Dd

`${name\|part:#>1}`  returns Bb#Cc#Dd#Ee#

`${name\|part:#<5}`  returns Aa#Bb#Cc#Dd#

`${name\|part:#<-1}` returns Aa#Bb#Cc#Dd#

This can be especially useful for tags like ref, exit_to and destination or to switch words, 
example if value is "word1 word2 ... wordN-1 wordN"

`${name\|part: :-1}, ${name\|part: <-1}` returns "wordN, word1 word2 ... wordN-1 "

| highway-symbol | `symbol:max-num:max-alpha` |
Prepares the value as a highway reference such as "A21" "I-80" and so
on.
A code is added to the front of the string so that a highway shield is
displayed, spaces are removed and the text is truncated so as not to overflow the
symbol.

`${ref\|highway-symbol:box:4:8}`

See below for a list of the +highway-symbol+ values.

The first number is the maximum number of characters to allow for
references that contain numbers and letters.
The second is the maximum length of references that do not contain numbers.
If there is just the one number then it is used in both cases.

| height | `m=>ft` |
This is the same as the +conv+ filter, except that it prepends a special
separation character before the value which is intended for elevations.
As with +conv+ the only supported conversion currently is from meters to feet.

`${ele\|m=>ft}`

| not-equal | `tag` |
Used to check for duplicate tags. If the value of this tag is equal to
the value of the tag named as the argument to +not-equal+, then value
of this tag is set to undefined.

....
place=* {
   name '${name} (${int_name\|not-equal:name})'
       \| '${name}'
   }
....

In that example, if the international name is different to the name then it will be placed
in parenthesis after the name. Otherwise there will just be the name as given in the "name" tag.

| substring | `start:end` |
Extract part of the string. The start and end positions
are counted starting from zero and the end position is not included.

`${name\|2:5}`
If the "name" was "Dorset Lane", then the result is "rse".  If there is just the one number,
then the substring starts from that character until the end of the string.
|=====

=== Symbol codes
Here is a list of all the symbols that can be created with images to give an
idea of where they should be used.
The actual symbol will depend on the device that it is displayed on.

.Highway symbol codes
[width="60%",cols="1,1,2",options="header"]
|=====
| Shield name | Symbol | Description
| interstate | image:img/sym-interstate.png[] | US Interstate, digits only
| shield  | image:img/sym-shield.png[]        | US Highway shield, digits only
| round   | image:img/sym-round.png[]         | US Highway round, digits only
| hbox    | image:img/sym-hbox.png[]          | Box for major roads
| box     | image:img/sym-box.png[]           | Box for medium roads
| oval    | image:img/sym-oval.png[]          | Box for smaller roads
|====


////
| prefix | symbol code |
hello
| `${ref\|prefix:box}`
////
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20130813/c3f7f0c2/attachment-0003.html 


More information about the mkgmap-dev mailing list