public FiwareWeatherReport(string weatherCondition, WeatherMappings weatherMappings, DatasetAccidentReport accidentReport, long uid) { if (string.IsNullOrWhiteSpace(weatherCondition)) { return; } // Map weather condition to more statistical-friendly properties SetWeatherEventProperties(weatherCondition, weatherMappings); Humidity = accidentReport.Humidity; Precipitation = accidentReport.Precipitation; Pressure = accidentReport.Pressure; ReportTime = accidentReport.WeatherTimestamp; Temperature = accidentReport.Temperature; Visibility = accidentReport.Visibility; WindChill = accidentReport.WindChill; WindDirection = accidentReport.WindDirection; WindSpeed = accidentReport.WindSpeed; City = accidentReport.City; Country = accidentReport.Country; County = accidentReport.County; State = accidentReport.State; ZipCode = accidentReport.ZipCode; UID = uid; }
/// <summary> /// This method maps the Original Weather Condition value /// to more statistical appropriate sub-properties /// </summary> /// <param name="weatherCondition"></param> private void SetWeatherEventProperties(string weatherCondition, WeatherMappings weatherMappings) { this.OriginalWeatherConditionDescription = weatherCondition; var weatherMapping = weatherMappings.Mappings .SingleOrDefault(wm => wm.Name.ToLower() == weatherCondition.ToLower()); if (weatherMapping == null) { throw new ArgumentException($"Weather mapping with name of {weatherCondition} not found."); } this.Severity = weatherMapping.Severity; this.WeatherEvent = weatherMapping.WeatherEvent; this.CloudCoverage = weatherMapping.CloudCoverage; }