Skip to content

Commit

Permalink
Fix Environment Canada animated maps.
Browse files Browse the repository at this point in the history
As the support for the "pile of images" animation was removed to simplify the
mythweather code, this script stopped working.  Additionally, it was not
returning any copyright data.  As the requirement for Image::Magick has already
been added for some of the mythnetvision scripts, there's little reason not to
use it in mythweather.  To fix this animation, we are now reading in each
downloaded image in turn with Image::Magick, and making an animated GIF to pass
to mythweather.

Fixes #9467
  • Loading branch information
Beirdo committed Jan 11, 2011
1 parent 3128c78 commit 212062c
Showing 1 changed file with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/perl
# vim:ts=4:sw=4:ai:et:si:sts=4
#
# Animated satellite map grabber for Environment Canada.
#
Expand All @@ -13,6 +14,7 @@
use warnings;

use English;
use File::Path;
use File::Basename;
use Cwd 'abs_path';
use lib dirname(abs_path($0 or $PROGRAM_NAME)),
Expand All @@ -23,17 +25,18 @@
use LWP::Simple;
use Date::Manip;
use ENVCANMapSearch;
use Image::Magick;

our ($opt_v, $opt_t, $opt_T, $opt_l, $opt_u, $opt_d);

my $name = 'ENVCAN-Animated-Map';
my $version = 0.3;
my $version = 0.4;
my $author = 'Joe Ripley';
my $email = 'vitaminjoe@gmail.com';
my $updateTimeout = 10*60;
my $retrieveTimeout = 30;
my @types = ('amdesc', 'updatetime', 'animatedimage');
my $dir = "./";
my @types = ('amdesc', 'updatetime', 'animatedimage', 'copyright');
my $dir = "/tmp/envcan";

getopts('Tvtlu:d:');

Expand Down Expand Up @@ -66,6 +69,10 @@
$dir = $opt_d;
}

if (!-d $dir) {
mkpath( $dir, {mode => 0755} );
}

my $loc = shift;

if (!defined $loc || $loc eq "") {
Expand Down Expand Up @@ -97,24 +104,27 @@

# Download map files, if necessary (maps are stale after 15 minutes)
my $i = 0;
my $outimage = Image::Magick->new;
foreach my $image (@image_list) {
my $getImage = 1;
if (-f $path . $i) {
if (-f "$path$i" ) {
my @stats = stat(_);
if ($stats[9] > (time - 900)) { $i++; next; }
if ($stats[9] > (time - 900)) {
$outimage->Read( "$path$i" );
$i++;
next;
}
}

getstore($base_url . $image, $path . $i);
getstore($base_url . $image, "$path$i");
$outimage->Read( "$path$i" );
$i++;
}

# Determine image size
if (!$size) {
use Image::Size;
my ($x, $y) = imgsize("${path}0");
$size = "${x}x$y" if ($x && $y);
}
$outimage->Write( filename => "$dir/$file.gif", delay => 75 );

print "amdesc::$desc\n";
printf "animatedimage::${path}%%1-$i%s\n", ($size && "-$size" || '');
print "updatetime::Last Updated on " . UnixDate("now", "%b %d, %I:%M %p %Z") . "\n";
print "amdesc::$desc\n";
print "animatedimage::$dir/$file.gif\n";
print "updatetime::Last Updated on " .
UnixDate("now", "%b %d, %I:%M %p %Z") . "\n";
print "copyright::Environment Canada\n";

0 comments on commit 212062c

Please sign in to comment.