Class MapCSSRuleIndex


  • public class MapCSSRuleIndex
    extends java.lang.Object
    A collection of MapCSSRules, that are indexed by tag key and value. Speeds up the process of finding all rules that match a certain primitive. Rules with a ConditionFactory.SimpleKeyValueCondition [key=value] or rules that require a specific key to be set are indexed. Now you only need to loop the tags of a primitive to retrieve the possibly matching rules. To use this index, you need to add(MapCSSRule) all rules to it. You then need to call initIndex(). Afterwards, you can use getRuleCandidates(IPrimitive) to get an iterator over all rules that might be applied to that primitive.
    • Method Detail

      • add

        public void add​(MapCSSRule rule)
        Add a rule to this index. This needs to be called before initIndex() is called.
        Parameters:
        rule - The rule to add.
      • initIndex

        public void initIndex()
        Initialize the index.

        You must own the write lock of STYLE_SOURCE_LOCK when calling this method.

      • findAnyRequiredKey

        private static java.lang.String findAnyRequiredKey​(java.util.List<Condition> conds)
        Search for any key that condition might depend on.
        Parameters:
        conds - The conditions to search through.
        Returns:
        An arbitrary key this rule depends on or null if there is no such key.
      • getRuleCandidates

        public java.util.Iterator<MapCSSRulegetRuleCandidates​(IPrimitive osm)
        Get a subset of all rules that might match the primitive. Rules not included in the result are guaranteed to not match this primitive.

        You must have a read lock of STYLE_SOURCE_LOCK when calling this method.

        Parameters:
        osm - the primitive to match
        Returns:
        An iterator over possible rules in the right order.
        Since:
        13810 (signature)
      • clear

        public void clear()
        Clear the index.

        You must own the write lock STYLE_SOURCE_LOCK when calling this method.

      • isEmpty

        public boolean isEmpty()
        Check if this index is empty.
        Returns:
        true if this index is empty.
        Since:
        16784