日期:2014-05-16  浏览次数:20353 次

STSDB 缓存。。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using STSdb.Data;
using System.Reflection;

namespace YQMapTile.Ags.AGS
{
    /// <summary>
    /// STSDB提供的层块缓存器
    /// </summary>
    internal class STSTileCache : IAgsTileCache<MemoryStream>
    {
        //protected StorageEngine cacheEngine = null;
        protected XTable<long, byte[]> tileTable = null;
        private string sPath;
        private string sLyrName;

        /// <summary>
        /// 采用STS缓存来存储层块数据
        /// </summary>
        /// <param name="path">Path为缓存数据数据存储路</param>
        /// <param name="lyrname"></param>
        public STSTileCache(string path, string lyrname)
        {
            if (string.IsNullOrEmpty(path))
            {
                Assembly myAssembly = Assembly.GetAssembly(this.GetType());
                path = Path.GetDirectoryName(myAssembly.Location);
                string sts_dll = Path.Combine(path, "STSdb.dll");
                System.Reflection.Assembly.LoadFile(sts_dll);
                path = Path.Combine(path, "TileCache");
                //如果目录不存在则创建
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
            }
            string dbFileName = Path.Combine(path,(lyrname+".vstb").ToUpper());
            this.initCacheEngine(dbFileName, lyrname);
        }

        ~STSTileCache()
        {
            this.Close();
        }
        /// <summary>
        /// 关闭时直接全部清空
        /// </summary>
        public void ShutDown()
        {
            this.Close();
        }
        /// <summary>
        /// 关闭缓存引擎
        /// </summary>