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