Tricks & Tips: Creating initials from names
More Tricks
Unfortunately, programming for mkgmap can be very frustrating & tiresome with only a very limited amount of commands available.
using echotags: name=North Downs Way (Eastern) network=nwn operator=National Trails p1=N p2=D p3=W part1=North part2=Downs part3=Way part4=(Eastern) ref=NDW* route=hiking type=route |
Often hiking & cycling routes are plotted without a Reference, and so we can't add a shield to the route.
In this section we show you one approach:
There is an added problem in that the name often includes brackets etc, ie
Woodland Cycle Route ( From A to B ) : we certainly don't want to include brackets in a reference.
ie we don't want the above to be shortened to WCR(FATB) !
Infarct we will discard anything between brackets
How to shorten Woodland Cycle Route to WCR
1) Use ' ' to split names into words
2) Use |substring:"0:1" to obtain the first letter of each word
3) if initial letter contains a ( or - then reject this and anything following
The code
(route=foot & ref!=* & operator=* & name!=*{ # look for initials split space set name='${operator}' }
name=* { set name='${name|subst:"-=> "}' } # replacing - with space # not essential but plausible
(route=foot | route=hiking | route=walking) & ref!=* & name=* {
# look for initials split space
add part1='${name|part:" :1"}';
add part2='${name|part:" :2"}';
add part3='${name|part:" :3"}';
add part4='${name|part:" :4"}';
add part5='${name|part:" :5"}';
set done=yes;
}
#five words
route=foot & ref!=* & name=* & part5=* {
add p5='${part5|substring:"0:1"}';
}
#four words
route=foot & ref!=* & name=* & part4=* {
add p4='${part4|substring:"0:1"}';
}
### etc until part1=*
# now delete parts if they contain ( or /
p5='(' |p5='/' {delete p5;}
p4='('|p4='/' {delete p4;}
# etc
# now create refs
p1=* & p2=* & p3=* & p4=* & p5=* {add ref='$(p1)$(p2)$(p3)$(p4)$(p5)' }
p1=* & p2=* & p3=* & p4=* {add ref='$(p1)$(p2)$(p3)$(p4)'; }
p1=* & p2=* & p3=* {add ref='$(p1)$(p2)$(p3)'; }
p1=* & p2=* {add ref='$(p1)$(p2)'; }
p1=* {add ref='${part1|substring:"0:5"}'; }
(route=foot ) & done =yes {
set ref='$(ref)*'; # adding a * to indicate the REF has been auto generated
echotags "auto ref"
}
Next
How to create large town names
Showing contours in different intervals,50,100,150,200 etc