/// <summary> /// Gets the current weather conditions for the given zip code /// </summary> /// <param name="zipCode"></param> /// <returns></returns> public CurrentConditions GetCurrentConditions(string zipCode) { ZipCodeInfo zipCodeObject = this.zipCodeService.GetZipCode(zipCode); NoaaWeatherClient noaaClient = new NoaaWeatherClient(); NoaaResponse response = noaaClient.GetWeatherConditions(zipCodeObject.Latitude.Value, zipCodeObject.Longitude.Value); return(this.MapResponseObject(response)); }
public void TestGetCurrentConditionsFromNoaa() { // Arrange double latitude = 44.261917; double longitude = -88.414525; // Act NoaaWeatherClient client = new NoaaWeatherClient(); NoaaResponse response = client.GetWeatherConditions(latitude, longitude); // Assert Assert.NotNull(response); }
/// <summary> /// Maps the NOAA response object to our standard response object /// </summary> /// <param name="response">A NoaaResponse object of the response received from the NOAA service</param> /// <returns></returns> internal CurrentConditions MapResponseObject(NoaaResponse response) { CurrentConditions currentConditions = new CurrentConditions(); currentConditions.Source = "NOAA"; currentConditions.LocationName = response.location.areaDescription; currentConditions.Latitide = Convert.ToDouble(response.location.latitude); currentConditions.Longitude = Convert.ToDouble(response.location.longitude); //currentConditions.ObservationTime = DateTime.ParseExact(response.currentobservation.Date, "dd MMM HH:mm", CultureInfo.InvariantCulture); currentConditions.ConditionsDescription = response.currentobservation.Weather; currentConditions.Temperature = Convert.ToDouble(response.currentobservation.Temp); currentConditions.Humidity = Convert.ToDouble(response.currentobservation.Relh); currentConditions.Dewpoint = Convert.ToDouble(response.currentobservation.Dewp); currentConditions.Windchill = ConvertWindchillString(response.currentobservation.WindChill); currentConditions.WindSpeed = Convert.ToDouble(response.currentobservation.Winds); currentConditions.WindSpeedGusts = Convert.ToDouble(response.currentobservation.Gust); currentConditions.WindDirectionDegrees = Convert.ToDouble(response.currentobservation.Windd); currentConditions.WindDirection = this.MapWindDirection(response.currentobservation.Windd); return(currentConditions); }