PGIS下載離線地圖 SQLite+WPF

來源:互聯網
上載者:User

標籤:

項目是超高解析度螢幕牆,即時線上載入PGIS地圖速度會比較慢,造成螢幕大量留白。於是使用地圖緩衝,事先把這個區塊的地圖全部down下來,使用Sqlite資料庫儲存。留存。

 

//Task taskDown = new Task(DownTiles);//taskDown.Start();private void DownTiles()        {            double maxX = 138.796586;            double maxY = 24.371022;            double minX = 138.447725;            double minY = 24.086215;            double X0 = -180;            double Y0 = 90;            string tempUrl = "";            HttpWebRequest req = null;            Stream stream = null;            int bufferLen = 1024 * 1024;            int actual;            byte[] buffer = new byte[bufferLen];            for (int i = 9; i < 21; i++)//Level            {                int cmin = Math.Abs(Convert.ToInt32(Math.Floor((X0 - minX) / (256 * MapMethods.GetResoulution(i)))));                int cmax = Math.Abs(Convert.ToInt32(Math.Floor((X0 - maxX) / (256 * MapMethods.GetResoulution(i)))));                int rmin = Math.Abs(Convert.ToInt32(Math.Floor((Y0 - maxY) / (256 * MapMethods.GetResoulution(i)))));                int rmax = Math.Abs(Convert.ToInt32(Math.Floor((Y0 - minY) / (256 * MapMethods.GetResoulution(i)))));                for (int r = rmin; r < rmax; r++)//迴圈行                {                    for (int c = cmin; c < cmax; c++)//迴圈列                    {                        //Thread.Sleep(100);                        tempUrl = GetTileUrl(i, r, c);                        req = (HttpWebRequest)WebRequest.Create(tempUrl);                        stream = req.GetResponse().GetResponseStream();                        MemoryStream memoryStream = new MemoryStream();                                                while ((actual = stream.Read(buffer, 0, bufferLen)) > 0)                        {                            memoryStream.Write(buffer, 0, actual);                        }                        memoryStream.Position = 0;                        SaveTile(i, r, c, StreamToBytes2(memoryStream));                                                                    }                }            }        }        private byte[] StreamToBytes2(MemoryStream input)        {            byte[] bytes = new byte[input.Length];            input.Read(bytes, 0, bytes.Length);            return bytes;        }

 

PGIS下載離線地圖 SQLite+WPF

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.