예제 #1
0
        /// <summary>
        /// Computes the list of all possible tiles to request
        /// </summary>
        /// <returns></returns>
        public TileRef[] GetTileList()
        {
            var ranges = new TileSetRange[_maxZoomLevel + 1];

            for (int z = 0; z < ranges.Length; z++)
            {
                //Allow floating point drift
                var ll = WorldToTilePos(_ll.X, _ll.Y, z);
                var ur = WorldToTilePos(_ur.X, _ur.Y, z);
                if (_specificZoomLevels.Count == 0 || _specificZoomLevels.Contains(z))
                {
                    var rows = Math.Abs(ur.X - ll.X) + 1;
                    var cols = Math.Abs(ur.Y - ll.Y) + 1;

                    ranges[z] = new TileSetRange(Math.Min(ll.X, ur.X), Math.Min(ll.Y, ur.Y), z, rows, cols);
                }
                else //This zoom level has been omitted
                {
                    ranges[z] = new TileSetRange(z);
                }
            }

            var capacity = ranges.Sum(g => g.Total);
            var tiles    = new TileRef[capacity];
            var current  = 0;

            for (int z = 0; z < ranges.Length; z++)
            {
                var g = ranges[z];
                for (int xi = 0; xi < g.Rows; xi++)
                {
                    for (int yi = 0; yi < g.Cols; yi++)
                    {
                        int x = g.X + xi;
                        int y = g.Y + yi;
                        tiles[current] = new TileRef(string.Empty, x, y, z);
                        current++;
                    }
                }
            }

            return(tiles);
        }
        /// <summary>
        /// Computes the list of all possible tiles to request
        /// </summary>
        /// <returns></returns>
        public TileRef[] GetTileList()
        {
            //Z goes from 0 to 19
            var ranges = new TileSetRange[20];

            for (int z = 0; z < ranges.Length; z++)
            {
                //Allow floating point drift
                var ll = WorldToTilePos(_ll.X, _ll.Y, z);
                var ur = WorldToTilePos(_ur.X, _ur.Y, z);

                var rows = Math.Abs(ur.X - ll.X) + 1;
                var cols = Math.Abs(ur.Y - ll.Y) + 1;

                ranges[z] = new TileSetRange(Math.Min(ll.X, ur.X), Math.Min(ll.Y, ur.Y), z, rows, cols);
            }

            var capacity = ranges.Sum(g => g.Total);
            var tiles    = new TileRef[capacity];
            var current  = 0;

            for (int z = 0; z < ranges.Length; z++)
            {
                var g = ranges[z];
                for (int xi = 0; xi < g.Rows; xi++)
                {
                    for (int yi = 0; yi < g.Cols; yi++)
                    {
                        int x = g.X + xi;
                        int y = g.Y + yi;
                        tiles[current] = new TileRef(string.Empty, x, y, z);
                        current++;
                    }
                }
            }

            return(tiles);
        }