/// <summary>
        /// 读取指定行列号的数据
        /// </summary>
        /// <param name="level"></param>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        public Byte[] Read(int level, int row, int col)
        {
            string bundleFilePath = GetBundleFileWithouExtention(level, row, col);

            // 打开对应的索引文件
            EsriBundleIndexFile indexFile = new EsriBundleIndexFile(bundleFilePath + EsriBundleFileConfig.BundleIndexExt);
            indexFile.Intiliaze();

            // 读取所有索引
            var bundleIndices = indexFile.GetAllIndices();
            // 读取数据文件
            EsriBundleFile dataFile = new EsriBundleFile(bundleFilePath + EsriBundleFileConfig.BundleExt, bundleIndices);
            dataFile.Intiliaze();
            int index;
            EsriBundleHelper.ComputeIndex(row, col, PacketSize, out index);

            var tileBytes = dataFile.Read(index);
            indexFile.Dispose();
            dataFile.Dispose();
            return tileBytes;
        }
Exemple #2
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);
        }
Exemple #3
0
        static void CreateIndexFile(string oldfilepath, string newfilepath)
        {
            EsriBundleIndexFile indexfile = new EsriBundleIndexFile(oldfilepath);
            indexfile.Intiliaze();
            //indexfile.SaveAs(newfilepath);

            EsriBundleIndexFile indexfile1 = new EsriBundleIndexFile(indexfile.GetAllIndices());
            indexfile1.Intiliaze();
            indexfile1.SaveAs(newfilepath);
            indexfile1.Dispose();
            indexfile.Dispose();
        }
Exemple #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);
        }
Exemple #5
0
        static void ReadTest()
        {
            var oldIndexPath = @"d:\esri\R0000C0000.bundlx";
            var oldDataPath = @"d:\esri\R0000C0000.bundle";

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

            var allOldStorageIndices = oldIndexFile.GetAllIndices();
            EsriBundleFile oldDataFile = new EsriBundleFile(oldDataPath, allOldStorageIndices);
            oldDataFile.Intiliaze();
            for (int i = 0; i < 16384; i++)
            {
                var dataBytes = oldDataFile.Read(i);
                if (dataBytes != null)
                {
                    var indexx = allOldStorageIndices[i];
                }
            }
        }
Exemple #6
0
        public void Intiliaze()
        {
            if (IsIntiliazed) return;
            if (NewFileMode)
            {
                TilesBytesDict = new Dictionary<int, byte[]>(EsriBundleFileConfig.MaxTileCount);
                AllIndices = new List<TileIndex>();
                IsIntiliazed = true;
                return;
            }

            TileDataStream = new FileStream(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            ReadHeader(TileDataStream);
            if (AllIndices != null)
            {
                IntilizeIndicesDict();
            }
            else
            {
                var indexFilePath = Path.ChangeExtension(FilePath, EsriBundleFileConfig.BundleIndexExt);
                using (EsriBundleIndexFile indefile = new EsriBundleIndexFile(indexFilePath))
                {
                    indefile.Intiliaze();
                    AllIndices = indefile.GetAllIndices();
                }
                IntilizeIndicesDict();
            }
            IsIntiliazed = true;
        }