Пример #1
0
        public void UpdateWeatherForm(string CityName)
        {
            WeatherObject.RootObject weatherRoot = Weather.WeatherData(CityName); // deserialised json with weather data

            // Location variables
            Lat         = Convert.ToString(weatherRoot.coord.Lat);
            Lon         = Convert.ToString(weatherRoot.coord.Lon);
            CountryCode = weatherRoot.sys.Country;

            // Main variables
            Temp      = Convert.ToString(weatherRoot.main.Temp) + "C";
            FeelsLike = Convert.ToString(weatherRoot.main.Feels_like) + "C";
            Humidity  = Convert.ToString(weatherRoot.main.Humidity) + "%";
            WindSpeed = Convert.ToString(weatherRoot.wind.Speed * 2.23694);
            while (WindSpeed.Length > 5)
            {
                WindSpeed = WindSpeed.Remove(WindSpeed.Length - 1, 1);
            }
            WindSpeed  = WindSpeed + "mph";
            CloudCover = Convert.ToString(weatherRoot.clouds.All) + "%";

            // Time variables
            Timezone = TimezoneToUTC(weatherRoot.Timezone);
            Sunrise  = Convert.ToString(UnixTimeStampToDateTime(weatherRoot.sys.Sunrise));
            Sunset   = Convert.ToString(UnixTimeStampToDateTime(weatherRoot.sys.Sunset));
        }
Пример #2
0
        public async Task <ActionResult <WindSpeed> > GetWindSpeed()
        {
            WindSpeed windSpeed = new WindSpeed();

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                // New code:
                HttpResponseMessage response = await client.GetAsync(new Uri(_configuration.GetSection("wetherAPI").GetSection("baseUrl").Value));

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var data = JsonConvert.DeserializeObject <WeatherRoot>(result);
                    // convert wind speed m/s to km/h

                    var step1 = data.wind.speed * 18;
                    var KMH   = Math.Round((step1 / 5), 2);

                    windSpeed.windKmH = Convert.ToInt32(KMH);
                    windSpeed.windMS  = Convert.ToDecimal(data.wind.speed);
                }
            }
            return(windSpeed);
        }
Пример #3
0
        protected override int AddToHashCode(int hashcode)
        {
            hashcode = (hashcode * 37) + WindSpeed.GetHashCode();
            hashcode = (hashcode * 37) + WaveAge.GetHashCode();

            return(hashcode);
        }
Пример #4
0
    private void refreshWind()
    {
        windDirection = Random.Range(0, 360);
        int _windSpeed = Random.Range(0, 3);

        if (isTypoon)
        {
            _windSpeed = 3;
        }
        switch (_windSpeed)
        {
        case 0:
            //대충 세기 1정도
            windSpeed = global::WindSpeed.NORMAL;
            break;

        case 1:
            //세기 2정도
            windSpeed = global::WindSpeed.MIDDLE;
            break;

        case 2:
            //세기 3정도
            windSpeed = global::WindSpeed.STRONG;
            break;

        case 3:
            windSpeed = global::WindSpeed.TYPOON;
            break;
        }
        windSpeedText.text = windSpeed.ToString();
        windDirectionImage.transform.rotation = Quaternion.Euler(0, 0, windDirection);
    }
