summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2021-05-11 18:29:27 +0100
committerAlastair Poole <netstar@gmail.com>2021-05-11 18:29:27 +0100
commit75fe933d4d9a156ed61248b834c4cc1f5b2e03f7 (patch)
treec9c01a81ed5ff1f3f41123df83be4f52fa9de6b0
parent343b2a38660845c6cc12a7ae1736bde700c463d2 (diff)
chill: calculation is invalid above 10C.HEADmaster
-rw-r--r--src/e_mod_main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index cf8a670..fc34062 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -64,6 +64,7 @@ struct _Instance
64 struct 64 struct
65 { 65 {
66 int chill, direction, speed; 66 int chill, direction, speed;
67 Eina_Bool can_chill;
67 } wind; 68 } wind;
68 69
69 struct 70 struct
@@ -708,10 +709,14 @@ _forecasts_parse(void *data)
708 v *= 3.6; 709 v *= 3.6;
709 inst->details.wind.speed = v; 710 inst->details.wind.speed = v;
710 711
711 double t, vpow; 712 if (inst->condition.temp <= 10.0)
712 t = inst->condition.temp; 713 {
713 vpow = pow(inst->details.wind.speed, 0.16); 714 double t, vpow;
714 inst->details.wind.chill = (13.12 + (0.6215 * t)) - (11.37 * (vpow)) + ((0.3965 * t) * (vpow)); 715 t = inst->condition.temp;
716 vpow = pow(inst->details.wind.speed, 0.16);
717 inst->details.wind.chill = (13.12 + (0.6215 * t)) - (11.37 * (vpow)) + ((0.3965 * t) * (vpow));
718 inst->details.wind.can_chill = 1;
719 }
715 720
716 json_object *o_next = json_object_object_get(o_data, "next_1_hours"); 721 json_object *o_next = json_object_object_get(o_data, "next_1_hours");
717 json_object *o_summary = json_object_object_get(o_next, "summary"); 722 json_object *o_summary = json_object_object_get(o_next, "summary");
@@ -987,7 +992,10 @@ _forecasts_popup_content_create(Instance *inst)
987 992
988 lb = _lb_add(base, D_("Wind Chill")); 993 lb = _lb_add(base, D_("Wind Chill"));
989 elm_table_pack(tb, lb, 0, row, 1, 1); 994 elm_table_pack(tb, lb, 0, row, 1, 1);
990 snprintf(buf, sizeof(buf), "%d°%c", inst->details.wind.chill, inst->units.temp); 995 if (inst->details.wind.can_chill)
996 snprintf(buf, sizeof(buf), "%d°%c", inst->details.wind.chill, inst->units.temp);
997 else
998 snprintf(buf, sizeof(buf), "N/A");
991 lb = _lb_add(base, buf); 999 lb = _lb_add(base, buf);
992 elm_table_pack(tb, lb, 1, row++, 1, 1); 1000 elm_table_pack(tb, lb, 1, row++, 1, 1);
993 1001