[mkgmap-dev] Bug Report: First rule matches in style files ... not quite!
From Thilo Hannemann thannema at gmx.de on Mon Apr 20 13:17:53 BST 2009
It says in the documentation that the first rule in the style file that matches the elements is the one used. That is not quite true! The reason is, that the code handles the rules by putting them into baskets organized by the first condition of the rule (with some exceptions). There is for example a basket for all rules with the first condition "highway=residential". When deciding which rule to apply the code will iterate through all the tags of the osm element. It will determine whether there is a corresponding basket and then apply all the rules in that basket in sequence, until one fits. This does work only in simple cases. For example see a way with the following tags: highway=residential rcn=yes This is a residential way that is part of the regional cycle network. (Probably derived by using the "relations" style file to add the tag "rcn=yes" to all ways that are part of an rcn network.) The lines style file will look like -- rcn=yes [ ... some attributes for ways of the cycle network ... ] highway=residential [ ... some other attributes for generic residential roads ... ] -- If the documentation was right the way should always match the first rule (rcn=yes ...). But that is not the case, because it depends on which of the two tags is handled first. This in turn depends on which tag comes first in the osm data. If the tag "rcn=yes" is handled first, the first rule will match, because there is a fitting basket "rcn=yes". This would be according to the documentation. If the tag "highway=residential" is handled first, that rule will (unexpectedly) match, because there is also a fitting basket "highway=residential". To summarize the problem: The baskets are not ordered, therefore the application of the rules is only "until first hit" inside a basket. Between baskets it is "first tag in the osm data that fits". To make matters worse the code also tries to optimize the rules, so that the simple rule "first condition determines basket" does not hold. By inspecting the code it is possible to tweak the rules so that everything works ok, but if somebody can't read the code and tries to build complex style files he will run into serious trouble. Best regards Thilo
- Previous message: [mkgmap-dev] [PATCH] feature/bugfix: allow comments in "overlays" style file
- Next message: [mkgmap-dev] Bug Report: First rule matches in style files ... not quite!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list