changeset 349:f7793ef7c925

fetch_weather: Improve debugging.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 01 Nov 2015 22:04:45 +0200
parents 9f64f54c2fb3
children 51c08336d7b1
files fetch_weather.pl
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_weather.pl	Thu Oct 29 15:51:17 2015 +0200
+++ b/fetch_weather.pl	Sun Nov 01 22:04:45 2015 +0200
@@ -284,6 +284,7 @@
     else
     {
       my $data = $xml->{"soap:Body"}{"RoadWeatherResponse"};
+      print STDERR "Checking Tiehallinto response from ".$uri."\n" if (opt_get_int("debug") > 0);
 
       # Check if we need to update the static meta data
       my $meta_file = opt_get("tiehallinto_static_meta");
@@ -332,11 +333,13 @@
       # Parse XML and combine with the station meta data
       if (defined($data->{"roadweatherdata"}))
       {
+        my $nrecords = 0;
         foreach my $wdata (@{$data->{"roadweatherdata"}{"roadweather"}})
         {
           my $wid = $wdata->{"stationid"};
           if (defined($meta_data->{$wid}))
           {
+            $nrecords++;
             $weatherdata->{$meta_data->{$wid}[3]} =
             [
               1,
@@ -348,6 +351,7 @@
             ];
           }
         }
+        print STDERR $nrecords." records from Tiehallinto.\n" if (opt_get_int("debug") > 0);
       }
       else
       {
@@ -421,11 +425,14 @@
         if ($floc->{"gml:pos"} =~ /^\s*([\+\-]?\d+\.\d*)\s+([\+\-]?\d+\.\d*)\s*$/)
         {
           my ($flat, $flong) = ($1, $2);
+          my $nrecords = 0;
+
           # Should use a hash -
           foreach my $flol (@farray)
           {
             if ($flol->{"lat"} == $flat && $flol->{"long"} == $flong)
             {
+              $nrecords++;
               $weatherdata->{$floc->{"gml:name"}} =
               [
                 1,
@@ -438,6 +445,7 @@
               ];
             }
           }
+          print STDERR $nrecords." records from FMI.\n" if (opt_get_int("debug") > 0);
         }
       }
     } else {