Exemple #1
0
        /// <summary>
        /// Apply Douglas-Peucker on each section with the same IsOnGround
        /// </summary>
        /// <param name="route"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public IEnumerable <AircraftStatusBrief> DouglasPeucker(List <AircraftStatusBrief> route, double tolerance)
        {
            var result = new List <int>();
            int start = 0, end = 0;

            while (end < route.Count)
            {
                result.Add(start);
                while (end < route.Count - 1 && route[end + 1].IsOnGround == route[end].IsOnGround)
                {
                    end++;
                }
                if (end - start > 1)
                {
                    DouglasPeuckerRecursive(route.Select(o => GpsHelper.ToXyz(o.Latitude, o.Longitude, o.Altitude)).ToList(), tolerance * tolerance, start, end, result);
                }
                result.Add(end);
                start = end + 1;
                end   = start;
            }

            foreach (var index in result)
            {
                yield return(route[index]);
            }
        }
Exemple #2
0
        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 FlightPlanWaypoint ToData()
        {
            var waypoint = new FlightPlanWaypoint
            {
                Id     = id,
                Airway = ATCAirway,
                Type   = ATCWaypointType,
                ICAO   = ICAO?.ToData()
            };

            (waypoint.Latitude, waypoint.Longitude, waypoint.Altitude) = GpsHelper.ConvertString(WorldPosition);
            return(waypoint);
        }
        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);
        }