基於GMap.NET地圖下載器的開發和研究


基於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     }
View Code

 

技術交流  省厓 QQ:2252224326  2252224326@qq.com 版權所有 http://blog.sina.com.cn/u/6029512413


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM