Commit 683de85d authored by Harald Judt's avatar Harald Judt

New value: Dew point.

The user can now add the dew point value to the scrollbox via the
configuration dialog.
parent 370991e9
......@@ -32,7 +32,7 @@
#include "weather-scrollbox.h"
#define UPDATE_TIMER_DELAY 7
#define OPTIONS_N 13
#define OPTIONS_N 14
#define BORDER 4
#define LOC_NAME_MAX_LEN 50
......@@ -99,6 +99,7 @@ static const labeloption labeloptions[OPTIONS_N] = {
{N_("Wind direction (WD)"), WIND_DIRECTION},
{N_("Wind direction in degrees (WD)"), WIND_DIRECTION_DEG},
{N_("Humidity (H)"), HUMIDITY},
{N_("Dew point (D)"), DEWPOINT},
{N_("Low clouds (CL)"), CLOUDS_LOW},
{N_("Medium clouds (CM)"), CLOUDS_MED},
{N_("High clouds (CH)"), CLOUDS_HIGH},
......
......@@ -21,6 +21,7 @@
#endif
#include <libxfce4util/libxfce4util.h>
#include <math.h>
#include "weather-parsers.h"
#include "weather-data.h"
......@@ -148,6 +149,22 @@ timeslice_is_interval(xml_time *timeslice)
}
/*
* Calculate dew point in Celsius, taking the Magnus formulae as a
* basis. Source: http://de.wikipedia.org/wiki/Taupunkt
*/
static gdouble
calc_dewpoint(const xml_location *loc)
{
gdouble temp = string_to_double(loc->temperature_value, 0);
gdouble humidity = string_to_double(loc->humidity_value, 0);
gdouble val = log(humidity / 100);
return (241.2 * val + 4222.03716 * temp / (241.2 + temp))
/ (17.5043 - val - 17.5043 * temp / (241.2 + temp));
}
gchar *
get_data(const xml_time *timeslice,
const units_config *units,
......@@ -232,6 +249,12 @@ get_data(const xml_time *timeslice,
case HUMIDITY:
return LOCALE_DOUBLE(loc->humidity_value, ROUND_TO_INT("%.1f"));
case DEWPOINT:
val = calc_dewpoint(loc);
if (units->temperature == FAHRENHEIT)
val = val * 9.0 / 5.0 + 32.0;
return g_strdup_printf(ROUND_TO_INT("%.1f"), val);
case CLOUDS_LOW:
return LOCALE_DOUBLE(loc->clouds_percent[CLOUDS_PERC_LOW],
ROUND_TO_INT("%.1f"));
......@@ -276,6 +299,7 @@ get_unit(const units_config *units,
case ALTITUDE:
return (units->altitude == FEET) ? _("ft") : _("m");
case TEMPERATURE:
case DEWPOINT:
return (units->temperature == FAHRENHEIT) ? _("°F") : _("°C");
case PRESSURE:
switch (units->pressure) {
......
......@@ -32,6 +32,7 @@ typedef enum {
WIND_DIRECTION,
WIND_DIRECTION_DEG,
HUMIDITY,
DEWPOINT,
CLOUDS_LOW,
CLOUDS_MED,
CLOUDS_HIGH,
......
......@@ -342,7 +342,7 @@ create_summary_tab(plugin_data *data)
point = format_date(conditions->point, NULL, TRUE);
value = g_strdup_printf
(_("\tTemperature, wind, atmosphere and cloud data calculated\n"
(_("\tTemperatures, wind, atmosphere and cloud data calculated\n"
"\tfor:\t\t\t%s\n"),
point);
g_free(point);
......@@ -415,9 +415,10 @@ create_summary_tab(plugin_data *data)
APPEND_TEXT_ITEM_REAL(value);
}
/* temperature */
APPEND_BTEXT(_("\nTemperature\n"));
/* temperatures */
APPEND_BTEXT(_("\nTemperatures\n"));
APPEND_TEXT_ITEM(_("Temperature"), TEMPERATURE);
APPEND_TEXT_ITEM(_("Dew point"), DEWPOINT);
/* wind */
APPEND_BTEXT(_("\nWind\n"));
......@@ -540,6 +541,9 @@ forecast_cell_get_tooltip_text(plugin_data *data,
g_string_append_printf(text, _("Data calculated for:\t%s\n\n"), value);
g_free(value);
g_string_append(text, _("<b>Temperatures</b>\n"));
APPEND_TOOLTIP_ITEM(_("Dew point:\t\t\t%s%s%s\n\n"), DEWPOINT);
g_string_append(text, _("<b>Atmosphere</b>\n"));
APPEND_TOOLTIP_ITEM(_("Pressure:\t%s%s%s\n"), PRESSURE);
APPEND_TOOLTIP_ITEM(_("Humidity:\t%s%s%s\n\n"), HUMIDITY);
......
......@@ -133,6 +133,9 @@ make_label(const plugin_data *data,
case HUMIDITY:
lbl = _("H");
break;
case DEWPOINT:
lbl = _("D");
break;
case CLOUDS_LOW:
lbl = _("CL");
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment