Example #1
0
        public IList <TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
        {
            var tileInfos = new List <TileInfo>();
            // Iterating through all levels from current to zero. If lower levels are
            // not available the renderer can fall back on higher level tiles.
            var resolution = schema.Resolutions[levelId].UnitsPerPixel;
            var levels     = schema.Resolutions.Where(k => k.Value.UnitsPerPixel >= resolution).OrderBy(x => x.Value.UnitsPerPixel).ToList();

            var counter = 0;

            foreach (var level in levels)
            {
                if (counter > _maxLevelsUp)
                {
                    break;
                }

                var tileInfosForLevel = schema.GetTileInfos(extent, level.Key).OrderBy(
                    t => Algorithms.Distance(extent.CenterX, extent.CenterY, t.Extent.CenterX, t.Extent.CenterY));

                tileInfos.AddRange(tileInfosForLevel);
                counter++;
            }

            return(tileInfos);
        }
Example #2
0
        private static void GetRecursive(IDictionary <TileIndex, IFeature> resultTiles, ITileSchema schema,
                                         ITileCache <Feature> cache, Extent extent, IList <KeyValuePair <string, Resolution> > resolutions, int resolutionIndex)
        {
            if (resolutionIndex < 0 || resolutionIndex >= resolutions.Count)
            {
                return;
            }

            var tiles = schema.GetTileInfos(extent, resolutions[resolutionIndex].Key);

            foreach (var tileInfo in tiles)
            {
                var feature = cache.Find(tileInfo.Index);

                if (feature == null)
                {
                    // only continue the recursive search if this tile is within the extent
                    if (tileInfo.Extent.Intersects(extent))
                    {
                        GetRecursive(resultTiles, schema, cache, tileInfo.Extent.Intersect(extent), resolutions, resolutionIndex - 1);
                    }
                }
                else
                {
                    resultTiles[tileInfo.Index] = feature;
                }
            }
        }
        private static void GetRecursive(IDictionary <TileIndex, IFeature> resultTiles, ITileSchema schema,
                                         ITileCache <Feature> cache, Extent extent, IList <KeyValuePair <int, Resolution> > resolutions, int resolutionIndex)
        {
            if (resolutionIndex < 0 || resolutionIndex >= resolutions.Count)
            {
                return;
            }

            var tiles = schema.GetTileInfos(extent, resolutions[resolutionIndex].Key);

            foreach (var tileInfo in tiles)
            {
                var feature = cache.Find(tileInfo.Index);

                // Geometry can be null for some tile sources to indicate the tile is not present.
                // It is stored in the tile cache to prevent retries. It should not be returned to the
                // renderer.
                if (feature?.Geometry == null)
                {
                    // only continue the recursive search if this tile is within the extent
                    if (tileInfo.Extent.Intersects(extent))
                    {
                        GetRecursive(resultTiles, schema, cache, tileInfo.Extent.Intersect(extent), resolutions, resolutionIndex - 1);
                    }
                }
                else
                {
                    resultTiles[tileInfo.Index] = feature;
                }
            }
        }
Example #4
0
        public IList <TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
        {
            IList <TileInfo> infos = new List <TileInfo>();
            // Iterating through all levels from current to zero. If lower levels are
            // not availeble the renderer can fall back on higher level tiles.
            var resolution = schema.Resolutions[levelId].UnitsPerPixel;
            var levels     = schema.Resolutions.Where(k => resolution <= k.Value.UnitsPerPixel).OrderByDescending(x => x.Value.UnitsPerPixel);

            //var levelCount = levels.Count();
            foreach (var level in levels)
            {
                var tileInfos = schema.GetTileInfos(extent, level.Key);
                tileInfos = SortByPriority(tileInfos, extent.CenterX, extent.CenterY);

                //var count = infosOfLevel.Count();
                foreach (var info in tileInfos)
                {
                    if ((info.Index.Row >= 0) && (info.Index.Col >= 0))
                    {
                        infos.Add(info);
                    }
                }
            }

            return(infos);
        }
