~ubuntu-branches/ubuntu/natty/libgeo-metar-perl/natty

« back to all changes in this revision

Viewing changes to debian/patches/wind.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martín Ferrari
  • Date: 2008-06-13 02:42:42 UTC
  • mfrom: (0.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080613024242-2be2lbxarhx8sglx
Tags: 1.15-1
* New upstream release, new upstream maintainer.
* debian/docs: removed HACKING.
* debian/copyright: updated CP info, plus new format.
* debian/control: added myself to Uploaders, fixed case in short desc. Fix
  incorrect Build-Depends{,-Indep} distribution.
* debian/patches: finally merged all the patches from #304962 and #262397
  with the new upstream release! Also, sent the patches upstream as
  CPAN#36708. (Closes: #304962).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: libgeo-metar-perl/METAR.pm
 
2
===================================================================
 
3
--- libgeo-metar-perl.orig/METAR.pm
 
4
+++ libgeo-metar-perl/METAR.pm
 
5
@@ -333,9 +333,13 @@ sub new
 
6
     $self->{WIND_GUST_KTS} = undef;             # wind gusts (knots)
 
7
     $self->{WIND_MPH}      = undef;             # wind speed (MPH)
 
8
     $self->{WIND_GUST_MPH} = undef;             # wind gusts (MPH)
 
9
+    $self->{WIND_MS}       = undef;             # wind speed (m/s)
 
10
+    $self->{WIND_GUST_MS}  = undef;             # wind gusts (m/s)
 
11
     $self->{WIND_VAR}      = undef;             # wind variation (text)
 
12
     $self->{WIND_VAR_1}    = undef;             # wind variation (direction 1)
 
13
     $self->{WIND_VAR_2}    = undef;             # wind variation (direction 2)
 
14
+    $self->{WIND_VAR_ENG_1}= undef;         # wind variation (text, direction 1)
 
15
+    $self->{WIND_VAR_ENG_2}= undef;         # wind variation (text, direction 2)
 
16
     $self->{VISIBILITY}    = undef;             # visibility info
 
17
     $self->{RUNWAY}        = [ ];               # runway vis.
 
18
     $self->{WEATHER}       = [ ];               # current weather
 
19
@@ -1112,14 +1116,20 @@ sub _process
 
20
        {
 
21
         my $wind = $self->{wind};
 
22
         my $dir_deg  = substr($wind,0,3);
 
23
+        my $wind_speed;
 
24
         my $dir_eng = "";
 
25
                my $dir_abb = "";
 
26
 
 
27
+        $wind_speed = $1 if($wind =~ /...(\d{2,3})/o);
 
28
         # Check for wind direction
 
29
         if ($dir_deg =~ /VRB/i) {
 
30
-            $dir_deg = "Variable";
 
31
+            $dir_deg = $dir_eng = "Variable";
 
32
         } else {
 
33
-            if      ($dir_deg < 15) {
 
34
+            if ($wind_speed == 0 and $dir_deg == 0) {
 
35
+                # Calm wind (00000KT in METAR)
 
36
+                $dir_eng = "Calm";
 
37
+                print "wind is calm\n" if $self->{debug};
 
38
+            } elsif ($dir_deg < 15) {
 
39
                 $dir_eng = "North";
 
40
                                $dir_abb = "N";
 
41
             } elsif ($dir_deg < 30) {
 
42
@@ -1167,38 +1177,45 @@ sub _process
 
43
             } elsif ($dir_deg < 345) {
 
44
                 $dir_eng = "North/Northwest";
 
45
                                $dir_abb = "NNW";
 
46
-            } else {
 
47
+            } elsif ($dir_deg < 360) {
 
48
                 $dir_eng = "North";
 
49
                                $dir_abb = "N";
 
50
+            } else {
 
51
+                # Shouldn't happen, but if for some reason the METAR
 
52
+                # information doesn't contain a reasonable direction...
 
53
+                $dir_eng = "undeterminable";
 
54
             }
 
55
         }
 
56
 
 
57
                my $kts_speed = undef;
 
58
                my $mph_speed = undef;
 
59
+               my $mps_speed = undef;
 
60
 
 
61
                my $kts_gust = "";
 
62
                my $mph_gust = "";
 
63
+               my $mps_gust = "";
 
64
 
 
65
                # parse knots
 
66
 
 
67
                if ($self->{windtype} == $wt_knots){
 
68
                        $wind =~ /...(\d\d\d?)/o;
 
69
                        $kts_speed = $1;
 
70
-                       $mph_speed = $kts_speed * 1.1508;
 
71
-
 
72
+                       $mph_speed = $kts_speed * 1.15077945;
 
73
+                       $mps_speed = $kts_speed * 0.514444444;
 
74
 
 
75
                        if ($wind =~ /.{5,6}G(\d\d\d?)/o) {
 
76
                                $kts_gust = $1;
 
77
-                               $mph_gust = $kts_gust * 1.1508;
 
78
+                               $mph_gust = $kts_gust * 1.15077945;
 
79
+                               $mps_gust = $kts_gust * 0.514444444;
 
80
                        }
 
81
                # else: parse meters/second
 
82
                } elsif ($self->{windtype} == $wt_mps){
 
83
                        $wind=~ /...(\d\d\d?)/o;
 
84
-                       my $mps_speed = $1;
 
85
+                       $mps_speed = $1;
 
86
                        $kts_speed = $mps_speed * 1.9438445; # units
 
87
                        $mph_speed = $mps_speed * 2.2369363;
 
88
                        if ($wind =~ /\d{5,6}G(\d\d\d?)/o) {
 
89
-                               my $mps_gust = $1;
 
90
+                               $mps_gust = $1;
 
91
                                $kts_gust = $mps_gust * 1.9438445;
 
92
                                $mph_gust = $mps_gust * 2.2369363;
 
93
                        }
 
94
@@ -1208,9 +1225,11 @@ sub _process
 
95
 
 
96
         $self->{WIND_KTS} = $kts_speed;
 
97
         $self->{WIND_MPH} = $mph_speed;
 
98
+        $self->{WIND_MS}  = $mps_speed;
 
99
 
 
100
         $self->{WIND_GUST_KTS} = $kts_gust;
 
101
         $self->{WIND_GUST_MPH} = $mph_gust;
 
102
+        $self->{WIND_GUST_MS}  = $mps_gust;
 
103
 
 
104
         $self->{WIND_DIR_DEG} = $dir_deg;
 
105
         $self->{WIND_DIR_ENG} = $dir_eng;
 
106
@@ -1226,8 +1245,39 @@ sub _process
 
107
        {
 
108
                if ($self->{windvar} =~ /^(\d\d\d)V(\d\d\d)$/){
 
109
                        $self->{WIND_VAR} = "Varying between $1 and $2";
 
110
-                       $self->{WIND_VAR_1} = $1;
 
111
-                       $self->{WIND_VAR_2} = $2;
 
112
+            $self->{WIND_VAR_1} = $1;
 
113
+            $self->{WIND_VAR_2} = $2;
 
114
+            my @direction = (
 
115
+                15 => "North",
 
116
+                30 => "North/Northeast",
 
117
+                60 => "Northeast",
 
118
+                75 => "East/Northeast",
 
119
+                105 => "East",
 
120
+                120 => "East/Southeast",
 
121
+                150 => "Southeast",
 
122
+                165 => "South/Southeast",
 
123
+                195 => "South",
 
124
+                210 => "South/Southwest",
 
125
+                240 => "Southwest",
 
126
+                265 => "West/Southwest",
 
127
+                285 => "West",
 
128
+                300 => "West/Northwest",
 
129
+                330 => "Northwest",
 
130
+                345 => "North/Northwest",
 
131
+                360 => "North",
 
132
+                1000 => "undeterminable");
 
133
+            for(my $x = 0; $x < $#direction; $x += 2) {
 
134
+                if($self->{WIND_VAR_1} < $direction[$x]) {
 
135
+                    $self->{WIND_VAR_ENG_1} = $direction[$x+1];
 
136
+                    last;
 
137
+                }
 
138
+            }
 
139
+            for(my $x = 0; $x < $#direction; $x += 2) {
 
140
+                if($self->{WIND_VAR_2} < $direction[$x]) {
 
141
+                    $self->{WIND_VAR_ENG_2} = $direction[$x+1];
 
142
+                    last;
 
143
+                }
 
144
+            }
 
145
                }
 
146
        }
 
147
 
 
148
@@ -1322,6 +1372,7 @@ sub dump
 
149
     print "date_time: $self->{date_time}\n";
 
150
     print "modifier: $self->{modifier}\n";
 
151
     print "wind: $self->{wind}\n";
 
152
+    print "variable wind: $self->{vrbwind}\n";
 
153
     print "visibility: $self->{visibility}\n";
 
154
     print "runway: $self->{runway}\n";
 
155
     print "weather: " . join(', ', @{$self->{weather}}) . "\n";
 
156
@@ -1503,11 +1554,11 @@ Modifier (AUTO/COR) if any.
 
157
 
 
158
 =item WIND_DIR_ENG
 
159
 
 
160
-The current wind direction in english (Southwest, East, North, etc.)
 
161
+The current wind direction in English (Southwest, East, North, etc.)
 
162
 
 
163
 =item WIND_DIR_ABB
 
164
 
 
165
-The current wind direction in abbreviated english (S, E, N, etc.)
 
166
+The current wind direction in abbreviated English (S, E, N, etc.)
 
167
 
 
168
 =item WIND_DIR_DEG
 
169
 
 
170
@@ -1521,6 +1572,10 @@ The current wind speed in Knots.
 
171
 
 
172
 The current wind speed in Miles Per Hour.
 
173
 
 
174
+=item WIND_MS
 
175
+
 
176
+The current wind speed in Metres Per Second.
 
177
+
 
178
 =item WIND_GUST_KTS
 
179
 
 
180
 The current wind gusting speed in Knots.
 
181
@@ -1529,6 +1584,10 @@ The current wind gusting speed in Knots.
 
182
 
 
183
 The current wind gusting speed in Miles Per Hour.
 
184
 
 
185
+=item WIND_GUST_MS
 
186
+
 
187
+The current wind gusting speed in Metres Per Second.
 
188
+
 
189
 =item WIND_VAR
 
190
 
 
191
 The wind variation in English
 
192
@@ -1537,10 +1596,18 @@ The wind variation in English
 
193
 
 
194
 The first wind variation direction
 
195
 
 
196
+=item WIND_VAR_ENG_1
 
197
+
 
198
+The first wind variation direction in English
 
199
+
 
200
 =item WIND_VAR_2
 
201
 
 
202
 The second wind variation direction
 
203
 
 
204
+=item WIND_VAR_ENG_2
 
205
+
 
206
+The second wind variation direction in English
 
207
+
 
208
 =item VISIBILITY
 
209
 
 
210
 Visibility information.