Пример #1
0
        public AvgWindCalculator(IWxTableCollection windData, double Ktas, double AltitudeFt)
        {
            this.windData   = windData;
            this.Ktas       = Ktas;
            this.AltitudeFt = AltitudeFt;

            v1 = DefaultLocation;
            v2 = DefaultLocation;
        }
        private static string GetWindTemp(IWxTableCollection w, ICoordinate c, double alt)
        {
            var windUV = w.GetWindUV(c.Lat, c.Lon, alt);
            var wind   = Wind.FromUV(windUV);

            return(string.Format("{0}@{1}({2})",
                                 RoundToInt(wind.Direction).ToString().PadLeft(3, '0'),
                                 RoundToInt(wind.Speed).ToString().PadLeft(2, '0'),
                                 RoundToInt(w.GetTemp(c.Lat, c.Lon, alt))));
        }
Пример #3
0
 public static IEnumerable <(Wind, double temp)> Generate(IWxTableCollection windTables,
                                                          double lat, double lon, IEnumerable <double> flightLevels)
 {
     return(flightLevels.Select(fl =>
     {
         var UVWind = windTables.GetWindUV(lat, lon, fl * 100.0);
         var temp = windTables.GetTemp(lat, lon, fl * 100.0);
         return (Wind.FromUV(UVWind), temp);
     }));
 }
Пример #4
0
 private static FuelCalculator GetCalculator(IWxTableCollection w, Route route)
 {
     return(new FuelCalculator(
                TestAirportManager(),
                new CrzAltProviderStub(),
                w,
                route,
                FuelDataItemTest.GetItem(),
                55000.0,
                5000.0,
                41000.0));
 }
 public static InitialPlanCreator GetCreator(IWxTableCollection w)
 {
     return(new InitialPlanCreator(
                TestAirportManager(),
                new CrzAltProviderStub(),
                w,
                TestRoute(),
                FuelDataItemTest.GetItem(),
                55000.0,
                5000.0,
                41000.0));
 }
Пример #6
0
 /// <summary>
 /// Note: routesToAltn can be empty. In that case, alternates are not used.
 /// </summary>
 public FuelReportGenerator(
     AirportManager airportList,
     ICrzAltProvider altProvider,
     IWxTableCollection windTable,
     Route routeToDest,
     IEnumerable <Route> routesToAltn,
     FuelParameters para,
     double maxAlt = 41000.0)
 {
     this.airportList  = airportList;
     this.altProvider  = altProvider;
     this.windTable    = windTable;
     this.routeToDest  = routeToDest;
     this.routesToAltn = routesToAltn.ToList();
     this.para         = para;
     this.maxAlt       = maxAlt;
 }
Пример #7
0
        /// <summary>
        /// Get string of the flight plan to export.
        /// </summary>
        /// <exception cref="Exception"></exception>
        public static string GetExportText(Route route, IWxTableCollection w)
        {
            var altitudes = List(6000, 9000, 12000, 18000, 24000,
                                 30000, 34000, 39000, 44000, 49000);

            return(string.Join("\n", route.Select(node =>
            {
                var wpt = node.Waypoint;
                var id = (node == route.First.Value || node == route.Last.Value) ?
                         wpt.ID.Substring(0, 4) :
                         wpt.ID;

                var altitudesStr = altitudes.Select(a => GetWindTemp(w, wpt, a)).ToList();
                return string.Join("\t", List(id).Concat(altitudesStr.Take(5))) + "\n\t" +
                string.Join("\t", altitudesStr.Skip(5));
            })));
        }
Пример #8
0
 public InitialPlanCreator(
     AirportManager airportList,
     ICrzAltProvider altProvider,
     IWxTableCollection windTable,
     Route route,
     FuelDataItem fuelData,
     double zfw,
     double landingFuel,
     double maxAlt)
 {
     this.airportList = airportList;
     this.altProvider = altProvider;
     this.windTable   = windTable;
     this.route       = route;
     this.fuelData    = fuelData;
     this.zfw         = zfw;
     this.landingFuel = landingFuel;
     this.maxAlt      = maxAlt;
 }
