Exemplo n.º 1
0
        public void Match(MapElement mapElement)          // ( RenderCallback renderCallback, List<Tag> tags, byte zoomLevel )
        {
            MatchingCacheKey matchingCacheKey = new MatchingCacheKey(mapElement.Tags, mapElement.Tile.ZoomFactor);

            List <RenderInstruction> matchingList;

            if (this.matchingCache.TryGetValue(matchingCacheKey, out matchingList))
            {
                // cache hit
                for (int i = 0, n = matchingList.Count; i < n; ++i)
                {
                    mapElement.RenderInstructions.AddRange(matchingList);
                }
                return;
            }

            // cache miss
            matchingList = new List <RenderInstruction>();
            for (int i = 0, n = this.rulesList.Count; i < n; ++i)
            {
                this.rulesList[i].Match(mapElement);
            }

            this.matchingCache[matchingCacheKey] = matchingList;
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            else if (!(obj is MatchingCacheKey))
            {
                return(false);
            }
            MatchingCacheKey other = (MatchingCacheKey)obj;

            if (this.tags == null)
            {
                if (other.tags != null)
                {
                    return(false);
                }
            }
            else if (!this.tags.Equals(other.tags))
            {
                return(false);
            }
            if (this.zoomLevel != other.zoomLevel)
            {
                return(false);
            }
            return(true);
        }