
Hi, I seem to have found a bug in the style file reader - it does not appear to work correctly if the first term is a not equals term. For example, with the following two rules only the latter one correctly triggers: highway!=bus_stop & name~'(?i)ferry terminal' {echotags 'Trigger 1'} name~'(?i)ferry terminal' & highway!=bus_stop {echotags 'Trigger 2'} returning as an example PolygonPOINode generated from 100221082 [amenity=parking, mkgmap:admin_level7=Pembroke Dock, mkgmap:area2poi=true, name=Ferry Terminal] Trigger 2 I think it is failing to match when there is no highway tag at all. If you start with highway!=* as your first term in a rule, the style reader throws it out as not valid with "Cannot start rule with tag!=*" and I think this may be related. Regards, Mike

Hi Mike, I agree that both rules should either produce the same result or the 1st should produce an error message. The current code changes the 1st rule to highway=* & (highway!=.... ) while the 2nd one is changed to name=* & (name~ ... ) I am not sure why the 1st rule is changed like that, I found no hint in the documentation that highway!=something implies highway=* and I think it makes no sense. It would probably be better to treat highway!=something like highway!=* when it appears as first term ? Gerd ________________________________________ Von: mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Mike Baggaley <mike@tvage.co.uk> Gesendet: Donnerstag, 27. Juli 2017 18:53:28 An: mkgmap-dev@lists.mkgmap.org.uk Betreff: [mkgmap-dev] style file reader error Hi, I seem to have found a bug in the style file reader - it does not appear to work correctly if the first term is a not equals term. For example, with the following two rules only the latter one correctly triggers: highway!=bus_stop & name~'(?i)ferry terminal' {echotags 'Trigger 1'} name~'(?i)ferry terminal' & highway!=bus_stop {echotags 'Trigger 2'} returning as an example PolygonPOINode generated from 100221082 [amenity=parking, mkgmap:admin_level7=Pembroke Dock, mkgmap:area2poi=true, name=Ferry Terminal] Trigger 2 I think it is failing to match when there is no highway tag at all. If you start with highway!=* as your first term in a rule, the style reader throws it out as not valid with "Cannot start rule with tag!=*" and I think this may be related. Regards, Mike _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi Mike
Hi, I seem to have found a bug in the style file reader - it does not appear to work correctly if the first term is a not equals term. For example, with the following two rules only the latter one correctly triggers:
highway!=bus_stop & name~'(?i)ferry terminal' {echotags 'Trigger 1'} name~'(?i)ferry terminal' & highway!=bus_stop {echotags 'Trigger 2'}
Yes that is a bug, thanks for reporting it.
I think it is failing to match when there is no highway tag at all. If you start with highway!=* as your first term in a rule, the style reader throws it out as not valid with "Cannot start rule with tag!=*" and I think this may be related.
The rules were more restrictive in the past, and when an error message doesn't make sense it is usually down to a bug, since these things should not happen any more. Although the code does require that an equals or exists terms is first, it is also supposed to re-arrange the expression so that is the case. So your first expression should have been re-written to name=* && name~'(?i)ferry terminal' & highway!=bus_stop There is a second bug, in that having failed to re-arrange it properly it should have then failed with an error. As it turns out there was a test for this, but it was saying that it should be allowed instead of being a failure. The only intended restriction now is that you cannot write a rule that would match an element without any tags at all. The attached patch should fix both these issues. ..Steve

