Package: metar
Version: 20050706.1-1
Severity: wishlist
Tags: patch

I can convert wind direction from a compass heading to compass points
in my head, but I shouldn't have to.  See patch.

Peter

--- metar-20050706.1.orig/src/main.c
+++ metar-20050706.1/src/main.c
@@ -106,7 +106,12 @@
        if (metar.winddir == -1) {
                printf("Wind direction: Variable\n");
        } else {
-               printf("Wind direction: %i\n", metar.winddir);
+               static const char *winddirs[] = {
+                       "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
+                       "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N"
+               };
+               int i = (metar.winddir * 4 + 45) / 90;
+               printf("Wind direction: %i (%s)\n", metar.winddir, winddirs[i]);
        }
        printf("Wind speed    : %i %s\n", metar.windstr, metar.windunit);
        printf("Wind gust     : %i %s\n", metar.windgust, metar.windunit);

Attachment: signature.asc
Description: Digital signature

Reply via email to