基于GMap.NET地图下载器的开发和研究
软件下载地址:https://pan.baidu.com/s/1ay0aOm3fiZ35vlfD8kFYFw
1、地图浏览功能
可以浏览谷歌地图、百度、arcgis、bing地图等多种卫星、道路地图。
2、按照行政区域地图下载
3、地图瓦片存贮到本地,通过本地缓存永久保存地图数据


1 public class MemoryCache : IDisposable 2 { 3 private FastReaderWriterLock kiberCacheLock; 4 private readonly KiberTileCache TilesInMemory; 5 6 public MemoryCache() 7 { 8 9 this.TilesInMemory = new KiberTileCache(); 10 this.kiberCacheLock = new FastReaderWriterLock(); 11 } 12 13 internal void AddTileToMemoryCache(RawTile tile, byte[] data) 14 { 15 if (data != null) 16 { 17 this.kiberCacheLock.AcquireWriterLock(); 18 try 19 { 20 if (!this.TilesInMemory.ContainsKey(tile)) 21 { 22 this.TilesInMemory.Add(tile, data); 23 } 24 } 25 finally 26 { 27 this.kiberCacheLock.ReleaseWriterLock(); 28 } 29 } 30 } 31 32 public void Clear() 33 { 34 this.kiberCacheLock.AcquireWriterLock(); 35 try 36 { 37 this.TilesInMemory.Clear(); 38 } 39 finally 40 { 41 this.kiberCacheLock.ReleaseWriterLock(); 42 } 43 } 44 45 public void Dispose() 46 { 47 this.Dispose(true); 48 GC.SuppressFinalize(this); 49 } 50 51 private void Dispose(bool disposing) 52 { 53 if (this.kiberCacheLock != null) 54 { 55 if (disposing) 56 { 57 this.Clear(); 58 } 59 this.kiberCacheLock.Dispose(); 60 this.kiberCacheLock = null; 61 } 62 } 63 64 ~MemoryCache() 65 { 66 this.Dispose(false); 67 } 68 69 internal byte[] GetTileFromMemoryCache(RawTile tile) 70 { 71 this.kiberCacheLock.AcquireReaderLock(); 72 try 73 { 74 byte[] buffer = null; 75 if (this.TilesInMemory.TryGetValue(tile, out buffer)) 76 { 77 return buffer; 78 } 79 } 80 finally 81 { 82 this.kiberCacheLock.ReleaseReaderLock(); 83 } 84 return null; 85 } 86 87 internal void RemoveOverload() 88 { 89 this.kiberCacheLock.AcquireWriterLock(); 90 try 91 { 92 this.TilesInMemory.RemoveMemoryOverload(); 93 } 94 finally 95 { 96 this.kiberCacheLock.ReleaseWriterLock(); 97 } 98 } 99 100 public int Capacity 101 { 102 get 103 { 104 int memoryCacheCapacity; 105 this.kiberCacheLock.AcquireReaderLock(); 106 try 107 { 108 memoryCacheCapacity = this.TilesInMemory.MemoryCacheCapacity; 109 } 110 finally 111 { 112 this.kiberCacheLock.ReleaseReaderLock(); 113 } 114 return memoryCacheCapacity; 115 } 116 set 117 { 118 this.kiberCacheLock.AcquireWriterLock(); 119 try 120 { 121 this.TilesInMemory.MemoryCacheCapacity = value; 122 } 123 finally 124 { 125 this.kiberCacheLock.ReleaseWriterLock(); 126 } 127 } 128 } 129 130 public double Size 131 { 132 get 133 { 134 double memoryCacheSize; 135 this.kiberCacheLock.AcquireReaderLock(); 136 try 137 { 138 memoryCacheSize = this.TilesInMemory.MemoryCacheSize; 139 } 140 finally 141 { 142 this.kiberCacheLock.ReleaseReaderLock(); 143 } 144 return memoryCacheSize; 145 } 146 } 147 }
技术交流 省厓 QQ:2252224326 2252224326@qq.com 版权所有 http://blog.sina.com.cn/u/6029512413