예제 #1
0
        public static bool TryParse(string s, out GpsLocation result)
        {
            result = new GpsLocation();

            if (string.IsNullOrEmpty(s))
            {
                return(false);
            }

            int pos = 0;

            double latitude  = double.NaN;
            double longitude = double.NaN;

            if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude))
            {
                return(false);
            }
            if (!TryParseGpsFragment(s, ref pos, ref latitude, ref longitude))
            {
                return(false);
            }
            if (!IsValidLatitude(latitude) || !IsValidLongitude(longitude))
            {
                return(false);
            }

            result.Latitude  = latitude;
            result.Longitude = longitude;
            return(true);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is GpsLocation))
            {
                return(false);
            }

            GpsLocation other = (GpsLocation)obj;

            return(this.Latitude == other.Latitude && this.Longitude == other.Longitude);
        }