Skip to content

Commit 968a45b

Browse files
committed
refactor: Patch by sbalazs due to single issue
1 parent 0bb2c6d commit 968a45b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

baseline/Common/baseline.common.pas

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ interface
2121
PWeatherStation = ^TWeatherStation;
2222
TWeatherStation = record
2323
FStation: String[100];
24-
FMin: Single;
25-
FMax: Single;
26-
FTot: Single;
24+
FMin: Int64;
25+
FMax: Int64;
26+
FTot: Int64;
2727
FCnt: Integer;
2828

2929
end;
@@ -34,7 +34,7 @@ TBaseline = class(TObject)
3434
FStationNames: TStringList;
3535
FHashStationList: TFPHashList;
3636

37-
procedure AddToHashList(AStation: String; ATemp: Single);
37+
procedure AddToHashList(AStation: String; ATemp: Int64);
3838
procedure BuildHashList;
3939
protected
4040
public
@@ -112,7 +112,7 @@ destructor TBaseline.Destroy;
112112
inherited Destroy;
113113
end;
114114

115-
procedure TBaseline.AddToHashList(AStation: String; ATemp: Single);
115+
procedure TBaseline.AddToHashList(AStation: String; ATemp: Int64);
116116
var
117117
weatherStation: PWeatherStation;
118118
Index: Integer;
@@ -146,7 +146,7 @@ procedure TBaseline.BuildHashList;
146146
strLine: String;
147147
strStation: String;
148148
strTemp: String;
149-
temparature: Single;
149+
temparature: Int64;
150150
begin
151151
if FileExists(FInputFile) then
152152
begin
@@ -162,6 +162,7 @@ procedure TBaseline.BuildHashList;
162162
begin
163163
strStation := Copy(strLine, 1, position - 1);
164164
strTemp := Copy(strLine, position + 1, Length(strLine));
165+
strTemp := StringReplace(strTemp, '.', '', [rfReplaceAll]);
165166
Val(strTemp, temparature, Code);
166167
if Code <> 0 then
167168
Continue;
@@ -185,7 +186,9 @@ procedure TBaseline.Generate;
185186
var
186187
index: Integer;
187188
strTemp: String;
188-
mean: Single;
189+
min: Double;
190+
max: Double;
191+
mean: Double;
189192
weatherStation: PWeatherStation;
190193
begin
191194

@@ -196,9 +199,10 @@ procedure TBaseline.Generate;
196199
for index := 0 to FHashStationList.Count - 1 do
197200
begin
198201
weatherStation := FHashStationList.Items[index];
199-
weatherStation^.FTot := Round(weatherStation^.FTot*10)/10;
200-
mean := weatherStation^.FTot/weatherStation^.FCnt;
201-
strTemp := weatherStation^.FStation + '=' + FormatFloat('0.0', weatherStation^.FMin) + '/' + FormatFloat('0.0', mean) + '/' + FormatFloat('0.0', weatherStation^.FMax) + ',';
202+
Min := weatherStation^.FMin/10;
203+
Max := weatherStation^.FMax/10;
204+
Mean := weatherStation^.FTot/weatherStation^.FCnt/10;
205+
strTemp := weatherStation^.FStation + '=' + FormatFloat('0.0', Min) + '/' + FormatFloat('0.0', Mean) + '/' + FormatFloat('0.0', Max) + ',';
202206
FStationNames.Add(strTemp);
203207
end;
204208
FStationNames.EndUpdate;

0 commit comments

Comments
 (0)