基于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

转载于:https://www.cnblogs.com/shengya/p/9608309.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值