示例#1
0
        private void CreateEmptyTileBuffer()
        {
            int          minLevel     = 1;
            TileComputer tileComputer = new TileComputer(_tileSetting.TileSize, _tileSetting.SampleRatio);

            LevelDef[] levels     = tileComputer.GetLevelDefs(_dataProvider.Width, _dataProvider.Height);
            int        levelCount = levels.Length;

            byte[] buffer = new byte[_tileSetting.TileSize * _tileSetting.TileSize * _dataTypeSize];
            for (int i = levelCount - 1; i >= minLevel; i--)
            {
                for (int b = 1; b <= _dataProvider.BandCount; b++)
                {
                    TileIdentify[] ts = levels[i].TileIdentities;
                    foreach (TileIdentify t in ts)
                    {
                        string fName = GetTileBufferFileName(t, b) + "_" + t.Width.ToString() + "_" + t.Height + ".RAW";
                        using (FileStream fs = new FileStream(fName, FileMode.Create))
                        {
                            fs.SetLength(t.Width * t.Height * _dataTypeSize);
                        }
                    }
                }
            }
        }
示例#2
0
        private void TestReadFromLevelBuffer()
        {
            int          idx          = 0;
            int          minLevel     = 1;
            TileComputer tileComputer = new TileComputer(_tileSetting.TileSize, _tileSetting.SampleRatio);

            LevelDef[] levels     = tileComputer.GetLevelDefs(_dataProvider.Width, _dataProvider.Height);
            int        levelCount = levels.Length;

            byte[] buffer = new byte[_tileSetting.TileSize * _tileSetting.TileSize * _dataTypeSize];
            for (int i = levelCount - 1; i >= minLevel; i--)
            {
                for (int b = 1; b <= _dataProvider.BandCount; b++)
                {
                    string fName = GetLevelBufferFileName(b, levels[i]);
                    using (FileStream fs = new FileStream(fName, FileMode.Open))
                    {
                        TileIdentify[] ts = levels[i].TileIdentities;
                        foreach (TileIdentify t in ts)
                        {
                            fs.Seek(t.BeginRow * t.Width + t.BeginCol, SeekOrigin.Begin);
                            fs.Read(buffer, 0, t.Width * t.Height * _dataTypeSize);
                            //Console.WriteLine((idx++).ToString());
                        }
                    }
                }
            }
        }
示例#3
0
        public void UpdateTileComputer(ICanvas canvas)
        {
            TileSetting tileSetting = canvas.CanvasSetting != null ? canvas.CanvasSetting.TileSetting : new TileSetting();

            if (_tileComputer == null || _tileComputer.TileSize != tileSetting.TileSize || _tileComputer.SampleRatio != tileSetting.SampleRatio)
            {
                _tileComputer = new TileComputer(tileSetting.TileSize, tileSetting.SampleRatio);
                _leves        = _tileComputer.GetLevelDefs(_dataProvider.Width, _dataProvider.Height);
            }
        }
示例#4
0
        private void CreateBufferByLevel()
        {
            int[] defaultBandNos, otherBandNos;
            GetBandNos(out defaultBandNos, out otherBandNos);
            TileComputer tileComputer = new TileComputer(_tileSetting.TileSize, _tileSetting.SampleRatio);

            LevelDef[] levels     = tileComputer.GetLevelDefs(_dataProvider.Width, _dataProvider.Height);
            int        levelCount = levels.Length;
            Stopwatch  sw         = new Stopwatch();

            sw.Start();
            CreateBufferByLevel(levels, 1, defaultBandNos);
            CreateBufferByLevel(levels, 1, otherBandNos);
            sw.Stop();
            Console.WriteLine("Lost time : " + sw.ElapsedMilliseconds.ToString());
        }
示例#5
0
        public float Estimate(string fname, out int memoryOfTile, out int tileCount)
        {
            int bandCount;
            int width;
            int height;

            tileCount    = 0;
            memoryOfTile = 0;
            using (IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider)
            {
                bandCount = prd.BandCount;
                width     = prd.Width;
                height    = prd.Height;
            }
            int          tileSize = 512;
            TileComputer computer = new TileComputer(tileSize, 2);

            LevelDef[] lvs = computer.GetLevelDefs(width, height);
            if (lvs == null || lvs.Length == 0)
            {
                return(0);
            }
            tileCount = 0;
            foreach (LevelDef lv in lvs)
            {
                if (lv.TileIdentities != null && lv.TileIdentities.Length > 0)
                {
                    tileCount += lv.TileIdentities.Length;
                }
            }
            //
            float memorySize = 0;

            if (bandCount == 1)
            {
                memoryOfTile = tileSize * tileSize * 1;
            }
            else
            {
                memoryOfTile = tileSize * tileSize * 3;
            }
            memorySize = tileCount * memoryOfTile / 1024 / 1024;//MB
            //
            return(memorySize);
        }
示例#6
0
        private void CreateEmptyLevelBuffer()
        {
            int          minLevel     = 1;
            TileComputer tileComputer = new TileComputer(_tileSetting.TileSize, _tileSetting.SampleRatio);

            LevelDef[] levels     = tileComputer.GetLevelDefs(_dataProvider.Width, _dataProvider.Height);
            int        levelCount = levels.Length;

            byte[] buffer = new byte[_tileSetting.TileSize * _tileSetting.TileSize * _dataTypeSize];
            for (int i = levelCount - 1; i >= minLevel; i--)
            {
                for (int b = 1; b <= _dataProvider.BandCount; b++)
                {
                    string fName = GetLevelBufferFileName(b, levels[i]);
                    using (FileStream fs = new FileStream(fName, FileMode.Create))
                    {
                        fs.SetLength((long)levels[i].Size.Width * (long)levels[i].Size.Height * (long)_dataTypeSize);
                    }
                }
            }
        }