예제 #1
0
        public static PluginAlertType GetAlertByLevel(AirplaneBasic airplane, Radar radar, bool lightWeight, bool mediumWeight, bool heavyWeight, bool superHeavysAndRare)
        {
            var listAircraftTypeHighAlert = HelperPlugin.ListWideAirplanes;

            var listAircraftTypeSuperHighAlert = HelperPlugin.ListSuperHighAirplanes;

            PluginAlertType alertType = PluginAlertType.Low;

            bool isSuperHighAlert = listAircraftTypeSuperHighAlert.Where(s => airplane.AircraftType != null && airplane.AircraftType.ICAO.Contains(s)).Count() > 0 &&
                                    superHeavysAndRare;

            if (isSuperHighAlert)
            {
                alertType = PluginAlertType.High;
            }
            else if (heavyWeight && airplane.Weight == AirplaneWeight.Heavy ||
                     mediumWeight && airplane.Weight == AirplaneWeight.Medium ||
                     lightWeight && airplane.Weight == AirplaneWeight.Light)
            {
                alertType = PluginAlertType.High;
            }
            else if (!heavyWeight && airplane.Weight == AirplaneWeight.Heavy)
            {
                alertType = PluginAlertType.Medium;
            }

            return(alertType);
        }
예제 #2
0
        public static List <Place> GetForwardLocations(AirplaneBasic airplane, bool isPassNear)
        {
            double lat       = airplane.Latitude;
            double lon       = airplane.Longitude;
            double direction = airplane.Direction * Math.PI / 180;

            double vlat = (Math.Cos(direction) * 0.1);
            double vlon = (Math.Sin(direction) * 0.1);

            List <Place> locationsFound = new List <Place>();

            int distanceToCover = 100;

            distanceToCover = (isPassNear) ? 35 : distanceToCover;

            for (int i = 0; i < 100; i++)
            {
                double currentLat = lat + (vlat * i * 0.08);
                double currentLon = lon + (vlon * i * 0.08);

                List <Place> listPlacesOver = ListPlacesGPS.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList();

                if (listPlacesOver.Count > 0)
                {
                    bool hasFound = locationsFound.Where(s => s.Name == listPlacesOver.FirstOrDefault().Name).Count() > 0;
                    if (!hasFound)
                    {
                        locationsFound.Add(listPlacesOver.FirstOrDefault());
                    }
                }
            }

            return(locationsFound);
        }
예제 #3
0
        public static string GetForwardLocationsPhrase(AirplaneBasic airplane, bool isPassNear, int maxLocations = 50)
        {
            try
            {
                string       final                   = String.Empty;
                List <Place> locationsFound          = GetForwardLocations(airplane, isPassNear);
                List <Place> locationsFoundPluginred = new List <Place>();

                // The "For" below was needed because a bug.
                maxLocations = (maxLocations > locationsFound.Count) ? locationsFound.Count : maxLocations;
                for (int i = 0; i < maxLocations; i++)
                {
                    locationsFoundPluginred.Add(locationsFound[i]);
                }

                for (int i = 0; i < locationsFoundPluginred.Count; i++)
                {
                    if (i == 0)
                    {
                        final += ", vai passar ";
                        if (!String.IsNullOrEmpty(locationsFoundPluginred[i].Preposicao))
                        {
                            final += locationsFoundPluginred[i].Preposicao;
                        }
                        else
                        {
                            final += "por";
                        }

                        final += " ";
                    }

                    final += locationsFoundPluginred[i];

                    if (locationsFoundPluginred.Count - 2 == i)
                    {
                        final += " e ";
                    }
                    else if (locationsFoundPluginred.Count - 3 >= i)
                    {
                        final += ", ";
                    }
                }

                return(final);
            }
            catch (Exception e)
            {
                new ArgumentException("Problema ao faser a frase de forwardinLocations. Msg:" + e.Message);

                throw e;
            }
        }
예제 #4
0
        private void MakeAlert(List <Alert> listAlerts, Radar radar, AirplaneBasic airplane, PluginAlertType alertType = PluginAlertType.High, bool subAlert = false)
        {
            Alert pluginAlert = new Alert(radar, Name, airplane, IconType.NoIcon);

            pluginAlert.AlertType       = alertType;
            pluginAlert.TimeToBeRemoved = DateTime.Now.AddHours(23);

            switch (airplane.State)
            {
            case AirplaneStatus.Cruise:

                pluginAlert.Icon = IconType.Cruise;

                break;

            case AirplaneStatus.Landing:

                pluginAlert.Icon = IconType.Landing;

                break;

            case AirplaneStatus.TakingOff:

                pluginAlert.Icon = IconType.TakingOff;

                break;

            case AirplaneStatus.ParkingOrTaxing:

                pluginAlert.Icon = IconType.Taxing;

                break;
            }

            if (subAlert)
            {
                pluginAlert.ID += "_sub";
            }

            listAlerts.Add(pluginAlert);
        }
예제 #5
0
        public static string GetOverLocation(AirplaneBasic airplane)
        {
            double lat       = airplane.Latitude;
            double lon       = airplane.Longitude;
            double direction = airplane.Direction * Math.PI / 180;

            List <string> locationsFound = new List <string>();

            double currentLat = lat;
            double currentLon = lon;

            if (airplane.State == AirplaneStatus.ParkingOrTaxing)
            {
                var listPlacesOverAirport = ListPlacesAirport.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList();

                if (listPlacesOverAirport.Count > 0)
                {
                    bool hasFound = locationsFound.Where(s => s == listPlacesOverAirport.FirstOrDefault().Name).Count() > 0;
                    if (!hasFound)
                    {
                        locationsFound.Add(listPlacesOverAirport.FirstOrDefault().Name);
                    }
                }
            }
            else
            {
                var listPlacesOver = ListPlacesGPS.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList();

                if (listPlacesOver.Count > 0)
                {
                    bool hasFound = locationsFound.Where(s => s == listPlacesOver.FirstOrDefault().Name).Count() > 0;
                    if (!hasFound)
                    {
                        locationsFound.Add(listPlacesOver.FirstOrDefault().Name);
                    }
                }
            }

            return(locationsFound.FirstOrDefault());
        }
예제 #6
0
 public static bool IsAirplaneInApproximation(AirplaneBasic airplane, Radar radar)
 {
     return(airplane.Altitude <= 28000);
 }