Beispiel #1
0
        static void BatchTestSaveas()
        {
            var odlFolder = @"C:\arcgisserver\directories\arcgiscache\TestChinaMap\图层\_alllayers11111";
            var newFolder = @"C:\arcgisserver\directories\arcgiscache\TestChinaMap\图层\_alllayersnew";

            var allOldFiles = Directory.GetFiles(odlFolder, "*.bundle", SearchOption.AllDirectories);
            foreach (var oldFilePath in allOldFiles)
            {

                EsriBundleFile oldDataFile = new EsriBundleFile(oldFilePath);
                oldDataFile.Intiliaze();
                string filename = Path.GetFileName(oldFilePath);
                string newDataSavepath = oldFilePath.Replace(odlFolder, newFolder).Replace(filename, "");

                if (!Directory.Exists(newDataSavepath)) Directory.CreateDirectory(newDataSavepath);
                oldDataFile.SaveAs(Path.Combine(newDataSavepath, filename));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 写入指定行列号的瓦片数据,由于需要频繁打开文件然后复制,最好使用批量写入的方式
        /// </summary>
        /// <param name="level"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="tilebytes"></param>
        public void Write(int level, int row, int col, Byte[] tilebytes)
        {
            string bundleFilePath = GetBundleFileWithouExtention(level, row, col);

            // 将旧文件的数据首先读到新文件中,插入新的数据会造成整个文件数据的移动,因而这里采用全部读取出来,然后重新写入的方式
            EsriBundleFile oldDataFile = new EsriBundleFile(bundleFilePath + EsriBundleFileConfig.BundleExt);
            oldDataFile.Intiliaze();
            var newDataFile = new EsriBundleFile(oldDataFile.Config);
            newDataFile.Intiliaze();
            for (int i = 0; i < EsriBundleFileConfig.MaxTileCount; i++)
            {
                var dataBytes = oldDataFile.Read(i);

                newDataFile.Write(i, dataBytes);
            }
            oldDataFile.Dispose();
            oldDataFile = null;
            int index;
            EsriBundleHelper.ComputeIndex(row, col, PacketSize, out index);

            newDataFile.Write(index, tilebytes);
            newDataFile.SaveAs(bundleFilePath + EsriBundleFileConfig.BundleExt);
            newDataFile.Dispose();
        }
Beispiel #3
0
        static void CreateDataFileTest()
        {
            var oldIndexPath = @"d:\esri\R1300C6980.bundlx";
            var oldDataPath = @"d:\esri\R1300C6980.bundle";
            var newDataPath = @"d:\esri\R1300C6980new.bundle";

            EsriBundleIndexFile oldIndexFile = new EsriBundleIndexFile(oldIndexPath);
            oldIndexFile.Intiliaze();

            var allOldStorageIndices = oldIndexFile.GetAllIndices();
            EsriBundleFile oldDataFile = new EsriBundleFile(oldDataPath, allOldStorageIndices);
            oldDataFile.Intiliaze();
            EsriBundleFile newDataFile = new EsriBundleFile(oldDataFile.Config);
            newDataFile.Intiliaze();
            for (int i = 0; i < 16384; i++)
            {
                var dataBytes = oldDataFile.Read(i);

                newDataFile.Write(i, dataBytes);
            }
            newDataFile.SaveAs(newDataPath);
        }
Beispiel #4
0
        static void TestSaveAs()
        {
            var oldIndexPath = @"d:\esri\R1300C6980.bundlx";
            var oldDataPath = @"d:\esri\R1300C6980.bundle";
            var newDataPath = @"d:\esri\R1300C6980new.bundle";

            EsriBundleIndexFile oldIndexFile = new EsriBundleIndexFile(oldIndexPath);
            oldIndexFile.Intiliaze();

            var allOldStorageIndices = oldIndexFile.GetAllIndices();
            EsriBundleFile oldDataFile = new EsriBundleFile(oldDataPath, allOldStorageIndices);
            oldDataFile.Intiliaze();
            oldDataFile.SaveAs(newDataPath);
        }