libgweather r509 - in trunk: . libgweather
- From: danw svn gnome org
- To: svn-commits-list gnome org
- Subject: libgweather r509 - in trunk: . libgweather
- Date: Tue, 25 Nov 2008 16:08:45 +0000 (UTC)
Author: danw
Date: Tue Nov 25 16:08:45 2008
New Revision: 509
URL: http://svn.gnome.org/viewvc/libgweather?rev=509&view=rev
Log:
* libgweather/weather-metar.c (WIND_RE_STR, metar_tok_wind):
Handle wind reports in m/s. #541721
Modified:
trunk/ChangeLog
trunk/libgweather/weather-metar.c
trunk/libgweather/weather-priv.h
Modified: trunk/libgweather/weather-metar.c
==============================================================================
--- trunk/libgweather/weather-metar.c (original)
+++ trunk/libgweather/weather-metar.c Tue Nov 25 16:08:45 2008
@@ -105,8 +105,14 @@
memset (sgust, 0, sizeof (sgust));
glen = strspn (gustp + 1, CONST_DIGITS);
strncpy (sgust, gustp + 1, glen);
+ tokp = gustp + 1 + glen;
}
+ if (!strcmp (tokp, "MPS"))
+ info->windspeed = WINDSPEED_MS_TO_KNOTS ((WeatherWindSpeed)spd);
+ else
+ info->windspeed = (WeatherWindSpeed)spd;
+
if ((349 <= dir) || (dir <= 11))
info->wind = WIND_N;
else if ((12 <= dir) && (dir <= 33))
@@ -139,8 +145,6 @@
info->wind = WIND_NW;
else if ((327 <= dir) && (dir <= 348))
info->wind = WIND_NNW;
-
- info->windspeed = (WeatherWindSpeed)spd;
}
static void
@@ -379,7 +383,7 @@
}
#define TIME_RE_STR "([0-9]{6})Z"
-#define WIND_RE_STR "(([0-9]{3})|VRB)([0-9]?[0-9]{2})(G[0-9]?[0-9]{2})?KT"
+#define WIND_RE_STR "(([0-9]{3})|VRB)([0-9]?[0-9]{2})(G[0-9]?[0-9]{2})?(KT|MPS)"
#define VIS_RE_STR "((([0-9]?[0-9])|(M?([12] )?([1357]/1?[0-9])))SM)|" \
"([0-9]{4}(N|NE|E|SE|S|SW|W|NW( [0-9]{4}(N|NE|E|SE|S|SW|W|NW))?)?)|" \
"CAVOK"
Modified: trunk/libgweather/weather-priv.h
==============================================================================
--- trunk/libgweather/weather-priv.h (original)
+++ trunk/libgweather/weather-priv.h Tue Nov 25 16:08:45 2008
@@ -51,7 +51,7 @@
typedef gdouble WeatherTemperature;
typedef gdouble WeatherHumidity;
-typedef gint WeatherWindSpeed;
+typedef gdouble WeatherWindSpeed;
typedef gdouble WeatherPressure;
typedef gdouble WeatherVisibility;
typedef time_t WeatherUpdate;
@@ -119,6 +119,7 @@
#define WINDSPEED_KNOTS_TO_KPH(knots) ((knots) * 1.851965)
#define WINDSPEED_KNOTS_TO_MPH(knots) ((knots) * 1.150779)
#define WINDSPEED_KNOTS_TO_MS(knots) ((knots) * 0.514444)
+#define WINDSPEED_MS_TO_KNOTS(ms) ((ms) / 0.514444)
/* 1 bft ~= (1 m/s / 0.836) ^ (2/3) */
#define WINDSPEED_KNOTS_TO_BFT(knots) (pow ((knots) * 0.615363, 0.666666))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]