Index: ChangeLog
===================================================================
--- ChangeLog	(révision 164)
+++ ChangeLog	(copie de travail)
@@ -1,3 +1,11 @@
+2008-04-11  Samuel Buffet  <evebuffet@yahoo.fr>
+
+	New prototypes and implementations of functions giving access to
+	numerical values of *WeatherInfo* members.
+	* libgweather/weather.h: add new prototypes
+	* libgweather/weather.c: add new implementations
+	INT_MAX or DBL_MAX is an invalid or unknown result
+
 2008-04-11  Vincent Untz  <vuntz@gnome.org>
 
 	* data/Locations.xml.in: add some FIXME for later, when we can break
Index: libgweather/weather.c
===================================================================
--- libgweather/weather.c	(révision 164)
+++ libgweather/weather.c	(copie de travail)
@@ -1097,3 +1097,256 @@
 
     return NULL;
 }
+
+time_t weather_info_get_update_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, INT_MAX);
+    if (!info->valid)
+        return INT_MAX;
+
+    return info->update;
+}
+
+gint weather_info_get_sky_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, INT_MAX);
+    if (!info->valid)
+        return INT_MAX;
+    if (info->sky < 0)
+	    return INT_MAX;
+	
+    return info->sky;
+}
+
+gboolean weather_info_get_conditions_significant_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, FALSE);
+    if (!info->valid)
+        return FALSE;
+    return info->cond.significant;
+}
+
+gint weather_info_get_conditions_phenomenon_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, INT_MAX);
+    if (!info->valid)
+        return INT_MAX;
+    return info->cond.phenomenon;
+}
+
+gint weather_info_get_conditions_qualifier_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, INT_MAX);
+    if (!info->valid)
+        return INT_MAX;
+    return info->cond.qualifier;
+}
+
+static gdouble temperature_value (gfloat far, TempUnit to_unit)
+{
+    gdouble tmp;
+
+    switch (to_unit) {
+        case TEMP_UNIT_FAHRENHEIT:
+			tmp = far;
+            break;
+        case TEMP_UNIT_CENTIGRADE:
+            tmp = TEMP_F_TO_C(far);
+            break;
+        case TEMP_UNIT_KELVIN:
+            tmp = TEMP_F_TO_K(far);
+            break;
+
+        case TEMP_UNIT_INVALID:
+        case TEMP_UNIT_DEFAULT:
+        default:
+            return DBL_MAX;
+    }
+
+    return tmp;
+}
+
+gdouble weather_info_get_temp_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+
+    if (!info->valid)
+        return DBL_MAX;
+    if (info->temp < -500.0)
+        return DBL_MAX;
+
+    return temperature_value (info->temp, info->temperature_unit);
+}
+
+gdouble weather_info_get_dew_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+
+    if (!info->valid)
+        return DBL_MAX;
+    if (info->dew < -500.0)
+        return DBL_MAX;
+    
+    return temperature_value (info->dew, info->temperature_unit);
+}
+
+gdouble weather_info_get_humidity_value (WeatherInfo *info)
+{
+    gdouble humidity;
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+    if (!info->valid)
+        return DBL_MAX;
+
+    humidity = calc_humidity(info->temp, info->dew);
+    if (humidity < 0.0)
+        return DBL_MAX;
+
+    return humidity;
+}
+
+gint weather_info_get_wind_direction_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, INT_MAX);
+    if (!info->valid)
+        return INT_MAX;
+    if (info->windspeed < 0.0 || info->wind < 0)
+        return INT_MAX;
+    if (info->windspeed == 0.00) 
+	    return INT_MAX;
+	
+    return info->wind;
+}
+
+static gdouble windspeed_value (gfloat knots, SpeedUnit to_unit)
+{
+    gdouble tmp;
+
+    switch (to_unit) {
+        case SPEED_UNIT_KNOTS:
+            tmp = knots;
+            break;
+        case SPEED_UNIT_MPH:
+            tmp = WINDSPEED_KNOTS_TO_MPH(knots);
+            break;
+        case SPEED_UNIT_KPH:
+            tmp = WINDSPEED_KNOTS_TO_KPH(knots);
+            break;
+        case SPEED_UNIT_MS:
+            tmp = WINDSPEED_KNOTS_TO_MS(knots);
+            break;
+	 case SPEED_UNIT_BFT:
+            tmp = WINDSPEED_KNOTS_TO_BFT (knots);
+	     break;
+        case SPEED_UNIT_INVALID:
+        case SPEED_UNIT_DEFAULT:
+        default:
+            return DBL_MAX;
+    }
+
+    return tmp;
+}
+
+gdouble weather_info_get_wind_speed_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+    if (!info->valid)
+        return DBL_MAX;
+    if (info->windspeed < 0.0 || info->wind < 0)
+        return DBL_MAX;
+	
+    return windspeed_value(info->windspeed, info->speed_unit);
+}
+
+gdouble weather_info_get_pressure_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+    if (!info->valid)
+        return DBL_MAX;
+    if (info->pressure < 0.0)
+        return DBL_MAX;
+
+    switch (info->pressure_unit) {
+        case PRESSURE_UNIT_INCH_HG:
+	     return info->pressure;
+        case PRESSURE_UNIT_MM_HG:
+            return PRESSURE_INCH_TO_MM(info->pressure);
+        case PRESSURE_UNIT_KPA:
+            return PRESSURE_INCH_TO_KPA(info->pressure);
+        case PRESSURE_UNIT_HPA:
+            return PRESSURE_INCH_TO_HPA(info->pressure);
+        case PRESSURE_UNIT_MB:
+            return PRESSURE_INCH_TO_MB(info->pressure);
+        case PRESSURE_UNIT_ATM:
+            return PRESSURE_INCH_TO_ATM(info->pressure);
+	 case PRESSURE_UNIT_INVALID:
+	 case PRESSURE_UNIT_DEFAULT:
+	     return DBL_MAX;
+    }
+
+    return DBL_MAX;
+}
+
+gdouble weather_info_get_visibility_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+    if (!info->valid)
+        return DBL_MAX;
+    if (info->visibility < 0.0)
+        return DBL_MAX;
+
+    switch (info->distance_unit) {
+        case DISTANCE_UNIT_MILES:
+            return info->visibility;
+        case DISTANCE_UNIT_KM:
+            return VISIBILITY_SM_TO_KM(info->visibility);
+        case DISTANCE_UNIT_METERS:
+            return VISIBILITY_SM_TO_M(info->visibility);
+	 case DISTANCE_UNIT_INVALID:
+	 case DISTANCE_UNIT_DEFAULT:
+	     return DBL_MAX;
+    }
+
+    return DBL_MAX;
+}
+
+gdouble weather_info_get_apparent_value (WeatherInfo *info)
+{
+    gdouble apparent;
+    g_return_val_if_fail(info != NULL, DBL_MAX);
+    if (!info->valid)
+        return DBL_MAX;
+
+    apparent = calc_apparent(info);
+    if (apparent < -500.0)
+        return DBL_MAX;
+    
+    return temperature_value (apparent, info->temperature_unit);
+}
+
+time_t weather_info_get_sunrise_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info && info->location, INT_MAX);
+    
+    if (!info->location->latlon_valid)
+        return INT_MAX;
+    if (!info->valid)
+        return INT_MAX;
+    if (!calc_sun (info))
+        return INT_MAX;
+
+    return info->sunrise;
+}
+
+time_t weather_info_get_sunset_value (WeatherInfo *info)
+{
+    g_return_val_if_fail(info && info->location, INT_MAX);
+    
+    if (!info->location->latlon_valid)
+        return INT_MAX;
+    if (!info->valid)
+        return INT_MAX;
+    if (!calc_sun (info))
+        return INT_MAX;
+
+    return info->sunset;
+}
Index: libgweather/weather.h
===================================================================
--- libgweather/weather.h	(révision 164)
+++ libgweather/weather.h	(copie de travail)
@@ -164,6 +164,22 @@
 
 const gchar *		weather_info_get_icon_name	(WeatherInfo *info);
 gint			weather_info_next_sun_event	(WeatherInfo *info);
