Projekt

Obecné

Profil

Stáhnout (2.1 KB) Statistiky
| Větev: | Tag: | Revize:
1
namespace ServerApp.Parser.OutputInfo
2
{
3
    /// <summary>
4
    /// Weather conditions in regards to sun level
5
    /// </summary>
6
    /// <author>Alex Konig</author>
7
    public enum WeatherConditions
8
    {
9
        Sunny, Cloudy, Overcast, Dark
10
    }
11

    
12
    /// <summary>
13
    /// Transfers lux values to weather conditions and vice versa
14
    /// </summary>
15
    /// <author>Alex Konig</author>
16
    public static class ValueToConditions
17
    {
18
        /// <summary>
19
        /// Lux to weather conditions
20
        /// </summary>
21
        /// <param name="lux">Lux value</param>
22
        /// <returns>Weather conditions</returns>
23
        public static WeatherConditions TransferLuxToConditions(double lux)
24
        {
25
            if (lux > 40_000)
26
                return WeatherConditions.Sunny;
27

    
28
            if (lux > 20_000)
29
                return WeatherConditions.Cloudy;
30

    
31
            // TODO tohle bylo 10_000, jak mi to má vycházet, zkusit na hourly data
32
            if (lux != 0)
33
                return WeatherConditions.Overcast;
34

    
35
            return WeatherConditions.Dark;
36
        }
37

    
38
        /// <summary>
39
        /// Weather conditions to average lux
40
        /// </summary>
41
        /// <param name="condition">Weather conditions</param>
42
        /// <returns>Lux value</returns>
43
        internal static double TransferConditionsToLux(WeatherConditions condition)
44
        {
45
            if (condition == WeatherConditions.Sunny)
46
                return 60_000;
47

    
48
            if (condition == WeatherConditions.Cloudy)
49
                return 30_000;
50

    
51
            if (condition == WeatherConditions.Overcast)
52
                return 10_000;
53

    
54
            if (condition == WeatherConditions.Dark)
55
                return 0;
56

    
57
            return -1;
58
        }
59

    
60
        internal static WeatherConditions CloudCoverToConditions(int cloudCover)
61
        {
62
            if (cloudCover >= 66)
63
                return WeatherConditions.Overcast;
64

    
65
            if (cloudCover >= 33)
66
                return WeatherConditions.Cloudy;
67

    
68
            if (cloudCover >= 0)
69
                return WeatherConditions.Sunny;
70

    
71
            return WeatherConditions.Dark;
72
        }
73
    }
74
}
(2-2/3)