Beispiel #1
0
        /// <summary>
        /// 读取数据源表
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, NtripSourceTable> LoadNtripSourceTables()
        {
            var tables = new Dictionary <string, NtripSourceTable>();

            foreach (var item in this.NtripCasters.Values)
            {
                var local = Path.Combine(Setting.ApplicationDirectory, item.SourceTablePath);
                var table = NtripSourceTable.Load(local);
                tables.Add(item.Name, table);
            }
            return(tables);
        }
Beispiel #2
0
        public static NtripSourceTable Load(string path)
        {
            var manager = new NtripSourceTable();

            using (StreamReader reader = new StreamReader(path, Encoding.Default))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    if (IsSourceLine(line))
                    {
                        INtripSourceItem item;
                        var first3Char = line.Substring(0, 3);
                        var type       = SourceTypeHelper.GetSourceType(first3Char);
                        switch (type)
                        {
                        case SourceType.Stream:
                            var NtripStreamItem = NtripStream.Parse(line);
                            NtripStreamItem.CasterName = Path.GetFileNameWithoutExtension(path).Replace("-table", "");
                            item = NtripStreamItem;
                            break;

                        case SourceType.Caster:
                            item = NtripCasterItem.Parse(line);
                            break;

                        case SourceType.Network:
                            item = NtripNetwork.Parse(line);
                            break;

                        default:
                            item = NtripCasterItem.Parse(line);
                            break;
                        }
                        manager.GetOrCreate(item.SourceType).Add(item);
                    }
                }
            }
            return(manager);
        }