comparison fetch_weather.pl @ 486:b352722e8717

fetch_weather: FMI open data no longer requires an API key. Also the data URLs have changed, so fix those as well.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 08 Jan 2020 15:21:16 +0200
parents 6773d97a3de2
children b4be881a9908
comparison
equal deleted inserted replaced
485:b866ab8bd382 486:b352722e8717
40 "force_update" => 0, 40 "force_update" => 0,
41 "debug" => 0, 41 "debug" => 0,
42 "opt_fmi" => 0, 42 "opt_fmi" => 0,
43 "opt_tiehallinto" => 0, 43 "opt_tiehallinto" => 0,
44 "purge_threshold" => 60, 44 "purge_threshold" => 60,
45 "fmi_api_key" => "",
46 "outfile" => "", 45 "outfile" => "",
47 "http_user_agent" => "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 6.0) Opera 10.63 [en]", 46 "http_user_agent" => "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 6.0) Opera 10.63 [en]",
48 "tiehallinto_meta" => "tiehallinto.meta", 47 "tiehallinto_meta" => "tiehallinto.meta",
49 "tiehallinto_meta_period" => 7, 48 "tiehallinto_meta_period" => 7,
50 "tiehallinto_rw_url" => "http://tie.digitraffic.fi/api/v1/data/weather-data", 49 "tiehallinto_rw_url" => "http://tie.digitraffic.fi/api/v1/data/weather-data",
481 ### 480 ###
482 ### Fetch FMI data 481 ### Fetch FMI data
483 ### 482 ###
484 if (opt_chk_bool("opt_fmi")) 483 if (opt_chk_bool("opt_fmi"))
485 { 484 {
486 die("FMI data scrape enabled, but no API key set.\n") unless opt_chk_valid("fmi_api_key", 10);
487 my @fmitems = ("temperature", "humidity", "windspeedms", "totalcloudcover"); 485 my @fmitems = ("temperature", "humidity", "windspeedms", "totalcloudcover");
488 486
489 my $uri = "http://data.fmi.fi/fmi-apikey/".opt_get("fmi_api_key"). 487 my $uri = "https://opendata.fmi.fi/wfs".
490 "/wfs?request=getFeature&storedquery_id=fmi::observations::weather::". 488 "?request=getFeature".
489 "&storedquery_id=fmi::observations::weather::".
491 "multipointcoverage". 490 "multipointcoverage".
492 # "timevaluepair". 491 # "timevaluepair".
493 "&starttime=".format_time_gmt(time() - 10*60)."&endtime=".format_time_gmt(time()). 492 "&starttime=".format_time_gmt(time() - 10*60)."&endtime=".format_time_gmt(time()).
494 "&parameters=".join(",", @fmitems)."&maxlocations=100&bbox=19,59,32,75"; 493 "&parameters=".join(",", @fmitems)."&maxlocations=100&bbox=19,59,32,75";
495 494