Ejemplo n.º 1
0
        public int WriteRoutes(string outputPath, bool kml)
        {
            int count = 0;

            foreach (KeyValuePair <TaxiNode, Dictionary <XPlaneAircraftCategory, ResultRoute> > sizeRoutes in _results)
            {
                for (XPlaneAircraftCategory size = XPlaneAircraftCategory.Max - 1; size >= XPlaneAircraftCategory.A; size--)
                {
                    if (sizeRoutes.Value.ContainsKey(size))
                    {
                        ResultRoute route = sizeRoutes.Value[size];
                        if (route.TargetNode == null)
                        {
                            continue;
                        }

                        if (route.AvailableRunwayLength < VortexMath.Feet3000Km)
                        {
                            continue;
                        }

                        foreach (Parking currentParking in route.Parkings)
                        {
                            IEnumerable <WorldTrafficAircraftType> wtTypes = AircraftTypeConverter.WTTypesFromXPlaneLimits(XPlaneAircraftCategory.A, route.MaxSize, currentParking.Operation);

                            if (route.AvailableRunwayLength < VortexMath.Feet9000Km)
                            {
                                WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.SuperHeavy, WorldTrafficAircraftType.HeavyJet };
                                wtTypes = wtTypes.Except(big);
                            }
                            if (route.AvailableRunwayLength < VortexMath.Feet6500Km)
                            {
                                WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.LargeJet };
                                wtTypes = wtTypes.Except(big);
                            }
                            if (route.AvailableRunwayLength < VortexMath.Feet5000Km)
                            {
                                WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.MediumJet, WorldTrafficAircraftType.LightJet };
                                wtTypes = wtTypes.Except(big);
                            }
                            if (route.AvailableRunwayLength < VortexMath.Feet4000Km)
                            {
                                WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.LargeProp, WorldTrafficAircraftType.MediumProp };
                                wtTypes = wtTypes.Except(big);
                            }

                            if (wtTypes.Count() == 0)
                            {
                                continue;
                            }

                            IEnumerable <SteerPoint> steerPoints = BuildSteerPoints(currentParking, route);

                            if (steerPoints.Count() <= Settings.MaxSteerpoints)
                            {
                                string allSizes = string.Join(" ", wtTypes.Select(w => (int)w).OrderBy(w => w));
                                string sizeName = (wtTypes.Count() == 10) ? "all" : allSizes.Replace(" ", "");
                                string fileName = Path.Combine(outputPath, $"{currentParking.FileNameSafeName}_to_{Runway.Designator}-{route.AvailableRunwayLength * VortexMath.KmToFoot:00000}_{sizeName}");

                                int military = (currentParking.Operation == OperationType.Military) ? 1 : 0;
                                int cargo    = (currentParking.Operation == OperationType.Cargo) ? 1 : 0;

                                using (RouteWriter sw = RouteWriter.Create(kml ? 0 : 1, fileName, allSizes, cargo, military, Runway.Designator, "NOSEWHEEL"))
                                {
                                    count++;

                                    foreach (SteerPoint steerPoint in steerPoints)
                                    {
                                        sw.Write(steerPoint);
                                    }
                                }
                            }
                            else
                            {
                                Logger.Log($"Route from <{currentParking.FileNameSafeName}> to {Runway.Designator} not written. Too many steerpoints ({steerPoints.Count()} vs {Settings.MaxSteerpoints})");
                            }
                        }
                    }
                }
            }

            return(count);
        }
Ejemplo n.º 2
0
        public int WriteRoutes(string outputPath, bool kml)
        {
            int count = 0;

            foreach (KeyValuePair <TaxiNode, Dictionary <XPlaneAircraftCategory, ResultRoute> > sizeRoutes in _results)
            {
                for (XPlaneAircraftCategory size = Parking.MaxSize; size >= XPlaneAircraftCategory.A; size--)
                {
                    if (sizeRoutes.Value.ContainsKey(size))
                    {
                        ResultRoute route = sizeRoutes.Value[size];

                        if (route.TargetNode == null)
                        {
                            continue;
                        }

                        if (Parking.MaxSize < route.MinSize)
                        {
                            continue;
                        }

                        XPlaneAircraftCategory validMax = (XPlaneAircraftCategory)Math.Min((int)route.MaxSize, (int)Parking.MaxSize);
                        IEnumerable <WorldTrafficAircraftType> wtTypes = AircraftTypeConverter.WTTypesFromXPlaneLimits(route.MinSize, validMax, Parking.Operation);
                        if (wtTypes.Count() == 0)
                        {
                            Logger.Log($"WARN {Parking.Name} (Max)Cat {Parking.MaxSize} Types: {string.Join(" ", Parking.XpTypes)} does not map to any WT types.");
                        }

                        if (route.AvailableRunwayLength < VortexMath.Feet5000Km)
                        {
                            WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.SuperHeavy, WorldTrafficAircraftType.HeavyJet, WorldTrafficAircraftType.LargeJet, WorldTrafficAircraftType.LargeProp, WorldTrafficAircraftType.LightJet };
                            wtTypes = wtTypes.Except(big);
                        }
                        else if (route.AvailableRunwayLength < VortexMath.Feet6500Km)
                        {
                            WorldTrafficAircraftType[] big = { WorldTrafficAircraftType.SuperHeavy, WorldTrafficAircraftType.HeavyJet };
                            wtTypes = wtTypes.Except(big);
                        }
                        else if (route.AvailableRunwayLength > VortexMath.Feet8000Km)
                        {
                            WorldTrafficAircraftType[] small = { WorldTrafficAircraftType.LightProp, WorldTrafficAircraftType.LightJet, WorldTrafficAircraftType.MediumProp };
                            wtTypes = wtTypes.Except(small);
                        }

                        if (wtTypes.Count() == 0)
                        {
                            continue;
                        }

                        IEnumerable <SteerPoint> steerPoints = BuildSteerPoints(route, sizeRoutes.Key);
                        if (steerPoints.Count() <= Settings.MaxSteerpoints)
                        {
                            string allSizes = string.Join(" ", wtTypes.Select(w => (int)w).OrderBy(w => w));
                            string sizeName = (wtTypes.Count() == 10) ? "all" : allSizes.Replace(" ", "");
                            string fileName = Path.Combine(outputPath, $"{route.Runway.Designator}_to_{Parking.FileNameSafeName}_{route.AvailableRunwayLength * VortexMath.KmToFoot:00000}_{sizeName}");

                            using (RouteWriter sw = RouteWriter.Create(kml ? 0 : 1, fileName, allSizes, -1, -1, route.Runway.Designator, ParkingReferenceConverter.ParkingReference(Settings.ParkingReference)))
                            {
                                count++;

                                foreach (SteerPoint steerPoint in steerPoints)
                                {
                                    sw.Write(steerPoint);
                                }
                            }
                        }
                        else
                        {
                            Logger.Log($"Route from <{route.Runway.Designator}> to {Parking.FileNameSafeName} not written. Too many steerpoints ({steerPoints.Count()} vs {Settings.MaxSteerpoints})");
                        }
                    }
                }
            }
            return(count);
        }