//考虑并行情况,2014.09.14
        /// <summary>
        /// 获取指定时刻,某卫星的信息。可能需要拟合计算。
        /// 失败则返回 null。
        /// </summary>
        /// <param name="prn"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public override Ephemeris Get(SatelliteNumber prn, Time time)
        {
            if (!TimePeriod.BufferedContains(time))
            {
                log.Error(prn + "," + time + " 已经超出星历服务时段范围 " + TimePeriod);
                return(null);
            }

            var ephes = EphemerisManager.GetOrCreate(prn);

            if (ephes == null || ephes.Count == 0)
            {
                if (!WarnedPrns.Contains(prn))
                {
                    log.Warn("当前SP3文件 " + Name + " 没有这颗卫星的信息 " + prn);
                    WarnedPrns.Add(prn);
                }
                return(null);
            }

            //获取原始星历
            var storage = ephes.GetSatEphemerises(time);

            if (storage == null)
            {
                return(null);
            }
            if (storage.Count < MinSequentialSatCount)//连续数量太少,拟合将不准确。
            {
                log.Warn(prn + "," + time + " 连续数量太少,拟合将不准确。" + storage.Count + " 至少应 " + MinSequentialSatCount);
                return(null);
            }
            var secondOfWeek = time.SecondsOfWeek;

            //判断防止周日时间退减到周六
            if (time.DayOfWeek == DayOfWeek.Saturday && Math.Abs(TimeConsts.SECOND_PER_WEEK - secondOfWeek) < 2)
            {
                secondOfWeek -= TimeConsts.SECOND_PER_WEEK;//回滚到下一周
            }
            //找出最近的部分
            List <double> indexes  = Geo.Utils.DoubleUtil.GetNearst(storage.Keys, secondOfWeek, Order);
            var           entities = storage.GetSubEphemerises(indexes);

            //插值
            using (var interpolator = new EphemerisInterpolator(entities, Order))
            {
                return(interpolator.GetEphemerisInfo(time));
            }

            //return GetInterpolatorResult(prn, time, entities);
        }
Beispiel #2
0
        /// <returns></returns>
        public override Ephemeris Get(SatelliteNumber prn, Time time)
        {
            if (!TimePeriod.BufferedContains(time))
            {
                log.Error(prn + "," + time + " 已经超出星历服务时段范围 " + TimePeriod);
                return(null);
            }

            var ephes = EphemerisManager.GetOrCreate(prn);

            if (ephes == null || ephes.Count == 0)
            {
                if (!WarnedPrns.Contains(prn))
                {
                    log.Warn("当前SP3文件 " + Name + " 没有这颗卫星的信息 " + prn);
                    WarnedPrns.Add(prn);
                }
                return(null);
            }

            //获取原始星历
            var storage = ephes.GetSatEphemerises(time);

            if (storage == null)
            {
                return(null);
            }
            if (storage.Count < MinSequentialSatCount)//连续数量太少,拟合将不准确。
            {
                log.Warn(prn + "," + time + " 连续数量太少,拟合将不准确。" + storage.Count + " 至少应 " + MinSequentialSatCount);
                return(null);
            }

            var entities = storage.GetGetNearst(time, Order);

            //插值
            using (var interpolator = new EphemerisInterpolator(entities, Order))
            {
                var result = interpolator.GetEphemerisInfo(time);
                if (result.XYZ.Length > 100000000)
                {
                    log.Error("尚不支持轨道半径" + ((result.XYZ.Length) / 1000).ToString("0 000 000.00") + " KM 的 GNSS 卫星 " + result.XYZ);
                }
                return(result);
            }

            //return GetInterpolatorResult(prn, time, entities);
        }
        /// <summary>
        /// 初始化插值器
        /// </summary>
        private void Init()
        {
            var interval = Sp3File.Interval == 0 ? 1 : Sp3File.Interval; // Sp3Reader.Header.EpochInterval;

            WarnedPrns       = new List <SatelliteNumber>();
            EphemerisManager = new EphemerisManager(interval, MaxBreakingCount);
            Sp3File.TimePeriod.SetSameBuffer(interval * 10);

            foreach (var prn in Sp3File.Prns)
            {
                var storage = EphemerisManager.GetOrCreate(prn);

                var all = Sp3File.Get(prn);
                if (all == null || all.Count == 0)
                {
                    continue;
                }

                storage.Add(all.Values);
            }
        }