HI Steve, the patch fixes the problem I gave. However, I also found an allied problem that it doesn't fix (I had inadvertently posted this one just to Gerd rather than the list). Rewriting the rules to use the not operator and equals rather than not equals: name~'(?i)ferry terminal' & !(highway=bus_stop) {echotags 'Trigger 3'} - this works fine !(highway=bus_stop) & name~'(?i)ferry terminal' {echotags 'Trigger 4'} - this fails with an error "Invalid rule Expression" (without explaining what the error was) Is it possible to fix this one as well? Thanks, Mike -----Original Message----- From: Steve Ratcliffe [mailto:steve@parabola.me.uk] Sent: 30 July 2017 12:45 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] style file reader error Hi Mike
Hi, I seem to have found a bug in the style file reader - it does not appear to work correctly if the first term is a not equals term. For example, with the following two rules only the latter one correctly triggers:
highway!=bus_stop & name~'(?i)ferry terminal' {echotags 'Trigger 1'} name~'(?i)ferry terminal' & highway!=bus_stop {echotags 'Trigger 2'}
Yes that is a bug, thanks for reporting it.
I think it is failing to match when there is no highway tag at all. If you start with highway!=* as your first term in a rule, the style reader throws it out as not valid with "Cannot start rule with tag!=*" and I think this may be related.
The rules were more restrictive in the past, and when an error message doesn't make sense it is usually down to a bug, since these things should not happen any more. Although the code does require that an equals or exists terms is first, it is also supposed to re-arrange the expression so that is the case. So your first expression should have been re-written to name=* && name~'(?i)ferry terminal' & highway!=bus_stop There is a second bug, in that having failed to re-arrange it properly it should have then failed with an error. As it turns out there was a test for this, but it was saying that it should be allowed instead of being a failure. The only intended restriction now is that you cannot write a rule that would match an element without any tags at all. The attached patch should fix both these issues. ..Steve

Hi Mike
name~'(?i)ferry terminal' & !(highway=bus_stop) {echotags 'Trigger 3'} - this works fine !(highway=bus_stop) & name~'(?i)ferry terminal' {echotags 'Trigger 4'} - this fails with an error "Invalid rule Expression" (without explaining what the error was)
Is it possible to fix this one as well?
Yes I can fix that one in exactly the same way. Patch attached. There are a few cases which use ! that could work but will not. Eg !(highway!=primary) could work as it is the same as highway=primary. Steve

Hi Steve, thanks for the quick response. The patch fixes the second issue, but I have found one more slightly more obscure error. The following statement fails: (((name~'(?i)police' | name~'(?i)police station') & historic:amenity!=police) | name~'(?i)tunnel') & highway!=bus_stop {echotags 'Trigger 5'} The error message says: Invalid rule expression: (((($name~'(?i)police')|($name~'(?i)police station'))&($historic:amenity!=police&$highway!=bus_stop))) It appears to have lost the tunnel clause, presumably something to do with the handling of brackets. This fails both with and without the patch. Regards, Mike -----Original Message----- From: Steve Ratcliffe [mailto:steve@parabola.me.uk] Sent: 31 July 2017 22:55 To: mkgmap-dev@lists.mkgmap.org.uk Subject: Re: [mkgmap-dev] style file reader error Hi Mike
name~'(?i)ferry terminal' & !(highway=bus_stop) {echotags 'Trigger 3'} - this works fine !(highway=bus_stop) & name~'(?i)ferry terminal' {echotags 'Trigger 4'} - this fails with an error "Invalid rule Expression" (without explaining what the error was)
Is it possible to fix this one as well?
Yes I can fix that one in exactly the same way. Patch attached. There are a few cases which use ! that could work but will not. Eg !(highway!=primary) could work as it is the same as highway=primary. Steve

Hi Mike
Hi Steve, thanks for the quick response. The patch fixes the second issue, but I have found one more slightly more obscure error.
The following statement fails: (((name~'(?i)police' | name~'(?i)police station') & historic:amenity!=police) | name~'(?i)tunnel') & highway!=bus_stop {echotags 'Trigger 5'}
Unfortunately as you are using regex a lot, you are going to be finding a lot of these errors. Fortunately I have a solution, but it is a fairly big change so will have to wait for the weekend.
The error message says: Invalid rule expression: (((($name~'(?i)police')|($name~'(?i)police station'))&($historic:amenity!=police&$highway!=bus_stop)))
It appears to have lost the tunnel clause, presumably something to do with the handling of brackets.
The error is just showing the part of the expression that it could not handle, so nothing has been really lost. I'll see if I can get the original rule printed or at least change the message to show that it is just a part of the original rule. Steve
participants (3)
-
Gerd Petermann
-
Mike Baggaley
-
Steve Ratcliffe