- Support the "CAVOK" string: "Ceiling and visibility OK"

- Support the "9999" string: visibility > 10km
- All the world is not North America
  - Support Pressure values in hectopascals
  - Support weather stations outside of North America:
    Move Station ID detection out of the token parser loop
- Bump PORTREVISION and take Maintainership
This commit is contained in:
Tilman Keskinoz 2004-09-03 18:43:23 +00:00
parent cf81cc1cd3
commit f93e3fc274
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=118065
2 changed files with 182 additions and 1 deletions

View File

@ -7,12 +7,13 @@
PORTNAME= Geo-METAR
PORTVERSION= 1.14
PORTREVISION= 1
CATEGORIES= astro
MASTER_SITES= ${MASTER_SITE_PERL_CPAN}
MASTER_SITE_SUBDIR= Geo
PKGNAMEPREFIX= p5-
MAINTAINER= ports@FreeBSD.org
MAINTAINER= arved@FreeBSD.org
COMMENT= A perl module that processes METAR information from NOAA sources
PERL_CONFIGURE= yes

View File

@ -0,0 +1,180 @@
--- METAR.pm.orig Sat Nov 25 01:07:51 2000
+++ METAR.pm Fri Sep 3 20:33:01 2004
@@ -95,9 +95,13 @@
# PRESSURE
#
+# USA and Canada:
# The pressure, or altimeter setting, at the reporting site recorded in
# inches of mercury (Hg) minus the decimal point. It should always look
# like (A\d\d\d\d).
+# Rest of the World:
+# The pressure, or altimeter setting, at the reporting site recorded in
+# hectopascals(hPa). It should always look like (Q\d\d\d\d).
# REMARKS
#
@@ -164,6 +168,7 @@
my %_sky_types = (
SKC => "Sky Clear",
CLR => "Sky Clear",
+ CAVOK => "Sky Clear",
SCT => "Scattered",
BKN => "Broken",
FEW => "Few",
@@ -366,52 +371,87 @@
$self->{type} = "METAR";
$self->{TYPE} = "Routine Weather Report";
- while (defined($tok = shift(@toks))) ## as long as there are tokens
+ $tok = shift(@toks);
+ print "trying to match [$tok]\n" if $self->{debug};
+
+ ##
+ ## is it a report type?
+ ##
+
+ if (($tok =~ /METAR/i) or ($tok =~ /SPECI/i))
{
+ $self->{type} = $tok;
+
+ if ($self->{type} eq "METAR")
+ {
+ $self->{TYPE} = "Routine Weather Report";
+ }
+ elsif ($self->{type} eq "SPECI")
+ {
+ $self->{TYPE} = "Special Weather Report";
+ }
+ print "[$tok] is a report type.\n" if $self->{debug};
+
+ $tok = shift(@toks);
print "trying to match [$tok]\n" if $self->{debug};
##
- ## is it a report type?
+ ## is it a site ID?
##
- if (($tok =~ /METAR/i) or ($tok =~ /SPECI/i))
+ if ($tok =~ /[A-Z]{4,4}/)
{
- $self->{type} = $tok;
-
- if ($self->{type} eq "METAR")
- {
- $self->{TYPE} = "Routine Weather Report";
- }
- elsif ($self->{type} eq "SPECI")
- {
- $self->{TYPE} = "Special Weather Report";
- }
- print "[$tok] is a report type.\n" if $self->{debug};
- next;
+ $self->{site} = $tok;
+ print "[$tok] is a site ID.\n" if $self->{debug};
}
##
- ## is is a site ID?
+ ## Most likely something is wrong, but to be sure put the token back
+ ## on the stack
##
- elsif ($tok =~ /K[A-Z]{3,3}/)
+ else
{
- $self->{site} = $tok;
- print "[$tok] is a site ID.\n" if $self->{debug};
- next;
+ unshift(@toks,$tok);
}
+ }
+
+ ##
+ ## is it a site ID?
+ ##
+
+ elsif ($tok =~ /[A-Z]{4,4}/)
+ {
+ $self->{site} = $tok;
+ print "[$tok] is a site ID.\n" if $self->{debug};
+ }
+
+ ##
+ ## Most likely something is wrong, but to be sure put the token back
+ ## on the stack
+ ##
+
+ else
+ {
+ unshift(@toks,$tok);
+ }
+
+ # The order of the remaining stack is not defined, so do a patternmatching loop
+
+ while (defined($tok = shift(@toks))) ## as long as there are tokens
+ {
+ print "trying to match [$tok]\n" if $self->{debug};
+
##
## is it a date/time?
##
- elsif ($tok =~ /\d{6,6}Z/i)
+ if ($tok =~ /\d{6,6}Z/i)
{
$self->{date_time} = $tok;
print "[$tok] is a date/time.\n" if $self->{debug};
next;
-
-
}
##
@@ -447,6 +487,14 @@
next;
}
+ ## 9999 == visibility is better than 10 km
+ elsif ($tok eq "9999")
+ {
+ $self->{visibility} = $tok;
+ print "[$tok] is visibility information.\n" if $self->{debug};
+ next;
+ }
+
##
## is it visibility information with a leading digit?
##
@@ -526,7 +574,7 @@
## is it sky conditions (clear)?
##
- elsif ( $tok eq "SKC" || $tok eq "CLR" )
+ elsif ( $tok eq "SKC" || $tok eq "CLR" || $tok eq "CAVOK")
{
push(@{$self->{sky}},$tok);
push(@{$self->{SKY}}, "Sky Clear");
@@ -588,10 +636,20 @@
## is it an altimeter setting?
##
+ ## Northamerican setting in inches
elsif (!$in_remarks && $tok =~ /^A(\d\d)(\d\d)$/i)
{
$self->{alt} = $tok;
$self->{ALT} = "$1.$2";
+ print "[$tok] is an altimeter setting.\n" if $self->{debug};
+ next;
+ }
+
+ ## setting in hectopascals (hPa)
+ elsif (!$in_remarks && $tok =~ /^Q(\d\d)(\d\d)$/i)
+ {
+ $self->{alt} = $tok;
+ $self->{ALT} = "$1$2";
print "[$tok] is an altimeter setting.\n" if $self->{debug};
next;
}