Пример #1
0
        /// <summary>
        /// Load grids from the specified folder
        /// </summary>
        public void InitializeExternalGrids(string strGridsFolder, bool recursive)
        {
            SearchOption opt = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;

            string[]      gridTypes = { "*.los", "*.gsb", "*.dat", "*.lla" };
            List <string> names     = new List <string>();

            foreach (string gridType in gridTypes)
            {
                string[] tmp = Directory.GetFiles(strGridsFolder, gridType, opt);
                names.AddRange(tmp);
            }

            foreach (var s in names)
            {
                string coreName = "@" + Path.GetFileNameWithoutExtension(s);
                if (_tables.ContainsKey(coreName))
                {
                    continue;
                }
                string ext = Path.GetExtension(s).ToLower();
                if (ext != ".los" && ext != ".gsb" && ext != ".dat")
                {
                    continue;
                }
                if (ext == ".los" && !File.Exists(s.Replace(".los", ".las")))
                {
                    continue;
                }
                var s1 = s;
                _tables.Add(coreName, new Lazy <NadTable>(() => NadTable.FromSourceName(s1, false), true));
            }
        }
Пример #2
0
        /// <summary>
        /// This method parses the extension of a resource location or
        /// path and creates the new NadTable type.
        /// </summary>
        public static NadTable FromSourceName(string location, bool embedded = true, bool requiresDecompression = false)
        {
            NadTable result = null;
            string   ext    = Path.GetExtension(location).ToLower();

            switch (ext)
            {
            case ".lla":
                result = new LlaNadTable(location, embedded, requiresDecompression);
                break;

            case ".gsb":
                result = new GsbNadTable(location, 0, embedded, requiresDecompression);
                break;

            case ".dat":
                result = new DatNadTable(location, embedded, requiresDecompression);
                break;

            case ".los":
                result = new LasLosNadTable(location, embedded, requiresDecompression);
                break;
            }
            if (result != null)
            {
                result.ReadHeader();
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// Load grids from the specified folder
        /// </summary>
        public void InitializeExternalGrids(string strGridsFolder, bool recursive)
        {
            SearchOption opt = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;

            foreach (var gridType in new[] { "*.los", "*.gsb", "*.dat", "*.lla" })
            {
                foreach (var s in Directory.EnumerateFiles(strGridsFolder, gridType, opt))
                {
                    string coreName = "@" + Path.GetFileNameWithoutExtension(s);
                    string ext      = Path.GetExtension(s).ToLower();
                    if (ext == ".los" && !File.Exists(s.Replace(".los", ".las")))
                    {
                        continue;
                    }
                    var s1 = s;
                    _tables.Add(coreName, new Lazy <NadTable>(() => NadTable.FromSourceName(s1, false), true));
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Creates a new instance of NadTables
        /// </summary>
        public NadTables()
        {
            var a = Assembly.GetExecutingAssembly();

            foreach (var s in a.GetManifestResourceNames())
            {
                string[] ss = s.Split('.');
                if (ss.Length < 5)
                {
                    continue;
                }
                string coreName = "@" + ss[4];
                if (_tables.ContainsKey(coreName))
                {
                    continue;
                }
                string ext = Path.GetExtension(s).ToLower();
                if (ext != ".lla" && ext != ".dat" && ext != ".gsb")
                {
                    continue;
                }
                //if (ss[ss.Length - 2] != "ds") continue; // only encoded by DeflateStreamUtility
                using (var str = a.GetManifestResourceStream(s))
                {
                    if (str == null)
                    {
                        continue;
                    }
                }
                var s1 = s;
                if (ss[ss.Length - 2] == "ds")
                {
                    _tables.Add(coreName, new Lazy <NadTable>(() => NadTable.FromSourceName(s1, true, true), true));
                }
                else
                {
                    _tables.Add(coreName, new Lazy <NadTable>(() => NadTable.FromSourceName(s1, true), true));
                }
            }
        }