Argh.

Line 57 of the patch should of course be:

+           } elsif ($dir_deg <= 360) {

Revised patch attached.
diff -urN libgeo-metar-perl-1.14.old/METAR.pm libgeo-metar-perl-1.14/METAR.pm
--- libgeo-metar-perl-1.14.old/METAR.pm 2005-04-16 22:30:36.507324481 +0300
+++ libgeo-metar-perl-1.14/METAR.pm     2005-04-16 22:47:15.605605420 +0300
@@ -203,6 +203,8 @@
     $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_DEG}  = undef;             # wind variation in degrees
     $self->{WIND_VAR_ENG}  = undef;             # wind variation in english
     $self->{VISIBILITY}    = undef;             # visibility info
@@ -467,6 +469,18 @@
         }
 
                ##
+               ## is it international visibility information?
+               ##
+
+               elsif ($tok =~ /^\d\d\d\d$/) {
+                       $self->{visibility} = $tok;
+                       print "[$tok] is international visibility 
information.\n"
+                               if $self->{debug};
+                       next;
+               }
+
+
+               ##
                ## does it say CAVOK? (ceiling and visibility ok)
                ##
                
@@ -811,11 +825,18 @@
         my $dir_deg  = substr($wind,0,3);
         my $dir_eng = "";
 
+               my $metar_speed = $1 if $wind =~ /...(\d\d\d?)/o;
+
         # Check for wind direction
         if ($dir_deg =~ /VRB/i) {
-            $dir_deg = "Variable";
+            $dir_deg = "variable";
+                       $dir_eng = "variable";
         } else {
-            if      ($dir_deg < 15) {
+                       if ($metar_speed == 0 && $dir_deg eq "000") {
+                               # This in case if it's calm (00000KT in METAR)
+                                       $dir_eng = "calm";
+                               print "wind is calm\n" if $self->{debug};
+                       } elsif ($dir_deg >= 0 && $dir_deg < 15) {
                 $dir_eng = "North";
             } elsif ($dir_deg < 30) {
                 $dir_eng = "North/Northeast";
@@ -847,27 +868,40 @@
                 $dir_eng = "Northwest";
             } elsif ($dir_deg < 345) {
                 $dir_eng = "North/Northwest";
+                       } elsif ($dir_deg <= 360) {
+                               $dir_eng = "North";
             } else {
-                $dir_eng = "North";
+                               # Shouldn't happen, but if for some reason the 
METAR
+                               # information doesn't contain a reasonable 
direction...
+                               $dir_eng = "undeterminable";
             }
         }
 
-        $wind =~ /...(\d\d\d?)/o;
-        my $kts_speed = $1;
+               my $kts_speed = $metar_speed;
         my $mph_speed = $kts_speed * 1.1508;
+               my $ms_speed = $kts_speed * 0.5144;
         my $kts_gust = "";
         my $mph_gust = "";
+               my $ms_gust = "";
+
+               $mph_speed = sprintf("%.1f", $mph_speed);
+               $ms_speed = sprintf("%.1f", $ms_speed);
 
         if ($wind =~ /.{5,6}G(\d\d\d?)/o) {
             $kts_gust = $1;
             $mph_gust = $kts_gust * 1.1508;
+                       $mph_gust = sprintf("%.1f", $mph_gust);
+                       $ms_gust = $kts_gust * 0.5144;
+                       $ms_gust = sprintf("%.1f", $ms_gust);
         }
 
         $self->{WIND_KTS} = $kts_speed;
         $self->{WIND_MPH} = $mph_speed;
+               $self->{WIND_MS} = $ms_speed;
 
         $self->{WIND_GUST_KTS} = $kts_gust;
         $self->{WIND_GUST_MPH} = $mph_gust;
+               $self->{WIND_GUST_MS} = $ms_gust;
 
         $self->{WIND_DIR_DEG} = $dir_deg;
         $self->{WIND_DIR_ENG} = $dir_eng;
@@ -940,10 +974,17 @@
                   if ($vis =~ /^CAVOK$/i) {
                       $self->{VISIBILITY} = "Ceiling and visibility OK";
                   }
+                  elsif ($vis =~ /^(\d\d\d\d)$/) {
+                               # Convert meters to kilometers
+                               my $ivis = $1;
+                               $ivis = $ivis / 1000;
+                               $ivis = sprintf("%.1f", $ivis);
+                               $self->{VISIBILITY} = "$ivis kilometers";
+                  }
            elsif ($vis =~ /M(\d\/\d)/o) {
                $self->{VISIBILITY} = "Less than $1 statute miles";
            } else {
-               $self->{VISIBILITY} = $vis . " Statute Miles";
+               $self->{VISIBILITY} = $vis . " statute miles";
            } # end if
                }
     }
@@ -1231,6 +1272,10 @@
 
 The current wind speed in Miles Per Hour.
 
+=item WIND_MS
+
+The current wind speed in meters per second.
+
 =item WIND_GUST_KTS
 
 The current wind gusting speed in Knots.
@@ -1239,6 +1284,10 @@
 
 The current wind gusting speed in Miles Per Hour.
 
+=item WIND_GUST_MS
+
+The current wind gusting speed in meters per second.
+
 =item VISIBILITY
 
 Visibility information.
diff -urN libgeo-metar-perl-1.14.old/TODO libgeo-metar-perl-1.14/TODO
--- libgeo-metar-perl-1.14.old/TODO     2005-04-16 22:30:36.509323980 +0300
+++ libgeo-metar-perl-1.14/TODO 2005-04-16 22:52:35.035481138 +0300
@@ -51,3 +51,18 @@
 
 [EMAIL PROTECTED]
 
+---
+
+A couple of bugs that need fixing:
+
+- Unknown METAR group: RESHRA
+- Unknown METAR group: R06/P1500UU
+- Unknown METAR group: VV002
+- Unknown METAR group: 6000NE
+- Unknown METAR group: 24CLRD//
+- Unknown METAR group: 2419//95
+- Interprets R24/0650V1400N R06/0800V1200D as temperature 24, dew point 6
+- Convert numerals to numeric (04 -> 4)
+
[EMAIL PROTECTED]
+

Reply via email to