+
+time_t 	weather_info_get_update_value			(WeatherInfo *info);
+gint		weather_info_get_sky_value			(WeatherInfo *info);
+gboolean	weather_info_get_conditions_significant_value	(WeatherInfo *info);
+gint		weather_info_get_conditions_phenomenon_value	(WeatherInfo *info);
+gint		weather_info_get_conditions_qualifier_value	(WeatherInfo *info);
+gdouble 	weather_info_get_temp_value			(WeatherInfo *info);
+gdouble 	weather_info_get_dew_value			(WeatherInfo *info);
+gdouble 	weather_info_get_humidity_value			(WeatherInfo *info);
+gint 		weather_info_get_wind_direction_value   	(WeatherInfo *info);
+gdouble 	weather_info_get_wind_speed_value		(WeatherInfo *info);
+gdouble 	weather_info_get_pressure_value			(WeatherInfo *info);
+gdouble 	weather_info_get_visibility_value		(WeatherInfo *info);
+gdouble 	weather_info_get_apparent_value			(WeatherInfo *info);
+time_t 	weather_info_get_sunrise_value			(WeatherInfo *info);
+time_t 	weather_info_get_sunset_value			(WeatherInfo *info);
 G_END_DECLS
 
 #endif /* __WEATHER_H_ */