Example #5
0
        private static void GetRecursive(IDictionary<TileIndex, IFeature> resultTiles, ITileSchema schema,
            ITileCache<Feature> cache, Extent extent, IList<KeyValuePair<string, Resolution>> resolutions, int resolutionIndex)
        {
            if (resolutionIndex < 0 || resolutionIndex >= resolutions.Count)
                return;

            var tiles = schema.GetTileInfos(extent, resolutions[resolutionIndex].Key);

            foreach (var tileInfo in tiles)
            {
                var feature = cache.Find(tileInfo.Index);

                if (feature == null)
                {
                    // only continue the recursive search if this tile is within the extent
                    if (tileInfo.Extent.Intersects(extent))
                    {
                        GetRecursive(resultTiles, schema, cache, tileInfo.Extent.Intersect(extent), resolutions, resolutionIndex - 1);
                    }
                }
                else
                {
                    resultTiles[tileInfo.Index] = feature;
                }
            }
        }
Example #6
0
        public static void SelectRecursive(IDictionary <TileIndex, Tile <T> > selection, ITileCache <Tile <T> > cache,
                                           ITileSchema schema, Extent extent, int level)
        {
            var unitsPerPixel = schema.Resolutions[level].UnitsPerPixel;
            var tiles         = schema.GetTileInfos(extent, unitsPerPixel);

            foreach (var tileInfo in tiles)
            {
                var tile = cache.Find(tileInfo.Index);

                var nextLevelId = schema.Resolutions.Where(r => r.Value.UnitsPerPixel > unitsPerPixel)
                                  .OrderBy(r => r.Value.UnitsPerPixel).FirstOrDefault().Key;

                if (tile == null)
                {
                    SelectRecursive(selection, cache, schema, tileInfo.Extent.Intersect(extent), nextLevelId);
                }
                else
                {
                    selection[tileInfo.Index] = tile;
                    // If a tile is still semi transparent then select the higher level to show underneath the
                    // semi transparent one.
                    if (IsSemiTransparent(tile))
                    {
                        SelectRecursive(selection, cache, schema, tileInfo.Extent.Intersect(extent), nextLevelId);
                    }
                }
            }
        }
        public IList<IFeature> GetFeatures(BoundingBox box, double resolution, ITileSchema schema, ITileCache<Feature> memoryCache)
        {
            var tiles = schema.GetTileInfos(box.ToExtent(), resolution);
            var result = new List<IFeature>();
            foreach (var tileInfo in tiles)
            {
                var feature = memoryCache.Find(tileInfo.Index);

                if (feature != null)
                {
                    result.Add(feature);
                }
            }
            return result;
        }
        public IList <IFeature> GetFeatures(BoundingBox extent, double resolution, ITileSchema schema, ITileCache <Feature> memoryCache)
        {
            var tiles  = schema.GetTileInfos(extent.ToExtent(), resolution);
            var result = new List <IFeature>();

            foreach (var tileInfo in tiles)
            {
                var feature = memoryCache.Find(tileInfo.Index);

                if (feature != null)
                {
                    result.Add(feature);
                }
            }
            return(result);
        }
Example #9
0
        private static void GetRecursiveTiles(IDictionary <TileIndex, Tuple <TileInfo, Stream> > resultTiles, ITileSchema schema, ITileCache <Stream> bitmaps,
                                              FileCache cache, Extent extent, IList <KeyValuePair <string, Resolution> > resolutions, int resolutionIndex)
        {
            if (resolutionIndex < 0 || resolutionIndex >= resolutions.Count)
            {
                return;
            }
            var tiles = schema.GetTileInfos(extent, resolutions[resolutionIndex].Key);

            foreach (var tileInfo in tiles)
            {
                var feature = bitmaps.Find(tileInfo.Index);

                if (feature != null)
                {
                    resultTiles[tileInfo.Index] = new Tuple <TileInfo, Stream>(tileInfo, feature);
                }
                else
                {
                    byte[] cachedImg = null;
                    if (cache != null)
                    {
                        //Find in file cache.
                        cachedImg = cache.Find(tileInfo.Index);
                    }

                    if (cachedImg != null)
                    {
                        var stream = new MemoryStream(cachedImg);
                        bitmaps.Add(tileInfo.Index, stream);
                        resultTiles[tileInfo.Index] = new Tuple <TileInfo, Stream>(tileInfo, stream);
                    }
                    else
                    {
                        // only continue the recursive search if this tile is within the extent
                        if (tileInfo.Extent.Intersects(extent))
                        {
                            GetRecursiveTiles(resultTiles, schema, bitmaps, cache, tileInfo.Extent.Intersect(extent), resolutions, resolutionIndex - 1);
                        }
                    }
                }
            }
        }
