/// <exception cref="ArgumentException"></exception> public static Route ToRoute(this IEnumerable <ICoordinate> coordinates) { var items = coordinates.ToList(); if (items.Count < 2) { throw new ArgumentException(); } var result = new Route(); foreach (var i in items) { double lat = i.Lat; double lon = i.Lon; string latLonTxt = Format5Letter.ToString(lat, lon) ?? FormatDecimal.ToString(lat, lon); var wpt = new Waypoint(latLonTxt, lat, lon); result.AddLastWaypoint(wpt, "DCT"); } return(result); }
public void OutputStringAsExpected() { Assert.IsTrue(FormatDecimal.ToString(36.0, -150.0).Equals("N36.000000W150.000000")); Assert.IsTrue(FormatDecimal.ToString(36.0, 150.0).Equals("N36.000000E150.000000")); Assert.IsTrue(FormatDecimal.ToString(-36.0, -150.0).Equals("S36.000000W150.000000")); Assert.IsTrue(FormatDecimal.ToString(-36.0, 150.0).Equals("S36.000000E150.000000")); }
private bool TryParseCoord(string ident) { var coord = FormatDecimal.Parse(ident); if (coord != null) { lastWpt = -1; return(TryAppendWpt(new Waypoint(ident, coord))); } return(false); }
public static string AutoChooseFormat(this LatLon item) { string result = Format5Letter.To5LetterFormat(item.Lat, item.Lon); return(result ?? FormatDecimal.ToDecimalFormat(item.Lat, item.Lon)); }
private static LatLon ParseLatLon(string s) { return(Format5Letter.Parse(s) ?? Format7Letter.Parse(s) ?? FormatDecimal.Parse(s)); }