|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.me.parabola.mkgmap.osmstyle.RuleIndex
public class RuleIndex
An index to reduce the number of rules that have to be executed.
Only the first term (after rearrangement) of the rule is used in the index. This will (currently) always be an EQUALS or EXISTS (A=B or A=*).
We look at the tags of the element and pick out all rules that have the first term that matches the tag=value and tag=*, this is done by a single lookup for each tag in the element (on average a low number such as 3).
So if the element had the one tag highway=primary and the rules were as follows:
1 surface=good { ... } 2 highway=secondary { set fence=no; } 3 highway=primary { set surface=good; } 4 highway=* & abc=yes { } 5 surface=good { } 6 oneway=yes & highway=primary { }We would select rules 3 and 4. No other rule can match initially. But there is a further issue; if rule 3 matched it could set the surface tag. So we also need to select rule 5. Rule 1 can not be matched because it occurs before the rule that sets the tag, so it is not included. All this is precomputed when the index is created, so we can still do a single lookup.
So the full set of rules that we need to match is 3, 4 and 5. If rule 5 itself sets a tag, then we might have to add more rules and so on.
Constructor Summary | |
---|---|
RuleIndex()
|
Method Summary | |
---|---|
void |
addRuleToIndex(uk.me.parabola.mkgmap.osmstyle.RuleDetails rd)
Save the rule and maintains several lists related to it from the other information that is supplied. |
java.util.List<uk.me.parabola.mkgmap.osmstyle.RuleDetails> |
getRuleDetails()
|
Rule[] |
getRules()
Get all the rules that have been added. |
java.util.List<java.lang.Integer> |
getRulesForTag(java.lang.String tagval)
Get a list of rules that might be matched by this tag. |
void |
prepare()
Prepare the index for use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RuleIndex()
Method Detail |
---|
public void addRuleToIndex(uk.me.parabola.mkgmap.osmstyle.RuleDetails rd)
rd
- Contains 1) the keystring which is the key into the index.
2) the rule itself. 3) a list of the tags that might be changed by
this rule, should it be matched.public Rule[] getRules()
public java.util.List<java.lang.Integer> getRulesForTag(java.lang.String tagval)
tagval
- The tag and its value eg highway=primary.
public void prepare()
public java.util.List<uk.me.parabola.mkgmap.osmstyle.RuleDetails> getRuleDetails()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |