Package: metar Version: 20050807.1-1 Tags: patch metar has this idea that my city has atmospheric pressure of 3007 inches of mercury. Since I haven't suffocated yet, this seems unlikely. In reality, of course, it is 30.07 inches.
I don't know if it gets the other units right - if not, it's trivial to add fixed-point conversions to those too. Peter
diff -urN src/main.c src/main.c
--- src/main.c
+++ src/main.c
@@ -99,6 +99,7 @@
cloudlist_t *curcloud;
obslist_t *curobs;
int n = 0;
+ float qnh;
printf("Station : %s\n", metar.station);
printf("Day : %i\n", metar.day);
@@ -110,15 +111,20 @@
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
};
- int i = ((metar.winddir * 4 + 45) / 90) % 16;
- printf("Wind direction: %i (%s)\n", metar.winddir, winddirs[i]);
+ n = ((metar.winddir * 4 + 45) / 90) % 16;
+ printf("Wind direction: %i (%s)\n", metar.winddir, winddirs[n]);
}
printf("Wind speed : %i %s\n", metar.windstr, metar.windunit);
printf("Wind gust : %i %s\n", metar.windgust, metar.windunit);
printf("Visibility : %i %s\n", metar.vis, metar.visunit);
printf("Temperature : %i C\n", metar.temp);
printf("Dewpoint : %i C\n", metar.dewp);
- printf("Pressure : %i %s\n", metar.qnh, metar.qnhunit);
+
+ qnh = metar.qnh;
+ for (n = 0; n < metar.qnhfp; n++)
+ qnh /= 10.0;
+ printf("Pressure : %.*f %s\n", metar.qnhfp, qnh, metar.qnhunit);
+
printf("Clouds : ");
n = 0;
for (curcloud = metar.clouds; curcloud != NULL;
curcloud=curcloud->next) {
diff -urN src/metar.c src/metar.c
--- src/metar.c
+++ src/metar.c
@@ -318,8 +318,10 @@
memcpy(tmp, token+pmatch[1].rm_so, (size < 5 ? size :
5));
if (strncmp(tmp, "Q", 1) == 0)
strncpy(metar->qnhunit, "hPa", 3);
- else if (strncmp(tmp, "A", 1) == 0)
+ else if (strncmp(tmp, "A", 1) == 0) {
strncpy(metar->qnhunit, "\"Hg", 3);
+ metar->qnhfp = 2;
+ }
else
strncpy(metar->qnhunit, "Unkn", 4);
diff -urN src/metar.h src/metar.h
--- src/metar.h
+++ src/metar.h
@@ -57,6 +57,7 @@
char visunit[5];
int qnh;
char qnhunit[5];
+ int qnhfp; // fixed-point decimal places
int temp;
int dewp;
cloudlist_t *clouds;
signature.asc
Description: Digital signature

