private bool CalculateTileBBox(int level, int row, int col, out double xmin, out double ymin, out double xmax, out double ymax) { //calculate the bbox bool ret = false; if (level >= 0 && level < _service.DataSource.TilingScheme.LODs.Length) { double resolution = _service.DataSource.TilingScheme.LODs[level].Resolution; PBS.Util.Point origin = _service.DataSource.TilingScheme.TileOrigin; int tileRows = _service.DataSource.TilingScheme.TileRows; int tileCols = _service.DataSource.TilingScheme.TileCols; xmin = origin.X + resolution * tileCols * col; ymin = origin.Y - resolution * tileRows * (row + 1); xmax = origin.X + resolution * tileCols * (col + 1); ymax = origin.Y - resolution * tileRows * row; ret = true; } else { xmin = double.NaN; ymin = double.NaN; xmax = double.NaN; ymax = double.NaN; } return(ret); }
private void CalculateTileBBox(int level, int row, int col, out double xmin, out double ymin, out double xmax, out double ymax) { //calculate the bbox double resolution = _service.DataSource.TilingScheme.LODs[level].Resolution; PBS.Util.Point origin = _service.DataSource.TilingScheme.TileOrigin; int tileRows = _service.DataSource.TilingScheme.TileRows; int tileCols = _service.DataSource.TilingScheme.TileCols; xmin = origin.X + resolution * tileCols * col; ymin = origin.Y - resolution * tileRows * (row + 1); xmax = origin.X + resolution * tileCols * (col + 1); ymax = origin.Y - resolution * tileRows * row; }
/// <summary> /// /// </summary> /// <param name="levels"></param> /// <param name="extent">sr=3857</param> /// <returns></returns> public static long CalculateTileCount(int[] levels, ESRI.ArcGIS.Client.Geometry.Envelope extent) { long total = 0; int constTileSize = 256; LODInfo[] LODs = new LODInfo[20]; const double cornerCoordinate = 20037508.3427892; double resolution = cornerCoordinate * 2 / 256; double scale = 591657527.591555; for (int i = 0; i < LODs.Length; i++) { LODs[i] = new LODInfo() { Resolution = resolution, LevelID = i, Scale = scale }; resolution /= 2; scale /= 2; } PBS.Util.Point TileOrigin = new PBS.Util.Point(-cornerCoordinate, cornerCoordinate); foreach (int level in levels) { LODInfo lod = LODs[level]; double oneTileDistance = lod.Resolution * constTileSize; //calculate start tile and end tile int startTileRow = (int)(Math.Abs(TileOrigin.Y - extent.YMax) / oneTileDistance); int startTileCol = (int)(Math.Abs(TileOrigin.X - extent.XMin) / oneTileDistance); int endTileRow = (int)(Math.Abs(TileOrigin.Y - extent.YMin) / oneTileDistance); int endTileCol = (int)(Math.Abs(TileOrigin.X - extent.XMax) / oneTileDistance); //"startR,startC,endR,endC" total += Math.Abs((endTileCol - startTileCol + 1) * (endTileRow - startTileRow + 1)); } return(total); }