Ejemplo n.º 1
0
        /// <summary>
        /// Run initial analysis on airport
        /// </summary>
        /// <param name="icao">icao code of the airport to analyse</param>
        /// <param name="quiet">override to true to suppress log messages in the richtextbox</param>
        /// <returns>true if no errors occured during analysis</returns>
        private bool Analyse(string icao, bool quiet = false)
        {
            _quietMode = quiet;

            try
            {
                bool found = ScanCustomSceneries(icao);
                if (found)
                {
                    _airport = new Airport();
                    if (!_airport.Analyze(Path.Combine(Settings.DataFolder, $"{icao}.tmp"), icao))
                    {
                        LogElapsed("Customized airport does not contain the minimal data requiered to generate routes (parkings + atc taxi network).");
                        found    = false;
                        _airport = null;
                    }
                }

                if (!found)
                {
                    found = ScanDefaultAptDat(icao);
                    if (found)
                    {
                        _airport = new Airport();
                        if (!_airport.Analyze(Path.Combine(Settings.DataFolder, $"{icao}.tmp"), icao))
                        {
                            LogElapsed("Default airport does not contain the minimal data requiered to generate routes (parkings + atc taxi network).");
                            found    = false;
                            _airport = null;
                            return(false);
                        }
                    }
                }

                if (!found)
                {
                    return(false);
                }

                //StringBuilder sb = new StringBuilder();
                //_airport.AnalyzeFlows(sb);
                //LogElapsed($"\n{sb.ToString()}\n");

                LogElapsed("Parkings and ATC taxi network are present.");

                var ps = _airport.Parkings.GroupBy(p => p.Name);
                foreach (var psv in ps)
                {
                    if (psv.Count() > 1)
                    {
                        LogElapsed($"WARNING Duplicate parking names in apt source: <{psv.First().Name}> occurs {psv.Count()} times.");
                    }
                }


                if (CheckWorldTrafficFolders(icao, out _hasExistingInboundRoutes, out _hasExistingOutboundRoutes, out _hasExistingParkingDefs, out _hasExistingAirportOperations))
                {
                    btnGenerate.Enabled = true;
                    cbxOverwriteAirportOperations.ForeColor = _hasExistingAirportOperations ? Color.Red : Color.Black;
                    cbxOverwriteInboundRoutes.ForeColor     = _hasExistingInboundRoutes ? Color.Red : Color.Black;
                    cbxOverwriteOutboundRoutes.ForeColor    = _hasExistingOutboundRoutes ? Color.Red : Color.Black;
                    cbxOverwriteParkingDefs.ForeColor       = _hasExistingParkingDefs ? Color.Red : Color.Black;
                }
                else
                {
                    btnGenerate.Enabled = false;
                    cbxOverwriteAirportOperations.ForeColor = Color.Gray;
                    cbxOverwriteInboundRoutes.ForeColor     = Color.Gray;
                    cbxOverwriteOutboundRoutes.ForeColor    = Color.Gray;
                    cbxOverwriteParkingDefs.ForeColor       = Color.Gray;
                }
            }
            catch (Exception ex)
            {
                LogElapsed($"\nAn exception occurred during analysis:\n{ex}");
                return(false);
            }
            return(true);
        }