Пример #9
0
        /// <summary>
        /// Gets the wind vector in earth's coordinate at the given location.
        /// </summary>
        public static Vector3D GetWind(
            IWxTableCollection windData,
            double altitudeFt,
            double lat,
            double lon)
        {
            var w = windData.GetWindUV(lat, lon, altitudeFt);

            lat = ToRadian(lat);
            lon = ToRadian(lon);

            double sinLat = Sin(lat);
            double sinLon = Sin(lon);
            double cosLon = Cos(lon);

            var u1 = new Vector3D(-sinLon, cosLon, 0.0);
            var u2 = new Vector3D(-sinLat * cosLon, -sinLat * sinLon, Cos(lat));

            return(u1 * w.UComp + u2 * w.VComp);
        }
Пример #10
0
        public PlanNode(
            object NodeValue,
            IWxTableCollection WindTable,
            LinkedListNode <RouteNode> NextRouteNode,
            ICoordinate NextPlanNodeCoordinate,
            double Alt,
            double GrossWt,
            double FuelOnBoard,
            double TimeRemaining,
            double Kias,
            double Ktas = -1.0,
            double Gs   = -1.0)
        {
            if (!IsValidType(NodeValue))
            {
                throw new ArgumentException("Type not allowed.");
            }

            this.NodeValue              = NodeValue;
            this.WindTable              = WindTable;
            this.NextRouteNode          = NextRouteNode;
            this.NextPlanNodeCoordinate = NextPlanNodeCoordinate;
            this.Alt           = Alt;
            this.GrossWt       = GrossWt;
            this.FuelOnBoard   = FuelOnBoard;
            this.TimeRemaining = TimeRemaining;
            this.Kias          = Kias;
            this.Ktas          = Ktas;
            this.Gs            = Gs;

            var c = GetCoordinate();

            this.Lat = c.Lat;
            this.Lon = c.Lon;

            if (Gs == -1.0)
            {
                ComputeParameters();
            }
        }
Пример #11
0
        /// <summary>
        /// Gets the ground speed (in knots) at v, where the route is from v1
        /// to v2. The v, v1, and v2 are unit vectors on the sphere. v1 must be
        /// different from v2 but v can be the same as v1 or v2.
        /// </summary>
        public static double GetGS(
            IWxTableCollection windData,
            double altitudeFt,
            double ktas,
            Vector3D v1,
            Vector3D v2,
            Vector3D v)
        {
            var      latLon  = v.ToLatLon();
            Vector3D wind    = GetWind(windData, altitudeFt, latLon.Lat, latLon.Lon);
            double   windSpd = wind.R;
            var      w       = v.Equals(v2) ? -GetW(v, v1) : GetW(v, v2);

            // We solve the equation:
            // | (gs) * w - wind | = tas, where |x| is the length of vector x.
            double innerProduct = wind.Dot(w);
            double a            = 1.0;
            double b            = -2.0 * innerProduct;
            double c            = windSpd * windSpd - ktas * ktas;

            return((-b + Sqrt(b * b - 4.0 * a * c)) / (2.0 * a));
        }
Пример #12
0
        /// <exception cref="ArgumentException"></exception>
        public FuelCalculator(
            AirportManager airportList,
            ICrzAltProvider altProvider,
            IWxTableCollection windTable,
            Route route,
            FuelDataItem fuelData,
            double zfw,
            double landingFuel,
            double maxAlt)
        {
            if (route.Count < 2)
            {
                throw new ArgumentException();
            }

            this.airportList = airportList;
            this.altProvider = altProvider;
            this.windTable   = windTable;
            this.route       = route;
            this.fuelData    = fuelData;
            this.zfw         = zfw;
            this.landingFuel = landingFuel;
            this.maxAlt      = maxAlt;
        }