Пример #5
0
        public string WeatherDataListing()
        {
            //Forms the weather data into a string separated by line feeds
            string wsList = "";

            if (weaList.Count > 0)
            {
                {
                    wsList += "WriteDate:\t" + ReportDate.ToString("hh:mm:ss");
                    wsList += "\r\n" + "TempScale:\t" + TempScale.ToString();
                    wsList += "\r\n" + "WindScale:\t" + WindScale.ToString();
                    wsList += "\r\n" + "SkyTemp:\t" + SkyTemp.ToString();
                    wsList += "\r\n" + "AmbTemp:\t" + AmbTemp.ToString();
                    wsList += "\r\n" + "SenTemp:\t" + SenTemp.ToString();
                    wsList += "\r\n" + "WindSpeed:\t" + WindSpeed.ToString();
                    wsList += "\r\n" + "Humidity:\t\t" + Humidity.ToString();
                    wsList += "\r\n" + "DewPoint:\t" + DewPoint.ToString();
                    wsList += "\r\n" + "DewHeat:\t" + DewHeat.ToString();
                    wsList += "\r\n" + "RainFlag:\t\t" + RainFlag.ToString();
                    wsList += "\r\n" + "WetFlag:\t\t" + WetFlag.ToString();
                    wsList += "\r\n" + "ElapsedTime:\t" + ElapsedSeconds.ToString();
                    wsList += "\r\n" + "LastDataWrite:\t" + LastDataWrite.ToString("hh:mm:ss");
                    wsList += "\r\n" + "Cloudiness:\t" + Cloudiness.ToString();
                    wsList += "\r\n" + "Windiness:\t" + Windiness.ToString();
                    wsList += "\r\n" + "Raininess:\t" + Raininess.ToString();
                    wsList += "\r\n" + "Darkness:\t" + Darkness.ToString();
                    wsList += "\r\n" + "RoofCloseFlag:\t" + RoofCloseFlag.ToString();
                    wsList += "\r\n" + "AlertFlag:\t\t" + AlertFlag.ToString();
                }
            }
            return(wsList);
        }
Пример #6
0
        private static void ParseXForecast(XElement xForecast, List <AbstractParameter> parameters)
        {
            parameters.Add(Temperature.FromDouble(
                               xForecast.Element("temp").Element("metric").Value));

            parameters.Add(new Cloudiness(
                               xForecast.Element("sky").Value));

            parameters.Add(WindSpeed.FromKmph(
                               xForecast.Element("wspd").Element("metric").Value));

            parameters.Add(new WindDirection(
                               xForecast.Element("wdir").Element("degrees").Value));

            parameters.Add(Humidity.FromDouble(
                               xForecast.Element("humidity").Value));

            parameters.Add(Pressure.FromHpa(
                               xForecast.Element("mslp").Element("metric").Value));

            var precip = xForecast.Element("qpf").Element("metric").Value;

            if (precip != "")
            {
                parameters.Add(new PrecipitationAmount(
                                   precip));
            }
            else
            {
                parameters.Add(new PrecipitationAmount(
                                   0));
            }
        }
Пример #7
0
        private static void ParseXForecast(XElement xForecast, List <AbstractParameter> parameters)
        {
            parameters.Add(Temperature.FromDouble(
                               xForecast.Element("temperature").Attribute("value").Value));

            parameters.Add(Pressure.FromHpa(
                               xForecast.Element("pressure").Attribute("value").Value));

            var xPrecipVal = xForecast.Element("precipitation").Attribute("value");

            if (xPrecipVal != null)
            {
                parameters.Add(new PrecipitationAmount(
                                   xPrecipVal.Value));
            }
            else
            {
                parameters.Add(new PrecipitationAmount(0));
            }

            parameters.Add(new Humidity(
                               xForecast.Element("humidity").Attribute("value").Value));

            parameters.Add(new Cloudiness(
                               xForecast.Element("clouds").Attribute("all").Value));

            parameters.Add(WindDirection.FromDouble(
                               xForecast.Element("windDirection").Attribute("deg").Value));

            parameters.Add(WindSpeed.FromDouble(
                               xForecast.Element("windSpeed").Attribute("mps").Value));
        }
Пример #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            WindSpeed windSpeed = db.Winds.Find(id);

            db.Winds.Remove(windSpeed);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        internal WeatherResult ToWeatherResult(LocationResult location)
        {
            ITemperature      temperature = new DegreesFahrenheit(this.Temperature.Value);
            WindSpeed         windSpeed   = new WindSpeed(new MilesPerHour(this.Wind.Speed.Imperial.Value), this.Wind.Direction.Degrees);
            LatitudeLongitude latLong     = new LatitudeLongitude(location.GeoPosition.Latitude, location.GeoPosition.Longitude);

            return(new WeatherResult(temperature, latLong, windSpeed));
        }
