I wrote a PERL script that does exactly this and also removes any duplicate entries from the mesomap "<map>. It removes the <base> tag which is in an "illegal" position and does some other cleanup as well. It also formats the title attribute data to shorten it as much as possible(changing "North" to "N" for example) because there is a limitation on how much data some browsers will display on the mouseover before they truncate.
I'm not using it at the moment because I can't get it to run from a PHP include after a hosting change and I kind of placed figuring that out on the backburner.
To make this work you need to create a template in VWS that contains the following:
<table>
<tr>
<td><img src="wximg/mesomap.jpg" alt="SWFL Conditions" ></td>
</tr>
</table>
The code is below, it might help give you a starting point:
#!/usr/bin/perl
# DON"T FORGET TO SET THE PATH!
# mesomapfix 1.0
# exercise some good cgi practices
$|= 1;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Fcntl;
use strict;
use vars qw($count $line $key $temp
@vwsfile @fixed
%linelist
);
# plug the DoS security holes in CGI.pm
$CGI::DISABLE_UPLOADS = '1';
$CGI::POST_MAX = 1024 * 10; # max post size is 10K
#untaint the $ENV{path}
$ENV{'PATH'} = '/usr/lib';
#############################
# variables for your system #
#############################
# mesomap file
# MUST BE FULL PATH!
my $mesomap_file = '/your/path/to/mesomap/file';
##############
# here we go #
##############
# start by opening the VWS produced file
sysopen(VWSFILE, "$mesomap_file", O_RDONLY)
or die "Couldn't open mesomap file \"$mesomap_file\" for read";
@vwsfile=<VWSFILE>;
close VWSFILE;
chomp @vwsfile;
#get rid of the garbage
$vwsfile[2] =~ s/\<td\>//i;
$vwsfile[2] =~ s/\<\/td\>//i;
$vwsfile[2] =~ s/Conditions\"\>/Conditions\" \/\>/i;
$vwsfile[3] =~ s/\<base target=\"_blank\"\>//i;
$vwsfile[3] =~ s/\<map /\<map id=\"MESOMAP\" /i;
push (@fixed, $vwsfile[2], "$vwsfile[3]\n");
# filter out all the entries that are off the map
@vwsfile = grep !/coords.*\-/, @vwsfile;
# grab each area line put ID's and make a hash
%linelist = ();
$count = "0";
foreach $line (@vwsfile){
if ($line =~ /\<area.*ID\: /){
if (!$linelist{$line}) {
$linelist{$line} = $count;
} # end if
} # end if
$count++;
} # end foreach
# start processing
foreach $key (keys %linelist) {
push (@fixed, "$vwsfile[$linelist{$key}]\n");
$count= '1';
until ($count == '10') {
push (@fixed, "$vwsfile[$linelist{$key}+$count]\n");
$count++;
} # end until
my $last_alt = $vwsfile[$linelist{$key}+$count];
chop($last_alt);
chop($last_alt);
push (@fixed, "$last_alt\n");
$count= '1';
$temp = "title=\"";
until ($count == '10') {
my $temp1 = $vwsfile[$linelist{$key}+$count];
chop $temp1;
if ($count == 2) {
$temp1 =~ s/Time://;
$temp1 = substr($temp1, 7);
$temp1 = substr($temp1, 0, 5);
} # end if
if ($count == 6) {
$temp1 =~ s/in//;
} # end if
if ($count == 9) {
$temp1 =~ s/North/N/;
$temp1 =~ s/South/S/;
$temp1 =~ s/East/E/;
$temp1 =~ s/West/W/;
} # end if
$temp .= "$temp1\,";
$count++;
} # end until
my $temp1 = $vwsfile[$linelist{$key}+$count];
chop $temp1;
chop $temp1;
$temp1 =~ s/Hourly Rain:/Rain:/;
$temp .= "$temp1";
$temp =~ s/\s//;
$temp =~ s/City://;
$temp =~ s/\sTemp://;
$temp =~ s/DewPoint:/DPt:/;
$temp =~ s/Humidity:/RH:/;
$temp =~ s/Barometer:/Bar:/;
$temp =~ s/Wind Speed:/Wind:/;
$temp =~ s/Wind Gust:/Gust:/;
$temp =~ s/Wind Dir:/Dir:/;
$temp =~ s/°F//g;
$temp =~ s/:\s/:/g;
$temp =~ s/mph//g;
push (@fixed, "$temp \/>\n");
} # end foreach
push (@fixed, '</map>');
# print it
print "Content-type: text/html \n\n";
print "@fixed";
print "\n";
######################
# common subroutines #
######################
###################################################################################
# print_error: subroutine to output error messages. Useful for debugging as well. #
###################################################################################
sub print_error {
my $error = shift;
print "content-type: text/html \n\n";
print "$error";
exit(0);
} # end sub print_error