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
21
my $wind = $self->{wind};
22
my $dir_deg = substr($wind,0,3);
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";
33
- if ($dir_deg < 15) {
34
+ if ($wind_speed == 0 and $dir_deg == 0) {
35
+ # Calm wind (00000KT in METAR)
37
+ print "wind is calm\n" if $self->{debug};
38
+ } elsif ($dir_deg < 15) {
41
} elsif ($dir_deg < 30) {
42
@@ -1167,38 +1177,45 @@ sub _process
43
} elsif ($dir_deg < 345) {
44
$dir_eng = "North/Northwest";
47
+ } elsif ($dir_deg < 360) {
51
+ # Shouldn't happen, but if for some reason the METAR
52
+ # information doesn't contain a reasonable direction...
53
+ $dir_eng = "undeterminable";
57
my $kts_speed = undef;
58
my $mph_speed = undef;
59
+ my $mps_speed = undef;
67
if ($self->{windtype} == $wt_knots){
68
$wind =~ /...(\d\d\d?)/o;
70
- $mph_speed = $kts_speed * 1.1508;
72
+ $mph_speed = $kts_speed * 1.15077945;
73
+ $mps_speed = $kts_speed * 0.514444444;
75
if ($wind =~ /.{5,6}G(\d\d\d?)/o) {
77
- $mph_gust = $kts_gust * 1.1508;
78
+ $mph_gust = $kts_gust * 1.15077945;
79
+ $mps_gust = $kts_gust * 0.514444444;
81
# else: parse meters/second
82
} elsif ($self->{windtype} == $wt_mps){
83
$wind=~ /...(\d\d\d?)/o;
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) {
91
$kts_gust = $mps_gust * 1.9438445;
92
$mph_gust = $mps_gust * 2.2369363;
94
@@ -1208,9 +1225,11 @@ sub _process
96
$self->{WIND_KTS} = $kts_speed;
97
$self->{WIND_MPH} = $mph_speed;
98
+ $self->{WIND_MS} = $mps_speed;
100
$self->{WIND_GUST_KTS} = $kts_gust;
101
$self->{WIND_GUST_MPH} = $mph_gust;
102
+ $self->{WIND_GUST_MS} = $mps_gust;
104
$self->{WIND_DIR_DEG} = $dir_deg;
105
$self->{WIND_DIR_ENG} = $dir_eng;
106
@@ -1226,8 +1245,39 @@ sub _process
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;
116
+ 30 => "North/Northeast",
118
+ 75 => "East/Northeast",
120
+ 120 => "East/Southeast",
121
+ 150 => "Southeast",
122
+ 165 => "South/Southeast",
124
+ 210 => "South/Southwest",
125
+ 240 => "Southwest",
126
+ 265 => "West/Southwest",
128
+ 300 => "West/Northwest",
129
+ 330 => "Northwest",
130
+ 345 => "North/Northwest",
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];
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];
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.
160
-The current wind direction in english (Southwest, East, North, etc.)
161
+The current wind direction in English (Southwest, East, North, etc.)
165
-The current wind direction in abbreviated english (S, E, N, etc.)
166
+The current wind direction in abbreviated English (S, E, N, etc.)
170
@@ -1521,6 +1572,10 @@ The current wind speed in Knots.
172
The current wind speed in Miles Per Hour.
176
+The current wind speed in Metres Per Second.
180
The current wind gusting speed in Knots.
181
@@ -1529,6 +1584,10 @@ The current wind gusting speed in Knots.
183
The current wind gusting speed in Miles Per Hour.
187
+The current wind gusting speed in Metres Per Second.
191
The wind variation in English
192
@@ -1537,10 +1596,18 @@ The wind variation in English
194
The first wind variation direction
196
+=item WIND_VAR_ENG_1
198
+The first wind variation direction in English
202
The second wind variation direction
204
+=item WIND_VAR_ENG_2
206
+The second wind variation direction in English
210
Visibility information.