Пример #10
0
 public ActionResult Edit([Bind(Include = "Id,Location,Day,Hour,Velocity")] WindSpeed windSpeed)
 {
     if (ModelState.IsValid)
     {
         db.Entry(windSpeed).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(windSpeed));
 }
Пример #11
0
        public void WindChillFactorTest_WindspeedTooLow()
        {
            WindSpeed   ws = new WindSpeed(2.9, WindSpeed.Unit.MilesPerHour);
            Temperature t  = new Temperature(5, Temperature.Scale.Celsius);

            Assert.ThrowsException <MeteorologyException>(() =>
            {
                WindChillFactor factor = new WindChillFactor(t, ws);
            });
        }
Пример #12
0
        public void WindChillFactorTest_TemperatureTooHigh()
        {
            WindSpeed   ws = new WindSpeed(10, WindSpeed.Unit.MeterPerSecond);
            Temperature t  = new Temperature(50.1, Temperature.Scale.Fahrenheit);

            Assert.ThrowsException <MeteorologyException>(() =>
            {
                WindChillFactor factor = new WindChillFactor(t, ws);
            });
        }
Пример #13
0
        public ActionResult Create([Bind(Include = "Id,Location,Day,Hour,Velocity")] WindSpeed windSpeed)
        {
            if (ModelState.IsValid)
            {
                db.Winds.Add(windSpeed);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(windSpeed));
        }
Пример #14
0
        public void WindChillFactorTest_WindspeedNotTooLow()
        {
            WindSpeed   ws = new WindSpeed(3, WindSpeed.Unit.MilesPerHour);
            Temperature t  = new Temperature(5, Temperature.Scale.Celsius);

            WindChillFactor factor = new WindChillFactor(t, ws);

            Assert.AreEqual(4.2, Math.Round(factor.WindChillCelsius, 1));
            Assert.AreEqual(39.5, Math.Round(factor.WindChillFahrenheit, 1));
            Assert.AreEqual(673.3, Math.Round(factor.WattsPerMeterSquared, 1));
        }
Пример #15
0
        public void WindChillFactorTest_TemperatureNotTooHigh()
        {
            WindSpeed   ws = new WindSpeed(10, WindSpeed.Unit.MeterPerSecond);
            Temperature t  = new Temperature(50, Temperature.Scale.Fahrenheit);

            WindChillFactor factor = new WindChillFactor(t, ws);

            Assert.AreEqual(6.2, Math.Round(factor.WindChillCelsius, 1));
            Assert.AreEqual(43.2, Math.Round(factor.WindChillFahrenheit, 1));
            Assert.AreEqual(857.3, Math.Round(factor.WattsPerMeterSquared, 1));
        }
Пример #16
0
        public void WindChillFactorTest_ValidInput()
        {
            WindSpeed   ws = new WindSpeed(10, WindSpeed.Unit.MeterPerSecond);
            Temperature t  = new Temperature(5, Temperature.Scale.Celsius);

            WindChillFactor factor = new WindChillFactor(t, ws);

            Assert.AreEqual(-0.4, Math.Round(factor.WindChillCelsius, 1));
            Assert.AreEqual(31.3, Math.Round(factor.WindChillFahrenheit, 1));
            Assert.AreEqual(1043.7, Math.Round(factor.WattsPerMeterSquared, 1));
        }
