基于GMap.NET地图下载器的开发和研究
软件下载地址:https://pan.baidu.com/s/1ay0aOm3fiZ35vlfD8kFYFw
1、地图浏览功能
可以浏览谷歌地图、百度、arcgis、bing地图等多种卫星、道路地图。
2、按照行政区域地图下载
3、地图瓦片存贮到本地,通过本地缓存永久保存地图数据
public class MemoryCache : IDisposable
{
private FastReaderWriterLock kiberCacheLock;
private readonly KiberTileCache TilesInMemory; public MemoryCache()
{ this.TilesInMemory = new KiberTileCache();
this.kiberCacheLock = new FastReaderWriterLock();
} internal void AddTileToMemoryCache(RawTile tile, byte[] data)
{
if (data != null)
{
this.kiberCacheLock.AcquireWriterLock();
try
{
if (!this.TilesInMemory.ContainsKey(tile))
{
this.TilesInMemory.Add(tile, data);
}
}
finally
{
this.kiberCacheLock.ReleaseWriterLock();
}
}
} public void Clear()
{
this.kiberCacheLock.AcquireWriterLock();
try
{
this.TilesInMemory.Clear();
}
finally
{
this.kiberCacheLock.ReleaseWriterLock();
}
} public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
} private void Dispose(bool disposing)
{
if (this.kiberCacheLock != null)
{
if (disposing)
{
this.Clear();
}
this.kiberCacheLock.Dispose();
this.kiberCacheLock = null;
}
} ~MemoryCache()
{
this.Dispose(false);
} internal byte[] GetTileFromMemoryCache(RawTile tile)
{
this.kiberCacheLock.AcquireReaderLock();
try
{
byte[] buffer = null;
if (this.TilesInMemory.TryGetValue(tile, out buffer))
{
return buffer;
}
}
finally
{
this.kiberCacheLock.ReleaseReaderLock();
}
return null;
} internal void RemoveOverload()
{
this.kiberCacheLock.AcquireWriterLock();
try
{
this.TilesInMemory.RemoveMemoryOverload();
}
finally
{
this.kiberCacheLock.ReleaseWriterLock();
}
} public int Capacity
{
get
{
int memoryCacheCapacity;
this.kiberCacheLock.AcquireReaderLock();
try
{
memoryCacheCapacity = this.TilesInMemory.MemoryCacheCapacity;
}
finally
{
this.kiberCacheLock.ReleaseReaderLock();
}
return memoryCacheCapacity;
}
set
{
this.kiberCacheLock.AcquireWriterLock();
try
{
this.TilesInMemory.MemoryCacheCapacity = value;
}
finally
{
this.kiberCacheLock.ReleaseWriterLock();
}
}
} public double Size
{
get
{
double memoryCacheSize;
this.kiberCacheLock.AcquireReaderLock();
try
{
memoryCacheSize = this.TilesInMemory.MemoryCacheSize;
}
finally
{
this.kiberCacheLock.ReleaseReaderLock();
}
return memoryCacheSize;
}
}
}
技术交流 省厓 QQ:2252224326 2252224326@qq.com 版权所有 http://blog.sina.com.cn/u/6029512413