using Ips.Library.Entity; using System; using System.Collections.Generic; using System.Text; namespace Ips.Library.Entity { public class PosResult { public PosType PosType { get; set; } public bool HasRef { get; set; } public GeoLLA Result1 { get; set; } public GeoLLA Result2 { get; set; } public PosResult() : this(LonNan.Value, LatNan.Value, LonNan.Value, LatNan.Value) { } public PosResult(double lon, double lat, double alt) : this(lon, lat, alt, LonNan.Value, LatNan.Value, 0) { } public PosResult(double lon, double lat, double mirlon, double mirlat) : this(lon, lat, 0, mirlon, mirlat, 0) { } public PosResult(double lon, double lat, double alt, double mirlon, double mirlat, double miralt) { Result1 = new GeoLLA(lon, lat, alt); Result2 = new GeoLLA(mirlon, mirlat, miralt); } public override string ToString() { return $"{Result1.Lon},{Result1.Lat},{Result1.Alt};{Result2.Lon},{Result2.Lat},{Result2.Alt}"; } public static PosResult FromString(PosType posType, bool hasRef, string source) { if (string.IsNullOrWhiteSpace(source)) throw new ArgumentException("定位结果转换出错!", nameof(source)); var items = source.Split(';'); PosResult result = new PosResult(); result.PosType = posType; result.HasRef = hasRef; if (items.Length >= 1) { result.Result1 = GeoLLA.FromString(items[0]); } if (items.Length >= 2) { result.Result2 = GeoLLA.FromString(items[1]); } return result; } } }