logo separator

[mkgmap-dev] patch to improve style throughput

From Gerd Petermann gpetermann_muenchen at hotmail.com on Mon Apr 30 09:49:21 BST 2018

Hi all,

I think I found a much better solution for the RuleIndex. Attached patch reduces again the number of evaluated rules, but should still evaluates all necessary rules.
The old index still returned too many rules. Let's look at the example that I added as unit test. Set of rules:
0: a=* {set b=1}
1: b=1 {set c=1}
2: d=2 {set c=2}
3: c=* {set a=2}
4: c=1 {set d=2}
5: c=2 {set d=1}
6: d=1 [0x10401 resolution 24]
7: d=2 [0x10402 resolution 24]
Assume we have no index and an element with only one tag a=1. We check each rule:
Rules 0 matches and sets b=1
Now 1 matches and sets c=1
Rule 2 doesn't match.
Rule 3 matches and sets a=2
Rule 4 matches and sets d=2
Rule 5  doesn't match.
Rule 6  doesn't match.
Rule 7  matches.
The index is used to reduce the number of evaluated rules. In the best case it should return rules 0,1,3,4, and 7 for the given element.
But the current code returns all rules because it thinks that rule 4 can set d=2 and therefore rule 2 might be triggered (which is wrong).
The patch changes the index to recognizes the order of the rules which change tags and therefore returns only the needed rules.

I've tested it with different styles and found no problem so far. Means, maps did not change and the patch always was better than trunk or tags4.patch.
A binary based on trunk r4183 is here:

@Steve: Please let me know if you can think of a case that might not work.

If I hear no complains I'll commit this patch next weekend.


Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag von Gerd Petermann <gpetermann_muenchen at hotmail.com>
Gesendet: Samstag, 28. April 2018 09:34:36
An: Development list for mkgmap
Betreff: Re: [mkgmap-dev] patch to improve style throughput

Hi Steve,

after committing the tags3.patch with r4182 yesterday I wondered why I did not find a unit test which shows the problem that I fixed with r3822:

I've now added that test to make sure that the new code works. It does :)
I got curious and tried RuleIndex.java from r3820 and was surprised to find that it alse passes all tests.

In the end the code in RuleIndex was okay, the error was in the code that arranged expressions and you fixed that recently.
The good thing is that the old code was even better than that in tags3.patch, so I've created a new patch which is basically
a revert of the changes in r3822  and r4182.

Please review and try to find a unit test that would not work with that patch.


Von: mkgmap-dev <mkgmap-dev-bounces at lists.mkgmap.org.uk> im Auftrag von Steve Ratcliffe <steve at parabola.me.uk>
Gesendet: Donnerstag, 26. April 2018 23:33:53
An: mkgmap-dev at lists.mkgmap.org.uk
Betreff: Re: [mkgmap-dev] patch to improve style throughput

Hi Gerd

> here is the improved version of the patch. It reduces the number of rules to be checked a bit more.

Thanks, that seems to work well.

mkgmap-dev mailing list
mkgmap-dev at lists.mkgmap.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tags5.patch
Type: application/octet-stream
Size: 11909 bytes
Desc: tags5.patch
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20180430/d76688a0/attachment.obj>

More information about the mkgmap-dev mailing list