logo separator

[mkgmap-dev] How to display U. S. highway shields with numbers only

From GerdP gpetermann_muenchen at hotmail.com on Sun Jan 4 09:49:10 GMT 2015

Hi Mark,

mkgmap uses the String.replaceAll() method 
when subst is used with a regular expression.
Here is the link to the Oracle docu which also 
contains a link to regular expressions.

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29

regex:
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#sum

Gerd
 

Mark Bradley-2 wrote
> Gerd,
> 
>  
> 
> Thanks for the followup.  Somehow I overlooked the Substitution filter
> that
> you suggest, which seems like a good idea.  It looks like your idea also
> involves an Oracle Regex expression, with which I am not familiar.  I
> thought about that, but the URL in the Conversion Style Manual for the
> Regex
> documentation is no longer correct.  (Can someone on this mailing list see
> that it is corrected?)  After a little searching on the Java website, I
> did
> not find the documentation, and did not want to take a lot of time
> looking,
> so I tried a different tack.  After much thought, I came up with a series
> of
> commands that seems to produce the desired output.  However, it looks like
> the idea of using the Substitution filter might produce a more elegant
> solution.  I will probably look into that.
> 
>  
> 
> Anyway, here is the sequence of commands I came up with that seemed to
> work.
> (I live in Indiana.)  I have only included the commands that pertain to U.
> S. and state highways.  The motorways (interstates) were more
> straightforward and a lot easier, because their ref values are much more
> consistent.  The problem I had to overcome with the other highways is that
> the number of characters in the ref key value can vary, from none, to one
> or
> more.
> 
>  
> 
> # Append extra characters to the end of the ref value to ensure it is more
> than one character in length, otherwise an error will be returned by the
> Substring filter later.
> 
> # ("AB" are dummy characters.)
> 
> highway = * & ref = * { set ref = '$(ref) AB' }
> 
>  
> 
> # Create the letter_ref key that will determine later what type of symbol
> to
> display on the highway.
> 
> highway = * & ref = * { set letter_ref = '$(ref|substring:0:2)' }
> 
>  
> 
> # Extract the numbers only from the ref value, which will become the
> numbers
> inside the symbols.
> 
> highway = * & ref = * { set number_ref = '$(ref|part:" :-2)' }
> 
>  
> 
> #If the highway is a U. S. highway, use a shield symbol.
> 
> letter_ref = 'US' {name '${number_ref|highway-symbol:shield:3} ${name}' |
> '${number_ref|highway-symbol:shield:3}' | '${name}'; addlabel '${name}
> (${ref})' }
> 
>  
> 
> # If the highway is a state highway, use a round symbol.
> 
> letter_ref = 'SR' | letter_ref = 'IN' {name
> '${number_ref|highway-symbol:round:3} ${name}' |
> '${number_ref|highway-symbol:round:3}' | '${name}'; addlabel '${name}
> (${ref})' }
> 
>  
> 
> _____________________________________________
> 
>  
> 
> Hi Mark,
> 
>  
> 
> okay, so your problem is not directly related to the highway symbols.
> 
> What you need is a simple filter to return the part of a string which
> starts
> at the first digit. I guess this can be done with subst plus a regular
> expression, but I'm not sure how exactly.
> 
> Something like
> 
> ref=* {set my_ref = ${ref|subst:"[a-zA-Z]*~>"}
> 
>  
> 
>  
> 
> Gerd
> 
>  
> 
> 
> _______________________________________________
> mkgmap-dev mailing list

> mkgmap-dev at .org

> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev





--
View this message in context: http://gis.19327.n5.nabble.com/How-to-display-U-S-highway-shields-with-numbers-only-tp5828938p5828949.html
Sent from the Mkgmap Development mailing list archive at Nabble.com.


More information about the mkgmap-dev mailing list