public FlightPlanCompact(FlightPlanData flightPlan, string callsign, string aircraftType, int?estimatedCruisingSpeed, string remarks) { Callsign = callsign; AircraftType = aircraftType; Type = flightPlan.Type; RouteType = flightPlan.RouteType; CruisingAltitude = flightPlan.CruisingAltitude; Departure = flightPlan.Departure?.ID; Destination = flightPlan.Destination?.ID; Route = flightPlan.Waypoints == null ? null : string.Join(" ", flightPlan.Waypoints.Where(o => o.Id != "TIMECRUIS" && o.Id != "TIMEDSCNT").Select(o => o.Id)); CruisingSpeed = estimatedCruisingSpeed; if (estimatedCruisingSpeed != null && estimatedCruisingSpeed != 0 && flightPlan.Waypoints != null && flightPlan.Waypoints.Count() > 1) { var dist = 0d; for (var i = 1; i < flightPlan.Waypoints.Count(); i++) { var p1 = flightPlan.Waypoints.ElementAt(i - 1); var p2 = flightPlan.Waypoints.ElementAt(i); dist += GpsHelper.CalculateDistance(p1.Latitude, p1.Longitude, p2.Latitude, p2.Longitude); } EstimatedEnroute = TimeSpan.FromHours(dist / estimatedCruisingSpeed.Value); } Remarks = remarks; }
public FlightPlanData ToData() { var data = new FlightPlanData { Title = Title, Type = FPType, RouteType = RouteType, CruisingAltitude = (int)CruisingAlt, Description = Descr, Departure = new FlightPlanPosition { ID = DepartureID, Name = DepartureName }, Destination = new FlightPlanPosition { ID = DestinationID, Name = DestinationName }, Waypoints = ATCWaypoint?.Select(o => o.ToData()) }; (data.Departure.Latitude, data.Departure.Longitude, data.Departure.Altitude) = GpsHelper.ConvertString(DepartureLLA); (data.Destination.Latitude, data.Destination.Longitude, data.Destination.Altitude) = GpsHelper.ConvertString(DestinationLLA); return(data); }