Ticket #4226: 4226_diff.patch

File 4226_diff.patch, 2.9 KB (added by Joe Ripley <vitaminjoe@…>, 16 years ago)

Add wind chill reporting to Environment Canada grabber

  • mythplugins/mythweather/mythweather/scripts/envcan.pl

     
    148148        }
    149149        }
    150150} else {
    151         $results{'wind_spdgst'} = sprintf("%.2f (%.2f) kph", $results{'wind_speed'}, $results{'wind_gust'});
     151        $results{'wind_spdgst'} = sprintf("%.2f (%.2f)", $results{'wind_speed'}, $results{'wind_gust'});
    152152}
    153153       
    154154
  • mythplugins/mythweather/mythweather/scripts/ENVCANParser.pm

     
    33# This script parses the HTML of an Environment Canada weather forecast
    44# page as returned from http://www.weatheroffice.gc.ca.
    55#
    6 # TODO  Not exactly sure how Environment Canada reports windchill.  Looks
    7 #               like they don't report it in the summer time.  Using temperature
    8 #               as a value for now.
    9 #
    106# TODO  Environment Canada only reports 5 day forecasts.  6 day forecast
    117#               layout is used to report 5 day information.
    128#
     
    3632        $inside{"$tag-class"} = $attr{class} if defined $attr{class};
    3733        $inside{"$tag-src"}   = $attr{src} if defined $attr{src};
    3834        $inside{"$tag-longdesc"} = $attr{longdesc} if defined $attr{longdesc};
     35    $inside{"$tag-href"}     = $attr{href} if defined $attr{href};
    3936
    4037        doIMG() if $inside{img};
    4138}
     
    9794                        $results{'observation_time_rfc822'} = rfc822($1);
    9895                }
    9996        }
    100                
     97
    10198        if ($inside{dt}) {
    10299                if ($_[0] =~ /(Temperature)/) { $scratch = 1; return; }
    103100                if ($_[0] =~ /(Pressure)\/ Tendency/) { $scratch = 2; return; }
    104101                if ($_[0] =~ /(Visibility)/) { $scratch = 3; return; }
    105102                if ($_[0] =~ /(Humidity)/) { $scratch = 4; return; }
    106103                if ($_[0] =~ /(Dewpoint)/) { $scratch = 5; return; }
    107                 if ($_[0] =~ /(Wind)/) { $scratch = 6; return; }
     104                if ($_[0] =~ /(Wind Chill)/ ) { $scratch = 6; return; }
     105                if ($_[0] =~ /(Wind)/) { $scratch = 7; return; }
    108106        }
    109                
     107
    110108        if ($inside{dd}) {
    111                 if ($scratch == 1) { $_[0] =~ /(\d*).*/; $results{'temp'} = $1; $results{'windchill'} = $1; $results{'appt'} = $1; }
     109                if ($scratch == 1) { $_[0] =~ /(-?\d*).*/; $results{'temp'} = $1; }
    112110                if ($scratch == 2) { $_[0] =~ /(\d*\.\d+) kPa.*/; $results{'pressure'} = $1 * 10; }
    113111                if ($scratch == 3) { $_[0] =~ /(\d*) km/; $results{'visibility'} = $1; }
    114112                if ($scratch == 4) { $_[0] =~ /(\d*) \%/; $results{'relative_humidity'} = $1; }
    115113                if ($scratch == 5) { $_[0] =~ /(-?\d*).*/; $results{'dewpoint'} = $1; }
    116                 if ($scratch == 6) {
     114                if ($scratch == 6) { $_[0] =~ /(-?\d*).*/; $results{'appt'} = $1; $results{'windchill'} = $1; }
     115                if ($scratch == 7) {
    117116                        $_[0] =~ /.?(\w+) (\d+) km\/h/;
    118117                        $results{'wind_dir'} = $directions{$1};
    119118                        $results{'wind_speed'} = $2;