PGIS下载离线地图 SQLite+WPF
项目是超高分辨率屏幕墙,实时在线加载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; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!