public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (!(value is IEnumerable<Location>))
     {
         return null;
     }
     var collection = new LocationCollection();
     collection.AddRange(((IEnumerable<Location>) value).Select(l => l.ToGeoCoordinate()));
     return collection;
 }
示例#2
0
        public AircraftRouteViewModel GetRouteLine(Aircraft aircraft)
        {
            AircraftRouteViewModel line = new AircraftRouteViewModel(aircraft.Id);
            Location segmentStart       = aircraft.Location;

            if (aircraft.Route.Any())
            {
                LocationCollection pathLocations = new LocationCollection();
                foreach (Location segmentEnd in aircraft.Route.Select(x => x.Location))
                {
                    pathLocations.AddRange(segmentStart.CalculateGreatCircleLocations(segmentEnd));
                    segmentStart = segmentEnd;
                }

                line.Locations = pathLocations;
            }

            return(line);
        }