[mkgmap-dev] name include file
From Marko Mäkelä marko.makela at iki.fi on Sat Oct 5 21:03:30 BST 2013
On Wed, Sep 25, 2013 at 02:25:51PM +0100, Steve Ratcliffe wrote: >> I often get names like >> "Shell: Shell (Shell)" for fuel stations. The same happens to >> restaurants, supermarkets, etc. >> The tags name, operator and brand are often the same so I think they >> should not all be used in the POI name. >> >> Any suggestions for improvement? > >The not-equal filter was designed for such cases I think, or >could be modified to fit. > > http://www.mkgmap.org.uk/pipermail/mkgmap-dev/2009q4/005333.html I just tried the following approach, but the ${var} is apparently not being expanded before it is evaluated as a regular expression: Index: resources/styles/default/inc/name =================================================================== --- resources/styles/default/inc/name (revision 2737) +++ resources/styles/default/inc/name (working copy) @@ -1,9 +1,18 @@ # Rules for naming objects, based on the following tags: # name, brand, operator, ref +# Name similar to ref: remove it +ref=* & name ~ '${ref}' { delete name } + # None of operator, brand given ref=* & (operator!=* & brand!=*) { name '${ref} ${name}' | '${ref}' } +# Brand similar to operator or name: remove it +name=* & brand ~ '${name}' { delete brand } +operator=* & brand ~ '${operator}' { delete brand } +# Operator similar to name: remove it +name=* & operator ~ '${name}' { delete operator } + # Both operator and brand given operator=* & brand=* { name '${brand}: ${ref} ${name} (${operator})' | No matter if I write name ~ "${ref}" or name ~ '${ref}', I will get the following exception, due to misuse of the regexp metacharacters $ or {}: ---- java.util.regex.PatternSyntaxException: Illegal repetition near index 0 ${ref} ^ at java.util.regex.Pattern.error(Pattern.java:1924) at java.util.regex.Pattern.closure(Pattern.java:3104) at java.util.regex.Pattern.sequence(Pattern.java:2101) at java.util.regex.Pattern.expr(Pattern.java:1964) at java.util.regex.Pattern.compile(Pattern.java:1665) at java.util.regex.Pattern.<init>(Pattern.java:1337) at java.util.regex.Pattern.compile(Pattern.java:1022) at uk.me.parabola.mkgmap.osmstyle.eval.RegexOp.setSecond(RegexOp.java:51) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.runOp(ExpressionReader.java:158) at uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader.readConditions(ExpressionReader.java:63) --- In reality, I would not necessarily want a full-blown regexp. If I wanted that, I would want any regexp metacharacters in the variable substitution to be escaped, as with the Perl "\Q${var}\E". I guess that a substring match could suffice. We want to omit a key (name,brand,operator,ref) if it is a substring of (or equal to) another one: >bank=atm, brand='Otto.', operator=Otto Here, ${operator} should simply be deleted, because it is a substring of ${brand}. >amenity=restaurant, brand='Abc!', name='Abc Deli' >amenity=car_wash, brand='Abc!', name='Abc Car Wash' (Also this is a real example; 'Abc!' is a Finnish fuel station chain.) The keys are not substrings of each other, unless we ignore the exclamation point at the end of ${brand}. So, we want some sort of partial substring match. I guess we would also want a word match, so that the keys will be preserved in the following (artificial) examples: >shop=computer, brand='DG', name='Cambridge Minicomputers' >shop=clothes, brand='Yo', name='York Youth Apparel' Even though ${brand} is a substring of ${name}, it should be preserved, no matter if it is in the middle of a word or at the start of a word. I guess that this could be implemented by extending the RegexOp syntax so that it would allow variable substitutions and string function substitutions in the regular expression string. Any simpler ideas? Implement a new style function or operator for the substring match predicate? Best regards, Marko
- Previous message: [mkgmap-dev] point outside map area
- Next message: [mkgmap-dev] Commit: r2738: Drop points that lie outside of tile boundaries without producing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list