Beispiel #1
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);
        }
Beispiel #2
0
        public static NtripCasterItem Parse(string line)
        {
            var item = new NtripCasterItem();

            string[] fields = line.Split(';');
            string   first  = fields[0].ToUpper();

            if (first != "CAS")
            {
                throw new NotSupportedException("字符串错误");
            }
            int i = 1;

            item.Host      = fields[i++];
            item.Port      = fields[i++];
            item.Identifier = fields[i++];
            item.Operator  = fields[i++];
            item.Nmea      = fields[i++];
            item.Country   = fields[i++];
            item.Latitude  = fields[i++];
            item.Longitude = fields[i++];
            item.Misc      = fields[i++];
            return(item);
        }