From 01c062675cdff47e8b0c6e502a44f86f173786ee Mon Sep 17 00:00:00 2001 From: Nick White Date: Fri, 5 Feb 2021 15:46:29 +0000 Subject: Make units explicit in variable names, where known --- weather.go | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/weather.go b/weather.go index 996b3e4..ca7fe12 100644 --- a/weather.go +++ b/weather.go @@ -139,20 +139,20 @@ var TypeDescription = map[int]string{ // Our prefered struct type Weather struct { - airquality int - date string - feelsliketemp float64 - humidity int - maxuv int - precipitation int - pressure int - temperature float64 - time string - visibility int - weathertype int - winddir string - windgust float64 - windspeed float64 + airquality int + date string + feelsliketempDegC float64 + humidity int + maxuv int + precipitationPerc int + pressure int + temperatureDegC float64 + time string + visibilityMetres int + weathertype int + winddir string + windgustMph float64 + windspeedMph float64 } var ( @@ -173,16 +173,16 @@ func processBBC(b []byte) []Weather { for _, report := range f.Detailed.Reports { w.date = report.LocalDate w.time = report.Timeslot - w.feelsliketemp = float64(report.FeelsLikeTemperatureC) + w.feelsliketempDegC = float64(report.FeelsLikeTemperatureC) w.humidity = report.Humidity - w.temperature = float64(report.TemperatureC) - w.precipitation = report.PrecipitationProbabilityInPercent + w.temperatureDegC = float64(report.TemperatureC) + w.precipitationPerc = report.PrecipitationProbabilityInPercent w.pressure = report.Pressure - w.visibility = estimateVisibility(report.Visibility) + w.visibilityMetres = estimateVisibility(report.Visibility) w.weathertype = report.WeatherType w.winddir = report.WindDirectionFull - w.windgust = float64(report.GustSpeedMph) - w.windspeed = float64(report.WindSpeedMph) + w.windgustMph = float64(report.GustSpeedMph) + w.windspeedMph = float64(report.WindSpeedMph) weather = append(weather, w) } } @@ -208,17 +208,17 @@ func parseMetWeather(wp WeatherParams) Weather { var w Weather w.airquality = wp.AQIndex - w.feelsliketemp = wp.F + w.feelsliketempDegC = wp.F w.humidity = wp.H w.pressure = wp.P - w.precipitation = wp.PP - w.temperature = wp.T + w.precipitationPerc = wp.PP + w.temperatureDegC = wp.T w.maxuv = wp.UV - w.visibility = wp.V + w.visibilityMetres = wp.V w.weathertype = wp.WT w.winddir = wp.WD - w.windgust = wp.WG - w.windspeed = wp.WS * mpsToMphMultiplier + w.windgustMph = wp.WG + w.windspeedMph = wp.WS * mpsToMphMultiplier return w } @@ -302,8 +302,8 @@ func main() { if !ok { desc = fmt.Sprintf("%d", w.weathertype) } - fmt.Printf("%18s, Temp: %4.1f°C, ", desc, w.temperature) - fmt.Printf("Rain: %2d%%, Wind: %4.1fmph\n", w.precipitation, w.windspeed) + fmt.Printf("%18s, Temp: %4.1f°C, ", desc, w.temperatureDegC) + fmt.Printf("Rain: %2d%%, Wind: %4.1fmph\n", w.precipitationPerc, w.windspeedMph) if *verbose { fmt.Printf("%+v\n\n", w) } -- cgit v1.2.3