public static bool TryParse(string value, IFormatProvider provider, out GpsLocation result) { result = null; var match = LocRegex.Match(value); if (match == null || !match.Success || match.Groups.Count != 5) { return(false); } if (!decimal.TryParse(match.Groups[1].Value, NumberStyles.Float, provider, out decimal lat)) { return(false); } if (match.Groups[2].Value == "S" || match.Groups[2].Value == "s") { lat *= -1; } if (!decimal.TryParse(match.Groups[3].Value, NumberStyles.Float, provider, out decimal lon)) { return(false); } if (match.Groups[4].Value == "W" || match.Groups[4].Value == "w") { lon *= -1; } result = new GpsLocation( RationalDegrees.FromDecimal(lat), RationalDegrees.FromDecimal(lon)); return(true); }
public static GpsLocation FromBytes( byte[] latSignBytes, byte[] latBytes, byte[] lonSignBytes, byte[] lonBytes) { return(new GpsLocation( RationalDegrees.FromBytes(latBytes, latSignBytes[0] == South[0] ? -1 : 1), RationalDegrees.FromBytes(lonBytes, lonSignBytes[0] == West[0] ? -1 : 1))); }
public GpsLocation(RationalDegrees lat, RationalDegrees lon) { this.lat = lat; this.lon = lon; }