logo separator

[mkgmap-dev] Re: Questions related to practical usage of MKGMAP

From Toby Speight T.M.Speight.90 at cantab.net on Thu Jul 2 09:12:25 BST 2009

0> In article <56AA797E-5E8D-477F-B4A1-B2A113F41974 at gmx.de>,
0> Thilo Hannemann <URL:mailto:thannema at gmx.de> ("Thilo") wrote:

Thilo> And finally one patch that you might want to apply: "start-with".
Thilo> This adds a text filter for variable substitution.  You can say
Thilo> for example $ {name|start-with:Hospital }.  This will put the
Thilo> string "Hospital " in front of the name, but only if that string
Thilo> doesn't contain "Hospital" somewhere already.

I like that idea!  A corresponding 'end-with' would be really useful
(certainly in English, where the name usually comes before the function,
e.g. "Strathcarron Station").


Thilo> +   searchPhrase = arg.trim().toLowerCase();
Thilo> + ...
Thilo> +   if (value.toLowerCase().indexOf(searchPhrase) != -1)

That's not the best way to do a case-insensitive test - the reason being
that in some languages (e.g. French, I think) upper case letters have no
accents.  So "Ecole" should match "école" (again, excuse my poor French
if necessary!).  Also, in German, "Straße" should match "STRASSE".

Conversion of both values to uppercase is therefore a better simple
solution.

(I was surprised to find that java.text.Collator doesn't have an indexOf()
method - that's where I'd expect to do locale-dependent matching).

To do it properly, look at java.util.regexp - something like:

/--------
|     searchPattern = Pattern.compile(Pattern.quote(arg.trim()),
|                                     Pattern.UNICODE_CASE | Pattern.CANON_EQ);
| ...
|     if (searchPattern.matcher(value).matches())
\--------



More information about the mkgmap-dev mailing list