Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather noaa #671

Merged
merged 2 commits into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/get_weather
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ my %parms;
if (
!&GetOptions(
\%parms, "h", "help", "v", "city:s", "zone:s",
"state:s", "data=s", "no_log"
"state:s", "data=s", "no_log", "nws_rwr_zone:s"
)
or @ARGV
or ( $parms{h} or $parms{help} )
Expand Down Expand Up @@ -102,7 +102,7 @@ $Geo::WeatherNOAA::proxy_from_env = 1;
if ( $data{conditions} ) {
print "\nGetting the current weather for $parms{city}, $parms{state}\n";
$conditions =
print_current( $parms{city}, $parms{state}, undef, undef, undef, 1 );
print_current( $parms{city}, $parms{state}, undef, undef, undef, $parms{nws_rwr_zone} );
$conditions =~ s/°F/ degrees /;
$conditions =~ s/ in\./ inches. /g;
}
Expand Down
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