Beispiel #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);
        }
Beispiel #2
0
        public RouteForm(RouteWriter route_writer)
        {
            SetBrowserFeatureControl();
            InitializeComponent();
            route_Writer = route_writer;

            var webClient  = new WebClient();
            var webClient2 = new WebClient();

            route_name_lbl.Text = route_Writer.Route_name;
            writer_lbl.Text     = route_Writer.Full_name;
            rating_lbl.Text    += route_Writer.Route_rating;
            route_name_lbl.Left = 750 - route_name_lbl.Width / 2;
            writer_lbl.Left     = 750 - writer_lbl.Width / 2;
            rating_lbl.Left     = 750 - rating_lbl.Width / 2;
            if (MainForm.user != null)
            {
                mark_lbl.Visible   = true;
                mark_combo.Visible = true;
                data_comments.AllowUserToAddRows = true;
            }
            if (route_Writer.Route_description != null)
            {
                web.DocumentText = route_Writer.Route_description;
            }
            else
            {
                web.DocumentText = Description.empty_description;
            }

            string url = "http://94.230.164.34:8080/api/CommentRoute?id=" + route_Writer.Id_route;

            try
            {
                string response_comments = Encoding.UTF8.GetString(webClient2.DownloadData(url));
                comments = JsonConvert.DeserializeObject <List <Comment_Route> >(response_comments);

                data_comments.Rows.Clear();
                for (int i = 0; i < comments.Count; i++)
                {
                    data_comments.Rows.Add();
                    data_comments.Rows[i].Cells[0].Value = comments[i].Comment;
                    data_comments.Rows[i].Cells[1].Value = comments[i].Nick;
                    data_comments.Rows[i].Cells[2].Value = comments[i].Date.Value.Day.ToString() + "." + comments[i].Date.Value.Month.ToString() + "." + comments[i].Date.Value.Year.ToString();
                    data_comments.Rows[i].ReadOnly       = true;
                }
            }
            catch
            {
                Messages.ErrorComments();
            }

            url = "http://94.230.164.34:8080/api/RouteMovie?id=" + route_Writer.Id_route;
            try
            {
                string response_movies = Encoding.UTF8.GetString(webClient2.DownloadData(url));
                movies = JsonConvert.DeserializeObject <List <Movies> >(response_movies);

                data_movies.Rows.Clear();

                for (int i = 0; i < movies.Count; i++)
                {
                    data_movies.Rows.Add();
                    data_movies.Rows[i].Cells[0].Value = movies[i].Movie_title;
                    data_movies.Rows[i].Cells[1].Value = movies[i].Year_of_issue;
                }

                url = "http://94.230.164.34:8080/api/RouteMuseum?id=" + route_Writer.Id_route;
                string response_museums = Encoding.UTF8.GetString(webClient2.DownloadData(url));
                museums = JsonConvert.DeserializeObject <List <Museums> >(response_museums);

                data_museums.Rows.Clear();

                for (int i = 0; i < museums.Count; i++)
                {
                    data_museums.Rows.Add();
                    data_museums.Rows[i].Cells[0].Value = museums[i].Museum_name;
                    data_museums.Rows[i].Cells[1].Value = museums[i].Museum_site;
                    data_museums.Rows[i].Cells[2].Value = museums[i].Museum_address;
                }

                url = "http://94.230.164.34:8080/api/RoutePlace?id=" + route_Writer.Id_route;
                string response_places = Encoding.UTF8.GetString(webClient2.DownloadData(url));
                places = JsonConvert.DeserializeObject <List <Places> >(response_places);

                data_places.Rows.Clear();

                for (int i = 0; i < places.Count; i++)
                {
                    data_places.Rows.Add();
                    data_places.Rows[i].Cells[0].Value = places[i].Place_name;
                    data_places.Rows[i].Cells[1].Value = places[i].Place_address;
                }

                url = "http://94.230.164.34:8080/api/RouteSpectacle?id=" + route_Writer.Id_route;
                string response_spectacles = Encoding.UTF8.GetString(webClient2.DownloadData(url));
                spectacle_theater = JsonConvert.DeserializeObject <List <SpectacleTheater> >(response_spectacles);

                data_spectacles.Rows.Clear();

                for (int i = 0; i < spectacle_theater.Count; i++)
                {
                    data_spectacles.Rows.Add();
                    data_spectacles.Rows[i].Cells[0].Value = spectacle_theater[i].Spectacle_title;
                    data_spectacles.Rows[i].Cells[1].Value = spectacle_theater[i].Spectacle_link;
                    data_spectacles.Rows[i].Cells[2].Value = spectacle_theater[i].Theater_name;
                    data_spectacles.Rows[i].Cells[3].Value = spectacle_theater[i].Theater_address;
                }
            }
            catch
            {
                Messages.ErrorConnection();
            }

            if (museums.Count != 0)
            {
                for (int i = 0; i < museums.Count; i++)
                {
                    full_route.Add(new FullRoute {
                        Num      = numb, Name = museums[i].Museum_name, Address = museums[i].Museum_address,
                        Latitude = museums[i].Latitude, Longitude = museums[i].Longitude
                    });
                }
            }

            if (spectacle_theater.Count != 0)
            {
                for (int i = 0; i < spectacle_theater.Count; i++)
                {
                    full_route.Add(new FullRoute
                    {
                        Num       = numb,
                        Name      = spectacle_theater[i].Theater_name,
                        Address   = spectacle_theater[i].Theater_address,
                        Latitude  = spectacle_theater[i].Latitude,
                        Longitude = spectacle_theater[i].Longitude
                    });
                }
            }

            if (places.Count != 0)
            {
                for (int i = 0; i < places.Count; i++)
                {
                    full_route.Add(new FullRoute
                    {
                        Num       = numb,
                        Name      = places[i].Place_name,
                        Address   = places[i].Place_address,
                        Latitude  = places[i].Latitude,
                        Longitude = places[i].Longitude
                    });
                }
            }


            numb = full_route.Count;
        }
Beispiel #3
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);
        }