Пример #17
0
        //============================================================================*
        // CompareAtmospherics()
        //============================================================================*

        public int CompareAtmospherics(cBallistics Ballistics)
        {
            int rc = WindDirection.CompareTo(Ballistics.WindDirection);

            if (rc == 0)
            {
                rc = WindSpeed.CompareTo(Ballistics.WindSpeed);
            }

            return(rc);
        }
        public static WeatherResult ToResult(this WeatherData weatherData)
        {
            Kelvin kelvin = new Kelvin(weatherData.main.temp);

            LatitudeLongitude location = new LatitudeLongitude(weatherData.coord.lat, weatherData.coord.lon);

            WindSpeed windSpeed = new WindSpeed(new KilometersPerHour(weatherData.wind.speed), weatherData.wind.deg);

            WeatherResult result = new WeatherResult(kelvin, location, windSpeed);

            return(result);
        }
Пример #19
0
        // GET: WindSpeeds/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WindSpeed windSpeed = db.Winds.Find(id);

            if (windSpeed == null)
            {
                return(HttpNotFound());
            }
            return(View(windSpeed));
        }
Пример #20
0
    private void Start()
    {
        player      = GameObject.Find("Player");
        playerLocal = player.GetComponent <Transform>();

        rigid         = GetComponent <Rigidbody>();
        mapController = GameObject.Find("MapController");
        wind          = mapController.GetComponent <WindSpeed>();
        par           = mapController.GetComponent <Par>();

        projectileCamera = GameObject.Find("ShotCamera").GetComponent <LookAtProjectile>();

        //Debug.Log(wind.jesusRocks);
    }
Пример #21
0
 /// <summary>
 /// initForecastObjects init and allocate all forecast objects
 /// </summary>
 private void initForecastObjects()
 {
     this.location      = new Location();
     this.sunRise       = new SunRise();
     this.temperature   = new Temperature();
     this.humidity      = new Humidity();
     this.pressure      = new Pressure();
     this.windSpeed     = new WindSpeed();
     this.windDirection = new WindDirection();
     this.clouds        = new Clouds();
     this.precipitation = new Precipitation();
     this.weather       = new Weather();
     this.lastupdate    = new Lastupdate();
 }
Пример #22
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("WindSpeed", true, out subEle);
            subEle.Value = WindSpeed.ToString();

            ele.TryPathTo("CloudSpeed/Lower", true, out subEle);
            subEle.Value = CloudSpeedLower.ToString();

            ele.TryPathTo("CloudSpeed/Upper", true, out subEle);
            subEle.Value = CloudSpeedUpper.ToString();

            ele.TryPathTo("TransitionDelta", true, out subEle);
            subEle.Value = TransitionDelta.ToString();

            ele.TryPathTo("SunGlare", true, out subEle);
            subEle.Value = SunGlare.ToString();

            ele.TryPathTo("SunDamage", true, out subEle);
            subEle.Value = SunDamage.ToString();

            ele.TryPathTo("Precipitation/BeginFadeIn", true, out subEle);
            subEle.Value = PrecipitationBeginFadeIn.ToString();

            ele.TryPathTo("Precipitation/EndFadeOut", true, out subEle);
            subEle.Value = PrecipitationEndFadeOut.ToString();

            ele.TryPathTo("Thunder_Lightning/BeginFadeIn", true, out subEle);
            subEle.Value = Thunder_LightningBeginFadeIn.ToString();

            ele.TryPathTo("Thunder_Lightning/EndFadeOut", true, out subEle);
            subEle.Value = Thunder_LightningEndFadeOut.ToString();

            ele.TryPathTo("Thunder_Lightning/Frequency", true, out subEle);
            subEle.Value = Thunder_LightningFrequency.ToString();

            ele.TryPathTo("Classification", true, out subEle);
            subEle.Value = Classification.ToString();

            ele.TryPathTo("LightningColor/Red", true, out subEle);
            subEle.Value = LightningColorRed.ToString();

            ele.TryPathTo("LightningColor/Green", true, out subEle);
            subEle.Value = LightningColorGreen.ToString();

            ele.TryPathTo("LightningColor/Blue", true, out subEle);
            subEle.Value = LightningColorBlue.ToString();
        }
