Ejemplo n.º 1
0
        /// <summary>
        /// Matches a node with the given parameters against this RenderTheme. </summary>
        ///  <param name="renderCallback">
        ///            the callback implementation which will be executed on each match. </param>
        /// <param name="renderContext"> </param>
        /// <param name="poi">
        ///            the point of interest. </param>
        public virtual void MatchNode(RenderCallback renderCallback, RenderContext renderContext, PointOfInterest poi)
        {
            lock (this)
            {
                MatchingCacheKey matchingCacheKey = new MatchingCacheKey(poi.Tags, renderContext.rendererJob.tile.ZoomLevel, Closed.NO);

                IList <RenderInstruction> matchingList = this.poiMatchingCache.Get(matchingCacheKey);
                if (matchingList != null)
                {
                    // cache hit
                    for (int i = 0, n = matchingList.Count; i < n; ++i)
                    {
                        matchingList[i].RenderNode(renderCallback, renderContext, poi);
                    }
                    return;
                }

                // cache miss
                matchingList = new List <RenderInstruction>();

                for (int i = 0, n = this.rulesList.Count; i < n; ++i)
                {
                    this.rulesList[i].MatchNode(renderCallback, renderContext, matchingList, poi);
                }
                this.poiMatchingCache.Add(matchingCacheKey, matchingList);
            }
        }
Ejemplo n.º 2
0
        private void MatchWay(RenderCallback renderCallback, RenderContext renderContext, Closed closed, PolylineContainer way)
        {
            lock (this)
            {
                MatchingCacheKey matchingCacheKey = new MatchingCacheKey(way.Tags, way.Tile.ZoomLevel, closed);

                IList <RenderInstruction> matchingList = this.wayMatchingCache.Get(matchingCacheKey);
                if (matchingList != null)
                {
                    // cache hit
                    for (int i = 0, n = matchingList.Count; i < n; ++i)
                    {
                        matchingList[i].RenderWay(renderCallback, renderContext, way);
                    }
                    return;
                }

                // cache miss
                matchingList = new List <RenderInstruction>();
                for (int i = 0, n = this.rulesList.Count; i < n; ++i)
                {
                    this.rulesList[i].MatchWay(renderCallback, way, way.Tile, closed, matchingList, renderContext);
                }

                this.wayMatchingCache.Add(matchingCacheKey, matchingList);
            }
        }
Ejemplo n.º 3
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.closed != other.closed)
            {
                return(false);
            }
            if (this.tagsWithoutName == null && other.tagsWithoutName != null)
            {
                return(false);
            }
            else if (!this.tagsWithoutName.Equals(other.tagsWithoutName))
            {
                return(false);
            }
            if (this.zoomLevel != other.zoomLevel)
            {
                return(false);
            }
            return(true);
        }