123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Globalization;
- using System.Runtime.CompilerServices;
- using System.Text;
- namespace Ips.Library.Entity
- {
- public class EphResult
- {
- /// <summary>
- /// 卫星编号
- /// </summary>
- [DisplayName("卫星编号")]
- public int SatNum { get; set; }
- /// <summary>
- /// 星历时间
- /// </summary>
- [DisplayName("星历时间")]
- public DateTime Time { get; set; }
- /// <summary>
- /// 星历类型
- /// </summary>
- [DisplayName("星历类型")]
- public EphType EphType { get; set; }
- /// <summary>
- /// 位置X
- /// </summary>
- [DisplayName("位置X")]
- public double X { get; set; }
- /// <summary>
- /// 位置Y
- /// </summary>
- [DisplayName("位置Y")]
- public double Y { get; set; }
- /// <summary>
- /// 位置Z
- /// </summary>
- [DisplayName("位置Z")]
- public double Z { get; set; }
- /// <summary>
- /// 速度X
- /// </summary>
- [DisplayName("速度X")]
- public double Vx { get; set; }
- /// <summary>
- /// 速度Y
- /// </summary>
- [DisplayName("速度Y")]
- public double Vy { get; set; }
- /// <summary>
- /// 速度Z
- /// </summary>
- [DisplayName("速度Z")]
- public double Vz { get; set; }
- public EphResult() { }
- public EphResult(int satNum, DateTime time, double x, double y, double z, double vx = 0, double vy = 0, double vz = 0)
- {
- this.SatNum = satNum;
- this.Time = time;
- this.X = x;
- this.Y = y;
- this.Z = z;
- this.Vx = vx;
- this.Vy = vy;
- this.Vz = vz;
- }
- public EphResult(int satNum, EphType ephType, DateTime time, double x, double y, double z, double vx = 0, double vy = 0, double vz = 0)
- {
- this.SatNum = satNum;
- this.EphType = ephType;
- this.Time = time;
- this.X = x;
- this.Y = y;
- this.Z = z;
- this.Vx = vx;
- this.Vy = vy;
- this.Vz = vz;
- }
- public static EphResult FromString(string source)
- {
- EphResult result = new EphResult();
- var items = source.TrimEnd().Split('\t');
- int i = 0;
- if (items.Length >= 1 && DateTime.TryParseExact(items[i++], "yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentUICulture, DateTimeStyles.None, out DateTime timeRes))
- {
- result.Time = timeRes;
- }
- if (items.Length >= 3)
- {
- result.X = double.Parse(items[i++]);
- result.Y = double.Parse(items[i++]);
- result.Z = double.Parse(items[i++]);
- }
- if (items.Length >= 6)
- {
- result.Vx = double.Parse(items[i++]);
- result.Vy = double.Parse(items[i++]);
- result.Vz = double.Parse(items[i++]);
- }
- return result;
- }
- public static EphResult[] FromListString(string result, string itemsep = "")
- {
- if (string.IsNullOrWhiteSpace(result))
- return Array.Empty<EphResult>();
- if (string.IsNullOrWhiteSpace(itemsep))
- {
- itemsep = Environment.NewLine;
- }
- var items = result.Split(itemsep.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- EphResult[] results = new EphResult[items.Length];
- for (int i = 0; i < items.Length; i++)
- {
- results[i] = EphResult.FromString(items[i]);
- }
- return results;
- }
- public double[] GetEphXyz()
- {
- return new double[] { this.X, this.Y, this.Z, this.Vx, this.Vy, this.Vz };
- }
- public override string ToString()
- {
- return $"{SatNum},{Time:yyyy-MM-dd HH:mm:ss},{X},{Y},{Z},{Vx},{Vy},{Vz}";
- }
- }
- }
|