Skip Menu |

This queue is for tickets about the Geo-METAR CPAN distribution.

Report information
The Basics
Id: 6720
Status: resolved
Priority: 0/
Queue: Geo-METAR

People
Owner: koos [...] kzdoos.xs4all.nl
Requestors: ecammit [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Module reads items in remarks section as conditions.
Use this METAR data: KBUF 221854Z 23019G23KT 8SM FEW020 SCT035TCU BKN140 BKN260 21/17 A2975 RMK AO2 PK WND 24026/1833 SLP073 TCU DSNT NW-NE T02110167 It reports the conditions as 'Dust Storm'. After further inspection, it appears that the remark for 'distant' (DSNT) is the culprit. The module reads the DS and assumes it is a condition. I am submitting a patch that will constrain each section to its location before or after the remark symbol (RMK). -Timothy M. Ace
--- METAR.pm Fri Nov 24 20:07:50 2000 +++ /Raptor/Home/tmace/Projects/Weather/Product/Geo/METAR.pm Tue Jun 22 16:54:47 2004 @@ -117,7 +117,7 @@ use vars qw($AUTOLOAD $VERSION); use Carp 'cluck'; -$VERSION = '1.14'; +$VERSION = '1.15'; ## ## Lookup tables @@ -374,7 +374,7 @@ ## is it a report type? ## - if (($tok =~ /METAR/i) or ($tok =~ /SPECI/i)) + if (!$in_remarks && (($tok =~ /METAR/i) or ($tok =~ /SPECI/i))) { $self->{type} = $tok; @@ -394,7 +394,7 @@ ## is is a site ID? ## - elsif ($tok =~ /K[A-Z]{3,3}/) + elsif (!$in_remarks && $tok =~ /K[A-Z]{3,3}/) { $self->{site} = $tok; print "[$tok] is a site ID.\n" if $self->{debug}; @@ -405,7 +405,7 @@ ## is it a date/time? ## - elsif ($tok =~ /\d{6,6}Z/i) + elsif (!$in_remarks && $tok =~ /\d{6,6}Z/i) { $self->{date_time} = $tok; print "[$tok] is a date/time.\n" if $self->{debug}; @@ -429,7 +429,7 @@ ## is it wind information? ## - elsif ($tok =~ /.*?KT$/i) + elsif (!$in_remarks && $tok =~ /.*?KT$/i) { $self->{wind} = $tok; print "[$tok] is wind information.\n" if $self->{debug}; @@ -440,7 +440,7 @@ ## is it visibility information? ## - elsif ($tok =~ /.*?SM$/i) + elsif (!$in_remarks && $tok =~ /.*?SM$/i) { $self->{visibility} = $tok; print "[$tok] is visibility information.\n" if $self->{debug}; @@ -451,7 +451,7 @@ ## is it visibility information with a leading digit? ## - elsif ($tok =~ /^\d$/) + elsif (!$in_remarks && $tok =~ /^\d$/) { $tok .= " " . shift(@toks); $self->{visibility} = $tok; @@ -463,7 +463,7 @@ ## is it runway visibility info? ## - elsif ($tok =~ /R.*?FT$/i) + elsif (!$in_remarks && $tok =~ /R.*?FT$/i) { $self->{runway} = $tok; print "[$tok] is runway visual information.\n" if $self->{debug}; @@ -474,7 +474,7 @@ ## is it current weather info? ## - elsif ($tok =~ /^(-|\+)?(VC)?($_weather_types_pat)+/i) + elsif (!$in_remarks && $tok =~ /^(-|\+)?(VC)?($_weather_types_pat)+/i) { my $engl = ""; my $qual = $1; @@ -526,7 +526,7 @@ ## is it sky conditions (clear)? ## - elsif ( $tok eq "SKC" || $tok eq "CLR" ) + elsif (!$in_remarks && ( $tok eq "SKC" || $tok eq "CLR" ) ) { push(@{$self->{sky}},$tok); push(@{$self->{SKY}}, "Sky Clear"); @@ -536,7 +536,7 @@ ## is it sky conditions (clouds)? ## - elsif ( $tok =~ /^(FEW|SCT|BKN|OVC|SKC|CLR)(\d\d\d)?(CB|TCU)?$/i) + elsif (!$in_remarks && $tok =~ /^(FEW|SCT|BKN|OVC|SKC|CLR)(\d\d\d)?(CB|TCU)?$/i) { push(@{$self->{sky}},$tok); my $engl = ""; @@ -570,7 +570,7 @@ ## is it temperature and dew point info? ## - elsif ($tok =~ /(M?\d\d)\/(M?\d\d)/i) + elsif (!$in_remarks && $tok =~ /(M?\d\d)\/(M?\d\d)/i) { next if $self->{temp_dew}; $self->{temp_dew} = $tok; @@ -612,7 +612,7 @@ ## remarks? ## - elsif ($tok =~ /^RMK$/i) + elsif (!$in_remarks && $tok =~ /^RMK$/i) { push(@{$self->{remarks}},$tok); $in_remarks = 1; @@ -624,7 +624,7 @@ ## sea level pressure ## - elsif ($tok =~ /^SLP(\d+)/i) + elsif ($in_remarks && $tok =~ /^SLP(\d+)/i) { $self->{slp} = $tok; $self->{SLP} = "$1 mb"; @@ -636,7 +636,7 @@ ## sea level pressure not available ## - elsif ($tok eq "SLPNO") + elsif ($in_remarks && $tok eq "SLPNO") { $self->{slp} = "SLPNO"; $self->{SLP} = "not available"; @@ -648,7 +648,7 @@ ## hourly precipitation ## - elsif ($tok =~ /^P(\d\d\d\d)$/i) + elsif ($in_remarks && $tok =~ /^P(\d\d\d\d)$/i) { $self->{hourlyprecip} = $tok; @@ -663,7 +663,7 @@ ## weather begin/end times ## - elsif ($tok =~ /^($_weather_types_pat)([BE\d]+)$/i) + elsif ($in_remarks && $tok =~ /^($_weather_types_pat)([BE\d]+)$/i) { my $engl = ""; my $times = $2; @@ -705,7 +705,7 @@ ## hourly temp/dewpoint ## - elsif ($tok =~ /^T(\d)(\d\d)(\d)(\d)(\d\d)(\d)$/i) + elsif ($in_remarks && $tok =~ /^T(\d)(\d\d)(\d)(\d)(\d\d)(\d)$/i) { $self->{hourlytempdew} = $tok; if ( $1 == 1 ) {
On Tue Jun 22 17:02:21 2004, guest wrote: Show quoted text
> Use this METAR data: > > KBUF 221854Z 23019G23KT 8SM FEW020 SCT035TCU BKN140 BKN260 21/17 A2975 > RMK AO2 PK WND 24026/1833 SLP073 TCU DSNT NW-NE T02110167 > > It reports the conditions as 'Dust Storm'. After further inspection, > it appears that the remark for 'distant' (DSNT) is the culprit. > The module reads the DS and assumes it is a condition. I am > submitting a patch that will constrain each section to its location > before or after the remark symbol (RMK).
I took over Geo::METAR and rewrote the parser. It now keeps state and parses this METAR correctly. The new Geo::METAR is version 1.15 and should be available on CPAN soon.