1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/usr/bin/perl
#
#
# Contributed to the public domain. Authored by Jeremy McDermond
# (NH6Z).
#
# This script takes a single argument: The abbreviation of the
# radar station off of the NWS site, and outputs to STDOUT a .geo
# file that should be correct.
# NOTE: You'll need to install "LWP::UserAgent" and "Image::Size"
# from CPAN to make it work.
#
# Here's a typical invocation which creates a NYC Ridge Radar .geo
# file called OKX_NOR.geo:
#
# ./ridge_radar.pl OKX > OKX_NOR.geo
#
# Of course you'd typically put the resulting file in your Xastir
# maps directory and reindex maps to make it available for use.
use strict;
use LWP::UserAgent;
use Image::Size;
my $station = uc($ARGV[0]);
my $gif_url = 'https://radar.weather.gov/ridge/RadarImg/N0R/' . $station . '_N0R_0.gif';
my $response = LWP::UserAgent->new->request(
HTTP::Request->new( GET => $gif_url )
);
unless($response->is_success) {
die "Couldn't get radar image: ", $response->status_line, "\n";
}
my ($img_x, $img_y) = imgsize(\$response->content);
my $response = LWP::UserAgent->new->request(
HTTP::Request->new( GET => 'https://radar.weather.gov/ridge/RadarImg/N0R/' . $station . '_N0R_0.gfw' )
);
unless($response->is_success) {
die "Couldn't get radar descriptor: ", $response->status_line, "\n";
}
my ( $yscale, undef, undef, $xscale, $lon, $lat ) = split(/\r\n/, $response->content);
my $tiepoint_lat = $lat - ($yscale * $img_y);
my $tiepoint_lon = $lon - ($xscale * $img_x);
print "URL\t\t$gif_url\n";
print "TIEPOINT\t0\t0\t$lon\t$lat\n";
print "TIEPOINT\t$img_x\t$img_y\t$tiepoint_lon\t$tiepoint_lat\n";
print "IMAGESIZE\t$img_x\t$img_y\n";
print "REFRESH\t\t60\n";
print "TRANSPARENT\t0x0\n";
print "PROJECTION\tLatLon\n";
|