| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 | using System;using System.Collections.Generic;using System.Security.Cryptography;using System.Text;namespace Ips.Library.Entity{    public class GeoLLA    {        public GeoLLA() : this(LonNan.Value, LatNan.Value, 0) { }        public GeoLLA(double lon, double lat) : this(lon, lat, 0) { }        public GeoLLA(double lon, double lat, double alt)        {            Lon = lon;            Lat = lat;            Alt = alt;        }        /// <summary>        /// 经度        /// </summary>        public double Lon { get; set; }        /// <summary>        /// 纬度        /// </summary>        public double Lat { get; set; }        /// <summary>        /// 高度        /// </summary>        public double Alt { get; set; }        public const double MinLon = -180;        public const double MaxLon = 180;        public const double MinLat = -90;        public const double MaxLat = 90;        public override string ToString()        {            return $"{Lon},{Lat},{Alt}";        }        public bool IsSome(GeoLLA item)        {            if (item == null) return false;            if (ReferenceEquals(this, item)) return true;            return Lon == item.Lon && Lat == item.Lat && Alt == item.Alt;        }        public bool IsValid()        {            return Lon >= MinLon && Lon <= MaxLon && Lat >= MinLat && Lat <= MaxLat;        }        public double[] ToArray()        {            return new double[] { Lon, Lat, Alt };        }        public static GeoLLA FromString(string val, string itemsep = ",")        {            var items = val.Split(itemsep.ToCharArray());            double lon = LonNan.Value, lat = LatNan.Value, alt = 0;            if (items.Length > 1)            {                lon = double.Parse(items[0].Trim());                lat = double.Parse(items[1].Trim());            }            if (items.Length > 2)            {                alt = double.Parse(items[2].Trim());            }            return new GeoLLA(lon, lat, alt);        }    }    public class LonNan    {        public const double Value = 181;    }    public class LatNan    {        public const double Value = 91;    }}
 |