基于GMap.NET地图下载器的开发和研究

版权声明:省厓 QQ:2252224326 邮箱:[email protected] https://blog.csdn.net/u013247588/article/details/82527045

基于GMap.NET地图下载器的开发和研究

软件下载地址:https://pan.baidu.com/s/1LUkYtE4gedTKYEcS0QaH2g

更新时间2018年9月10日11:39:55

指南针地图应用平台      V1.812.180910   

1、增加谷歌、海图、全球船舶动态图、arcgis、高德地图等

2、增加放大、缩小等地图操作

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  [email protected] 版权所有 http://blog.sina.com.cn/u/6029512413

猜你喜欢

转载自blog.csdn.net/u013247588/article/details/82527045