Пример #23
0
 protected bool Equals(ForecastEntity other)
 {
     return(Id == other.Id &&
            string.Equals(City, other.City) &&
            Date.Equals(other.Date) &&
            Pressure.Equals(other.Pressure) &&
            Humidity.Equals(other.Humidity) &&
            TemperatureMorning.Equals(other.TemperatureMorning) &&
            TemperatureDay.Equals(other.TemperatureDay) &&
            TemperatureEvening.Equals(other.TemperatureEvening) &&
            TemperatureNight.Equals(other.TemperatureNight) &&
            WindSpeed.Equals(other.WindSpeed) &&
            string.Equals(Description, other.Description) &&
            string.Equals(Icon, other.Icon));
 }
Пример #24
0
        /// <summary>
        /// Returns true if Forecast instances are equal
        /// </summary>
        /// <param name="other">Instance of Forecast to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Forecast other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                     ) &&
                 (
                     Pressure == other.Pressure ||
                     Pressure != null &&
                     Pressure.Equals(other.Pressure)
                 ) &&
                 (
                     Humidity == other.Humidity ||
                     Humidity != null &&
                     Humidity.Equals(other.Humidity)
                 ) &&
                 (
                     WindSpeed == other.WindSpeed ||
                     WindSpeed != null &&
                     WindSpeed.Equals(other.WindSpeed)
                 ) &&
                 (
                     Clouds == other.Clouds ||
                     Clouds != null &&
                     Clouds.Equals(other.Clouds)
                 ) &&
                 (
                     Temperature == other.Temperature ||
                     Temperature != null &&
                     Temperature.Equals(other.Temperature)
                 ) &&
                 (
                     Weather == other.Weather ||
                     Weather != null &&
                     Weather.Equals(other.Weather)
                 ));
        }
Пример #25
0
        private static void ParseXForecast(XElement xForecast, List <AbstractParameter> parameters)
        {
            parameters.Add(new Temperature(
                               xForecast.Element("tempMaxC").Value));
            parameters.Add(new Temperature(
                               xForecast.Element("tempMinC").Value));

            parameters.Add(WindSpeed.FromKmph(
                               xForecast.Element("windspeedKmph").Value));

            parameters.Add(new WindDirection(
                               xForecast.Element("winddirDegree").Value));

            parameters.Add(new PrecipitationAmount(
                               xForecast.Element("precipMM").Value));
        }
Пример #26
0
    public void getWeather()
    {
        Observation        thisObs              = JsonUtility.FromJson <Observation>(jsonString);
        Properties         thisObsProperties    = thisObs.properties;
        WindDirection      thisObsWindDirection = thisObsProperties.windDirection;
        WindSpeed          thisObsWindSpeed     = thisObsProperties.windSpeed;
        Temperature        thisObsTemp          = thisObsProperties.temperature;
        BarometricPressure thisObsBaro          = thisObsProperties.barometricPressure;

        temperature        = thisObsTemp.value;
        windSpeed          = thisObsWindSpeed.value;
        windDir            = thisObsWindDirection.value;
        BarometricPressure = thisObsBaro.value;

        string rawObservation = thisObsProperties.rawMessage;

        uitext.text = thisObs.properties.windDirection.value.ToString();
        Debug.Log(windDir.ToString() + " /" + windSpeed);
    }
Пример #27
0
 public void GetWindSpeed(Action <IList <WindSpeed> > action)
 {
     DownloadAndParseJsonData("http://demeter.usask.ca/buffer_zone_multiplier/bufferzone_db_data.php?table=wind_speed", jValue =>
     {
         var ret = new List <WindSpeed>();
         foreach (var v in jValue)
         {
             var j    = (JsonValue)v;
             var curr = new WindSpeed()
             {
                 Id  = j["wind_speed_id"],
                 Min = j["min"],
                 Max = j["max"]
             };
             ret.Add(curr);
         }
         action(ret);
     });
 }
