Пример #1
0
        /// <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);
        }
Пример #2
0
 public void OutputStringAsExpected()
 {
     Assert.IsTrue(Format5Letter.ToString(36.0, -150.0).Equals("36N50"));
     Assert.IsTrue(Format5Letter.ToString(36.0, 150.0).Equals("36E50"));
     Assert.IsTrue(Format5Letter.ToString(-36.0, -150.0).Equals("36W50"));
     Assert.IsTrue(Format5Letter.ToString(-36.0, 150.0).Equals("36S50"));
 }
Пример #3
0
        private static string FormatIdAttribute(string id)
        {
            var c = Formatter.ParseLatLon(id);

            if (c == null)
            {
                return(id);
            }
            return(Format5Letter.ToString(Math.Round(c.Lat), Math.Round(c.Lon)));
        }
Пример #4
0
 private static void AddLatLons(WaypointList wptList)
 {
     for (int lon = -180; lon <= 180; lon++)
     {
         for (int lat = -90; lat <= 90; lat++)
         {
             wptList.AddWaypoint(
                 new Waypoint(Format5Letter.ToString(lat, lon), lat, lon));
         }
     }
 }
Пример #5
0
        public static string AutoChooseFormat(this LatLon item)
        {
            string result = Format5Letter.ToString(item.Lat, item.Lon);

            return(result ?? FormatDecimal.ToString(item.Lat, item.Lon));
        }