Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
bufr.pm:bufrdump.pl_source [2015-03-18 13:17:24] pals |
bufr.pm:bufrdump.pl_source [2022-05-31 09:29:31] (current) |
||
---|---|---|---|
Line 39: | Line 39: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 188: | Line 188: | ||
if ($txt) { | if ($txt) { | ||
if ($sort) { | if ($sort) { | ||
- | # Sort wmonr before nationalnr before call | + | # Sort wmonr before nationalnr before call sign before |
- | # sign before | + | # buoy_id before aircraft |
if ($msg{wmonr}) { | if ($msg{wmonr}) { | ||
$stnid = ' | $stnid = ' | ||
Line 200: | Line 200: | ||
} elsif ($msg{aircraft}) { | } elsif ($msg{aircraft}) { | ||
$stnid = ' | $stnid = ' | ||
+ | } elsif ($msg{icao_id}) { | ||
+ | $stnid = ' | ||
+ | } elsif ($msg{wigosid}) { | ||
+ | $stnid = ' | ||
} else { | } else { | ||
# Skip observation if no station identification found | # Skip observation if no station identification found | ||
Line 406: | Line 410: | ||
return unless $criteria_ref; | return unless $criteria_ref; | ||
- | my @ascii_params = qw(aircraft call_sign icao_id name obstime type); | + | my @ascii_params = qw(aircraft call_sign icao_id name obstime type wigosid); |
# Note that the loop counter $i might be changed in the loop | # Note that the loop counter $i might be changed in the loop | ||
Line 451: | Line 455: | ||
my $op; | my $op; | ||
if ($f_operator eq '<' | if ($f_operator eq '<' | ||
- | | $f_operator eq '< | + | |
- | | $f_operator eq '>' | + | |
- | | $f_operator eq '> | + | |
- | | $f_operator eq ' | + | |
- | | $f_operator eq ' | + | |
$op = $f_operator; | $op = $f_operator; | ||
} elsif ($f_operator eq ' | } elsif ($f_operator eq ' | ||
- | | $f_operator eq ' | + | || $f_operator eq ' |
if (grep {$_ eq $f_param} @ascii_params) { | if (grep {$_ eq $f_param} @ascii_params) { | ||
$msg_value =~ s/\s*$//; | $msg_value =~ s/\s*$//; | ||
Line 469: | Line 473: | ||
} | } | ||
- | | + | # Some parameters might need special massaging |
- | if (grep {$_ eq $f_param} @ascii_params) { | + | |
- | # Single quoting is neccessary to make the later eval work | + | |
- | $msg_value = "'" | + | |
- | } | + | |
- | } else { | + | |
if ($f_param eq ' | if ($f_param eq ' | ||
# Make non octal by removing leading 0 | # Make non octal by removing leading 0 | ||
Line 505: | Line 505: | ||
} | } | ||
} | } | ||
+ | |||
+ | my $condition = " | ||
+ | # Some values should be string values | ||
+ | if ($f_operator =~ /~/) { | ||
+ | $condition = " | ||
+ | } elsif (grep {$_ eq $f_param} @ascii_params) { | ||
+ | $condition = " | ||
+ | } | ||
# Finally, do the criterium check | # Finally, do the criterium check | ||
- | | + | if (eval $condition) { |
- | # No need to check the remaining alternative criteria | + | |
- | $i += $num_alt if $num_alt; | + | |
- | next; | + | |
- | } else { | + | } else { |
- | next if $num_alt; | + | |
- | return 1; | + | |
- | } | + | } |
} | } | ||
Line 528: | Line 536: | ||
return if !$req_stations; | return if !$req_stations; | ||
die " | die " | ||
- | . "' | + | . "' |
unless $req_stations | unless $req_stations | ||
- | =~ / | + | =~ / |
my ($id, $rest) = split /=/, $req_stations; | my ($id, $rest) = split /=/, $req_stations; | ||
Line 591: | Line 599: | ||
} | } | ||
- | my @ascii_params = qw(aircraft call_sign icao_id obstime name type); | + | my @ascii_params = qw(aircraft call_sign icao_id obstime name type wigosid); |
my $lexical_sort = grep {$_ eq $sort_on} @ascii_params; | my $lexical_sort = grep {$_ eq $sort_on} @ascii_params; | ||
Line 690: | Line 698: | ||
--sort | --sort | ||
first stations with wmonr, then stations with nationalnr, | first stations with wmonr, then stations with nationalnr, | ||
- | | + | |
+ | | ||
--sort_on < | --sort_on < | ||
values of parameter, or decreasing values if a ' | values of parameter, or decreasing values if a ' | ||
Line 771: | Line 780: | ||
criteria which should match < | criteria which should match < | ||
< | < | ||
- | follows =~ and !~ should be a Perl regular expression. The parameter | + | follows =~ and !~ should be a Perl match regular expression. The parameter |
criteria may be phrased as alternatives by separating them with ' | criteria may be phrased as alternatives by separating them with ' | ||
a single line. An example filter file is | a single line. An example filter file is | ||
Line 799: | Line 808: | ||
- | call_sign =~ '^L[A-N]..$' | + | call_sign =~ /^L[A-N]..$/ |
obstime >= ' | obstime >= ' | ||
HW | HWA | PW | PWA | HW | HWA | PW | PWA | ||
Line 830: | Line 839: | ||
--station buoyid=64607, | --station buoyid=64607, | ||
--station aircraft=EU3421, | --station aircraft=EU3421, | ||
+ | --station icao_id=ENGM, | ||
+ | --station wigosid=0-376-0-511, | ||
You cannot mix different kinds of stations this way (before ' | You cannot mix different kinds of stations this way (before ' | ||
- | must choose either wmonr, nationalnr, call_sign, buoy_id | + | must choose either wmonr, nationalnr, call_sign, buoy_id, aircraft, |
- | aircraft). Note also that providing the stations in the BUFR | + | icao_id or wigosid). Note also that providing the stations in the BUFR |
descriptor part (first part) of the filter file will speed up | descriptor part (first part) of the filter file will speed up | ||
execution time considerably, | execution time considerably, |