//Chesk Tiles public string CheckTiles(string pathToCacheRoot, TileCheckMode mode) { var zooms = Directory.EnumerateDirectories(pathToCacheRoot + @"\_alllayers\"); List <Task <string> > checkList = new List <Task <string> >(); this.check_mode = mode; DropMask(this.mask_name); foreach (string z in zooms) { //if(this.level_tbx.Text!="") //{ // var zoom = int.Parse(z.Substring(z.Length-2,2)); // var l = int.Parse(this.level_tbx.Text); // if(l!=zoom) // { // continue; // } //} var files = Directory.EnumerateFiles(z); foreach (string f in files) { var paras = new CheckTilesParameters { bundle_path = f }; Task <string> checkTileTask = Task.Factory.StartNew <string>((Object p) => CheckBundle(p), paras); checkList.Add(checkTileTask); } } Task.WaitAll(checkList.ToArray()); StringBuilder result = new StringBuilder(); foreach (var t in checkList) { if (t.Result != "") { result.AppendLine(t.Result); } } return(result.ToString()); }
private string CheckTiles(string pathToCacheRoot, TileCheckMode mode) { var zooms = Directory.EnumerateDirectories(pathToCacheRoot + @"\_alllayers\"); StringBuilder result = new StringBuilder(); foreach (string z in zooms) { var files = Directory.EnumerateFiles(z); foreach (string f in files) { int level; int row; int column; GetLRCFromBundleFilePath(f, out level, out row, out column); using (FileStream source = File.OpenRead(f)) { BinaryReader reader = new BinaryReader(source); for (int r = 0; r < 128; r++) { for (int c = 0; c < 128; c++) { int index = r * 128 + c; source.Seek((index * 8) + COMPACT_CACHE_HEADER_LENGTH, SeekOrigin.Begin); byte[] offsetAndSize = new byte[8]; reader.Read(offsetAndSize, 0, 8); byte[] offsetBytes = new byte[8]; Buffer.BlockCopy(offsetAndSize, 0, offsetBytes, 0, 5); long offset = BitConverter.ToUInt32(offsetBytes, 0); byte[] sizeBytes = new byte[4]; Buffer.BlockCopy(offsetAndSize, 5, sizeBytes, 0, 3); int size = BitConverter.ToInt32(sizeBytes, 0); if (size == 0) { continue; } source.Seek(offset, SeekOrigin.Begin); byte[] tile = new byte[size]; reader.Read(tile, 0, size); if (mode == TileCheckMode.Whole) { if (CheckBlank(tile)) { result.AppendLine(String.Format("L{0}/R{1}/C{2}", level, row + r, column + c)); } } else if (mode == TileCheckMode.Strip) { if (CheckStrip(tile)) { result.AppendLine(String.Format("L{0}/R{1}/C{2}", level, row + r, column + c)); } } } } } } } return(result.ToString()); }