Skip to content

Commit b5302b3

Browse files
authored
Merge pull request #16 from mcrossley/master
v 1.4.3
2 parents 5b96db9 + 2aec7ff commit b5302b3

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

CreateMissing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Exe</OutputType>
55
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
66
<FileVersion>$(PackageVersion)</FileVersion>
7-
<Version>1.4.2</Version>
7+
<Version>1.4.3</Version>
88
<StartupObject>CreateMissing.Program</StartupObject>
99
<TargetFramework>net48</TargetFramework>
1010
<Authors>Mark Crossley</Authors>

Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
535535
// not logged, calculate it
536536
else
537537
{
538-
var wchill = MeteoLib.WindChill(Utils.ConvertUserTempToC(outsidetemp), Utils.ConvertUserWindToKPH(speed));
538+
var wchill = Utils.TempCToUser(MeteoLib.WindChill(Utils.UserTempToC(outsidetemp), Utils.UserWindToKPH(speed)));
539539
if (wchill < rec.LowWindChill)
540540
{
541541
rec.LowWindChill = wchill;
@@ -552,7 +552,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
552552
// not logged, calculate it
553553
else
554554
{
555-
var heatIndex = MeteoLib.HeatIndex(Utils.ConvertUserTempToC(outsidetemp), hum);
555+
var heatIndex = Utils.TempCToUser(MeteoLib.HeatIndex(Utils.UserTempToC(outsidetemp), hum));
556556
if (heatIndex > rec.HighHeatIndex)
557557
{
558558
rec.HighHeatIndex = heatIndex;
@@ -577,7 +577,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
577577
// no logged apparent, calculate it
578578
else
579579
{
580-
var apparent = MeteoLib.ApparentTemperature(Utils.ConvertUserTempToC(outsidetemp), Utils.ConvertUserWindToMS(speed), hum);
580+
var apparent = Utils.TempCToUser(MeteoLib.ApparentTemperature(Utils.UserTempToC(outsidetemp), Utils.UserWindToMS(speed), hum));
581581
if (apparent > rec.HighAppTemp)
582582
{
583583
rec.HighAppTemp = apparent;
@@ -609,7 +609,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
609609
// no logged feels like data available, calculate it
610610
else
611611
{
612-
var feels = MeteoLib.FeelsLike(Utils.ConvertUserTempToC(outsidetemp), Utils.ConvertUserWindToKPH(speed), hum);
612+
var feels = Utils.TempCToUser(MeteoLib.FeelsLike(Utils.UserTempToC(outsidetemp), Utils.UserWindToKPH(speed), hum));
613613
if (feels > rec.HighFeelsLike)
614614
{
615615
rec.HighFeelsLike = feels;
@@ -635,7 +635,7 @@ private static Dayfilerec GetDayRecFromMonthly(DateTime date)
635635
// no logged humidex available, calculate it
636636
else
637637
{
638-
var humidex = MeteoLib.Humidex(Utils.ConvertUserTempToC(outsidetemp), hum);
638+
var humidex = Utils.TempCToUser(MeteoLib.Humidex(Utils.UserTempToC(outsidetemp), hum));
639639
if (humidex > rec.HighHumidex)
640640
{
641641
rec.HighHumidex = humidex;

Updates.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.4.3
2+
—————
3+
- Fix for derived temperatures (wind chill, feels like, apparent) when using Fahrenheit
4+
15
1.4.2
26
—————
37
- Fix crash in solar data

Utils.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static DateTime GetDateTime(DateTime date, string time)
6060
return new DateTime(date.Year, date.Month, date.Day, int.Parse(tim[0]), int.Parse(tim[1]), 0);
6161
}
6262

63-
public static double ConvertUserTempToC(double value)
63+
public static double UserTempToC(double value)
6464
{
6565
if (Program.cumulus.Units.Temp == 1)
6666
{
@@ -73,7 +73,20 @@ public static double ConvertUserTempToC(double value)
7373
}
7474
}
7575

76-
public static double ConvertUserWindToKPH(double wind) // input is in Units.Wind units, convert to km/h
76+
public static double TempCToUser(double value)
77+
{
78+
if (Program.cumulus.Units.Temp == 1)
79+
{
80+
return MeteoLib.CToF(value);
81+
}
82+
else
83+
{
84+
// C
85+
return value;
86+
}
87+
}
88+
89+
public static double UserWindToKPH(double wind) // input is in Units.Wind units, convert to km/h
7790
{
7891
switch (Program.cumulus.Units.Wind)
7992
{
@@ -94,7 +107,7 @@ public static double ConvertUserWindToKPH(double wind) // input is in Units.Wind
94107
};
95108
}
96109

97-
public static double ConvertUserWindToMS(double value)
110+
public static double UserWindToMS(double value)
98111
{
99112
switch (Program.cumulus.Units.Wind)
100113
{
@@ -111,6 +124,23 @@ public static double ConvertUserWindToMS(double value)
111124
};
112125
}
113126

127+
public static double WindMSToUser(double value)
128+
{
129+
switch (Program.cumulus.Units.Wind)
130+
{
131+
case 0:
132+
return value;
133+
case 1:
134+
return value * 2.23693629;
135+
case 2:
136+
return value * 3.6;
137+
case 3:
138+
return value * 1.94384449;
139+
default:
140+
return 0;
141+
}
142+
}
143+
114144
public static int CalcAvgBearing(double x, double y)
115145
{
116146
var avg = 90 - (int)(180 / Math.PI * Math.Atan2(y, x));

0 commit comments

Comments
 (0)