Skip to content

Commit

Permalink
fix: ForecastNextHour()
Browse files Browse the repository at this point in the history
Update ForecastNextHour.mjs
  • Loading branch information
VirgilClyne committed Oct 4, 2024
1 parent a1e7261 commit 994673f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/class/ForecastNextHour.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { log } from "../utils/utils.mjs";
export default class ForecastNextHour {
Name = "ForecastNextHour";
Version = "v1.3.1";
Version = "v1.3.2";
Author = "iRingo";

static #Configs = {
Expand Down Expand Up @@ -104,8 +104,8 @@ export default class ForecastNextHour {
//log(`☑️ ConditionType, precipitationIntensity: ${precipitationIntensity}, precipitationChance: ${precipitationChance}, precipitationType: ${precipitationType}`, "");
const Range = this.#Configs.Precipitation.Range[units];
let condition = "CLEAR";
if (precipitationIntensity >= Range.NO[0] && precipitationIntensity <= 0.001) condition = "CLEAR"
else if (precipitationIntensity > 0.001 && precipitationIntensity <= Range.NO[1]) {
if (precipitationIntensity = 0) condition = "CLEAR"
else if (precipitationIntensity > Range.NO[0] && precipitationIntensity <= Range.NO[1]) {
switch (precipitationType) {
case "RAIN":
condition = "POSSIBLE_DRIZZLE";
Expand Down Expand Up @@ -428,12 +428,12 @@ export default class ForecastNextHour {
switch (condition) {
case "CLEAR":
level = 0;
range = [Range.NO[0], 0.001];
range = Range.NO;
break;
case "POSSIBLE_DRIZZLE":
case "POSSIBLE_FLURRIES":
level = 0;
range = [0.001, Range.NO[1]];
range = Range.LIGHT;
break;
case "DRIZZLE":
case "FLURRIES":
Expand All @@ -452,6 +452,7 @@ export default class ForecastNextHour {
break;
};
perceivedPrecipitationIntensity = level + (precipitationIntensity - range[0]) / (range[1] - range[0]);
perceivedPrecipitationIntensity = Math.round(perceivedPrecipitationIntensity * 1000) / 1000;
perceivedPrecipitationIntensity = Math.min(3, perceivedPrecipitationIntensity);
//log(`✅ ConvertPrecipitationIntensity: ${perceivedPrecipitationIntensity}`, "");
return perceivedPrecipitationIntensity;
Expand Down

0 comments on commit 994673f

Please sign in to comment.