示例#1
0
        public StatAnnee(int VM, int Wilaya)
        {
            int i, jrs = 0, jrs2 = 0;

            //Sauvegarde de la wilaya
            this.Wilaya = Wilaya;
            DataWilaya Donnees = IOData.LireDonnesWilaya("../../Donnee", Wilaya);

            if (Donnees != null && Donnees.NombreDeJour() != 0)
            {
                startDate = Donnees.GetElementAt(0).DateDuJour;
                endDate   = Donnees.GetElementAt(Donnees.NombreDeJour() - 1).DateDuJour;
            }
            //Initialisation de max et min
            Tuple <int, int, int, float> Max = new Tuple <int, int, int, float>(0, 0, 0, -1000), Min = new Tuple <int, int, int, float>(0, 0, 0, 1000);
            List <Tuple <int, float> >   Tableau = new List <Tuple <int, float> >();
            float  somme        = 0;
            double sommeMoyenne = 0;

            for (i = 0; i < Donnees.NombreDeJour(); i++)
            {
                switch (VM)
                {
                case 1:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideTempuratureMin())
                    {
                        somme += Donnees.GetElementAt(i).TempuratureMin;
                        jrs++;
                        if (Donnees.GetElementAt(i).TempuratureMin >= Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMin < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMin);
                        }
                    }
                    break;

                case 2:     // Temperature max
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideTempuratureMax())
                    {
                        somme += Donnees.GetElementAt(i).TempuratureMax;
                        jrs++;
                        if (Donnees.GetElementAt(i).TempuratureMax >= Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMax < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).TempuratureMax);
                        }
                    }
                    break;

                case 3:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideHumidite())
                    {
                        somme += Donnees.GetElementAt(i).Humidite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Humidite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Humidite);
                        }
                        if (Donnees.GetElementAt(i).Humidite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Humidite);
                        }
                    }
                    break;

                case 4:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VidePression())
                    {
                        somme += Donnees.GetElementAt(i).Pression;
                        jrs++;
                        if (Donnees.GetElementAt(i).Pression > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Pression);
                        }
                        if (Donnees.GetElementAt(i).Pression < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Pression);
                        }
                    }
                    break;

                case 5:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VidePrecipitation())
                    {
                        somme += Donnees.GetElementAt(i).Humidite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Precipitation > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Precipitation);
                        }
                        if (Donnees.GetElementAt(i).Precipitation < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Precipitation);
                        }
                    }
                    break;

                case 6:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideDistanceDeVisibilite())
                    {
                        somme += Donnees.GetElementAt(i).DistanceDeVisibilite;
                        jrs++;
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                    }
                    break;

                case 7:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideVitesseDuVent())
                    {
                        somme += Donnees.GetElementAt(i).VitesseDuVent;
                        jrs++;
                        if (Donnees.GetElementAt(i).VitesseDuVent > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        if (Donnees.GetElementAt(i).VitesseDuVent < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                    }
                    break;

                case 8:
                    if (Donnees.GetElementAt(i).Existe&& !Donnees.GetElementAt(i).VideNebulosite())
                    {
                        somme += Donnees.GetElementAt(i).Nebulosite;
                        jrs++;
                        if (Donnees.GetElementAt(i).Nebulosite > Max.Item4)
                        {
                            Max = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Nebulosite);
                        }
                        if (Donnees.GetElementAt(i).Nebulosite < Min.Item4)
                        {
                            Min = new Tuple <int, int, int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DateDuJour.Month, Donnees.GetElementAt(i).DateDuJour.Year, Donnees.GetElementAt(i).Nebulosite);
                        }
                    }
                    break;
                }
                // Ajout du Tuple si fin de l'année
                if (i + 1 < Donnees.NombreDeJour())
                {
                    if (Donnees.GetElementAt(i).DateDuJour.Year != Donnees.GetElementAt(i + 1).DateDuJour.Year&& jrs != 0)
                    {
                        jrs2         += jrs;
                        sommeMoyenne += somme;
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Year, somme / jrs));
                        somme = 0;
                        jrs   = 0;
                    }
                }
            }

            if (jrs2 != 0)
            {
                moyenne = (float)(sommeMoyenne / jrs2);
            }
            this.Tableau = Tableau;
            this.Max     = Max;
            this.Min     = Min;
        }
示例#2
0
        //Constructeur de la classe
        public StatJour(int VM, int Wilaya, int Annee, int Mois)
        {
            int i;

            //Sauvegarde du mois et de l'annee
            this.Mois   = Mois;
            this.Annee  = Annee;
            this.Wilaya = Wilaya;
            //Initialisation de max et min
            Tuple <int, float>         Max = new Tuple <int, float>(0, -1000), Min = new Tuple <int, float>(0, 1000);
            List <Tuple <int, float> > Tableau = new List <Tuple <int, float> >();
            DataWilaya Donnees = IOData.LireDonnesWilaya("../../Donnee", Wilaya);

            for (i = 0; i < Donnees.NombreDeJour(); i++)
            {
                if ((Donnees.GetElementAt(i).DateDuJour.Month == Mois) && (Donnees.GetElementAt(i).DateDuJour.Year == Annee))
                {
                    switch (VM)
                    {
                    case 1:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin));
                        if (Donnees.GetElementAt(i).TempuratureMin <= Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMin > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMin);
                        }
                        break;

                    case 2:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax));
                        if (Donnees.GetElementAt(i).TempuratureMax <= Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        if (Donnees.GetElementAt(i).TempuratureMax > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).TempuratureMax);
                        }
                        break;

                    case 3:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite));
                        if (Donnees.GetElementAt(i).Humidite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite);
                        }
                        if (Donnees.GetElementAt(i).Humidite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Humidite);
                        }
                        break;

                    case 4:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression));
                        if (Donnees.GetElementAt(i).Pression < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression);
                        }
                        if (Donnees.GetElementAt(i).Pression > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Pression);
                        }
                        break;

                    case 5:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation));
                        if (Donnees.GetElementAt(i).Precipitation < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation);
                        }
                        if (Donnees.GetElementAt(i).Precipitation > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Precipitation);
                        }
                        break;

                    case 6:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite));
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        if (Donnees.GetElementAt(i).DistanceDeVisibilite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).DistanceDeVisibilite);
                        }
                        break;

                    case 7:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent));
                        if (Donnees.GetElementAt(i).VitesseDuVent < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        if (Donnees.GetElementAt(i).VitesseDuVent > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).VitesseDuVent);
                        }
                        break;

                    case 8:
                        Tableau.Add(new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite));
                        if (Donnees.GetElementAt(i).Nebulosite < Min.Item2)
                        {
                            Min = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite);
                        }
                        if (Donnees.GetElementAt(i).Nebulosite > Max.Item2)
                        {
                            Max = new Tuple <int, float>(Donnees.GetElementAt(i).DateDuJour.Day, Donnees.GetElementAt(i).Nebulosite);
                        }
                        break;
                    }
                }
            }
            this.Tableau = Tableau;
            this.Max     = Max;
            this.Min     = Min;
        }