Пример #28
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Date.GetHashCode();
         hashCode = (hashCode * 397) ^ Pressure.GetHashCode();
         hashCode = (hashCode * 397) ^ Humidity.GetHashCode();
         hashCode = (hashCode * 397) ^ TemperatureMorning.GetHashCode();
         hashCode = (hashCode * 397) ^ TemperatureDay.GetHashCode();
         hashCode = (hashCode * 397) ^ TemperatureEvening.GetHashCode();
         hashCode = (hashCode * 397) ^ TemperatureNight.GetHashCode();
         hashCode = (hashCode * 397) ^ WindSpeed.GetHashCode();
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Icon != null ? Icon.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #29
0
        private static void ParseMainXForecast(XElement xForecast, List <AbstractParameter> parameters)
        {
            parameters.Add(Temperature.FromDouble(
                               xForecast.Element("temperature").Attribute("value").Value));

            parameters.Add(WindDirection.FromDouble(
                               xForecast.Element("windDirection").Attribute("deg").Value));

            parameters.Add(WindSpeed.FromDouble(
                               xForecast.Element("windSpeed").Attribute("mps").Value));

            parameters.Add(Humidity.FromDouble(
                               xForecast.Element("humidity").Attribute("value").Value));

            parameters.Add(Pressure.FromHpa(
                               xForecast.Element("pressure").Attribute("value").Value));

            parameters.Add(Cloudiness.FromDouble(
                               xForecast.Element("cloudiness").Attribute("percent").Value));
        }
Пример #30
0
        public void Start()
        {
            World.MakeAnnouncement("A storm is coming!", null);

            switch (TypeofStorm)
            {
            case StormType.RainStorm:
                SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_rain_storm_alert, 0.15f);
                break;

            case StormType.SnowStorm:
                SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_snow_storm_alert, 0.15f);
                break;
            }

            BoundingBox bounds         = World.ChunkManager.Bounds;
            Vector3     extents        = bounds.Extents();
            Vector3     center         = bounds.Center();
            Vector3     windNormalized = WindSpeed / WindSpeed.Length();
            Vector3     offset         = new Vector3(-windNormalized.X * extents.X + center.X, bounds.Max.Y + 5, -windNormalized.Z * extents.Z + center.Z);
            Vector3     perp           = new Vector3(-windNormalized.Z, 0, windNormalized.X);
            int         numClouds      = (int)(MathFunctions.RandInt(10, 100) * Intensity);
            int         numCloudLayers = MathFunctions.RandInt(1, 5);

            for (int layer = 0; layer < numCloudLayers; layer++)
            {
                for (int i = 0; i < numClouds; i++)
                {
                    Vector3 cloudPos = offset + perp * 5 * (i - numClouds / 2) + MathFunctions.RandVector3Cube() * 10 + windNormalized * 2 * layer;

                    Cloud cloud = new Cloud(World.ComponentManager, Intensity, 5, offset.Y + MathFunctions.Rand(-3.0f, 3.0f), cloudPos, TypeofStorm == StormType.RainStorm ? 0.15f : 0.0f)
                    {
                        Velocity    = WindSpeed * 0.5f,
                        TypeofStorm = TypeofStorm
                    };
                    Clouds.Add(cloud);
                    World.ComponentManager.RootComponent.AddChild(cloud);
                }
            }
            IsInitialized = true;
        }
 /// <summary>
 /// initForecastObjects init and allocate all forecast objects
 /// </summary>
 private void initForecastObjects()
 {
     this.location = new Location();
     this.sunRise = new SunRise();
     this.temperature = new Temperature();
     this.humidity = new Humidity();
     this.pressure = new Pressure();
     this.windSpeed = new WindSpeed();
     this.windDirection = new WindDirection();
     this.clouds = new Clouds();
     this.precipitation = new Precipitation();
     this.weather = new Weather();
     this.lastupdate = new Lastupdate();
 }