Example #10
0
        public IList <TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
        {
            var infos = new List <TileInfo>();
            // Iterating through all levels from current to zero. If lower levels are
            // not available the renderer can fall back on higher level tiles.
            var resolution = schema.Resolutions[levelId].UnitsPerPixel;
            var levels     = schema.Resolutions.Where(k => k.Value.UnitsPerPixel >= resolution).OrderBy(x => x.Value.UnitsPerPixel).ToList();

            foreach (var level in levels)
            {
                var tileInfos = schema.GetTileInfos(extent, level.Key).OrderBy(
                    t => Algorithms.Distance(extent.CenterX, extent.CenterY, t.Extent.CenterX, t.Extent.CenterY));

                foreach (TileInfo info in tileInfos.Where(info => (info.Index.Row >= 0) && (info.Index.Col >= 0)))
                {
                    infos.Add(info);
                }
            }

            return(infos);
        }
Example #11
0
        public IList<TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
        {
            var infos = new List<TileInfo>();
            // Iterating through all levels from current to zero. If lower levels are
            // not available the renderer can fall back on higher level tiles.
            var resolution = schema.Resolutions[levelId].UnitsPerPixel;
            var levels = schema.Resolutions.Where(k => k.Value.UnitsPerPixel >= resolution).OrderBy(x => x.Value.UnitsPerPixel).ToList();

            foreach (var level in levels)
            {
                var tileInfos = schema.GetTileInfos(extent, level.Key).OrderBy(
                    t => Algorithms.Distance(extent.CenterX, extent.CenterY, t.Extent.CenterX, t.Extent.CenterY));

                foreach (TileInfo info in tileInfos.Where(info => (info.Index.Row >= 0) && (info.Index.Col >= 0)))
                {
                    infos.Add(info);
                }
            }

            return infos;
        }
Example #12
0
        public IList<TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
        {
            IList<TileInfo> infos = new List<TileInfo>();
            // Iterating through all levels from current to zero. If lower levels are
            // not availeble the renderer can fall back on higher level tiles.
            var unitsPerPixel = schema.Resolutions[levelId].UnitsPerPixel;
            var levels = schema.Resolutions.Where(k => unitsPerPixel <= k.Value.UnitsPerPixel).OrderByDescending(x => x.Value.UnitsPerPixel);

            //var levelCount = levels.Count();
            foreach (var level in levels)
            {
                var tileInfos = schema.GetTileInfos(extent, level.Key);
                tileInfos = SortByPriority(tileInfos, extent.CenterX, extent.CenterY);

                //var count = infosOfLevel.Count();
                foreach (var info in tileInfos)
                {
                    if ((info.Index.Row >= 0) && (info.Index.Col >= 0)) infos.Add(info);
                }
            }

            return infos;
        }
Example #13
0
 public IList <TileInfo> Get(ITileSchema schema, Extent extent, int level)
 {
     return(schema.GetTileInfos(extent, level).OrderBy(
                t => Algorithms.Distance(extent.CenterX, extent.CenterY, t.Extent.CenterX, t.Extent.CenterY)).ToList());
 }
Example #14
0
 public IList <TileInfo> GetTilesWanted(ITileSchema schema, Extent extent, string levelId)
 {
     return(schema.GetTileInfos(extent, (levelId)).ToList());
 }