Mercurial > hg > egg-tcls
diff fetch_weather.pl @ 491:f5c023538e2a
fetch_weather, weather: Remove certain "data translation" from fetch_weather and move that into weather.tcl.
Also rename some tokens.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 23 Jan 2020 05:01:37 +0200 |
parents | 120eb7eb7398 |
children | ec5f0ed99a28 |
line wrap: on
line diff
--- a/fetch_weather.pl Tue Jan 21 22:56:37 2020 +0200 +++ b/fetch_weather.pl Thu Jan 23 05:01:37 2020 +0200 @@ -119,49 +119,6 @@ } -my %th_rain_states = -( - "Pouta" => "poutaa", - "Heikko" => "heikkoa sadetta", - "Kohtalainen" => "kohtalaista sadetta", - "Voimakas" => "voimakasta sadetta", -); - -my $th_rain_states_k = join("|", map {quotemeta} sort { length($b)<=>length($a) } keys %th_rain_states); - -sub translate_rain($) -{ - my $tmp = $_[0]; - $tmp =~ s/($th_rain_states_k)/$th_rain_states{$1}/igo; - return $tmp; -} - - -my %th_cloud_states = -( - 0 => "selkeää", - 1 => "melkein selkeää", - 2 => "verrattain selkeää", - 3 => "verrattain selkeää", - 4 => "puolipilvistä", - 5 => "verrattain pilvistä", - 6 => "verrattain pilvistä", - 7 => "melkein pilvistä", - 8 => "pilvistä", -); - -sub translate_clouds($) -{ - return "" if ($_[0] eq "NaN" || $_[0] eq ""); - my $tmp = int($_[0]); - foreach my $n (sort { $a <=> $b } keys %th_cloud_states) - { - return $th_cloud_states{$n}." (".$n."/8)" if ($tmp == $n); - } - return $tmp; -} - - sub force_decode_utf8($) { if (!utf8::is_utf8($_[0])) @@ -492,7 +449,7 @@ "&storedquery_id=fmi::observations::weather::multipointcoverage". "&starttime=".format_time_gmt(time() - 10*60)."&endtime=".format_time_gmt(time()). "¶meters=".join(",", @fmitems). - "&maxlocations=200&bbox=19,59,32,75"; + "&maxlocations=300&bbox=19,59,32,75"; print STDERR "FMI URI: ".$uri."\n" if (opt_get_int("debug") > 0); @@ -588,7 +545,7 @@ plonk_data($frec->{"winddirection"}), # Station type dependant data - translate_clouds(plonk_data($frec->{"totalcloudcover"})), + plonk_data($frec->{"totalcloudcover"}), ]; } }