Skip to content

Commit

Permalink
Added option to manually define the RWR zone with nws_rwr_zone option…
Browse files Browse the repository at this point in the history
… in the mh.private.ini
  • Loading branch information
waynieack committed Feb 24, 2017
1 parent 6fd39d7 commit 8566037
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions code/common/internet_weather.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sub normalize_conditions {
if ( said $v_get_internet_weather_data) {
if (&net_connect_check) {
set $p_weather_data
qq|get_weather -state $config_parms{state} -city "$config_parms{city}"|;
qq|get_weather -state $config_parms{state} -city "$config_parms{city}" -nws_rwr_zone $config_parms{nws_rwr_zone}|;
start $p_weather_data;
$v_get_internet_weather_data->respond(
"app=weather Weather data requested for $config_parms{city}, $config_parms{state}"
Expand All @@ -97,7 +97,7 @@ sub normalize_conditions {
if ( said $v_get_internet_weather_conditions) {
if (&net_connect_check) {
set $p_weather_conditions
qq|get_weather -state $config_parms{state} -city "$config_parms{city}" -data conditions|;
qq|get_weather -state $config_parms{state} -city "$config_parms{city}" -data conditions -nws_rwr_zone $config_parms{nws_rwr_zone}|;
start $p_weather_conditions;
$v_get_internet_weather_conditions->respond(
"app=weather Weather conditions requested for $config_parms{city}, $config_parms{state}"
Expand Down
23 changes: 15 additions & 8 deletions lib/site/Geo/WeatherNOAA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ sub ucfirst_words {
#########################################################################

sub get_city_hourly {
my ( $city, $state, $filename, $fileopt, $UA ) = @_;

my ( $city, $state, $filename, $fileopt, $UA, $rwrzone ) = @_;
# City and state in all caps please
#
$city = uc $city;
Expand All @@ -493,11 +492,12 @@ sub get_city_hourly {
# Get data
#
my $zone = &get_zone( $ZONE_SEARCH_URL, "$city, $state" );
$rwrzone = $zone unless length($rwrzone);
my $URL =
$URL_BASE
. $zone
. '&issuedby='
. $zone
. $rwrzone
. '&product=RWR&format=txt&version=1&glossary=0';

#print STDERR "Getting data from $URL\n";
Expand All @@ -514,7 +514,14 @@ sub get_city_hourly {
$data = get_data( $URL, $filename, $fileopt, $UA );
$datalength = length($data);
}

if ( $data =~ /None issued/ ) {
print "
NWS is not returing any information, please configure the 2 or 3 letter zone
in the mh.private.ini with the nws_rwr_zone option. IE: nws_rwr_zone=LIX
The zone can be found at the following site:
http://forecast.weather.gov/product_sites.php?site=$zone&product=RWR\n
";
}
#print STDERR "Got data ($datalength)\n";

# Return error if there's an error
Expand Down Expand Up @@ -598,14 +605,14 @@ sub get_city_hourly {
} # get_city_hourly()

sub print_current {
my ( $city, $state, $filename, $fileopt, $UA ) = @_;
my $in = process_city_hourly( $city, $state, $filename, $fileopt, $UA );
my ( $city, $state, $filename, $fileopt, $UA, $rwrzone ) = @_;
my $in = process_city_hourly( $city, $state, $filename, $fileopt, $UA, $rwrzone );
return wrap( '', ' ', $in );
}

sub process_city_hourly {
my ( $city, $state, $filename, $fileopt, $UA ) = @_;
my $in = get_city_hourly( $city, $state, $filename, $fileopt, $UA );
my ( $city, $state, $filename, $fileopt, $UA, $rwrzone ) = @_;
my $in = get_city_hourly( $city, $state, $filename, $fileopt, $UA, $rwrzone );

$state = uc($state);

Expand Down

0 comments on commit 8566037

Please sign in to comment.