From 3d8ababbfe27f970fef9ccf8d0618e651b29e707 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Wed, 11 Sep 2019 08:19:31 +0200 Subject: [PATCH] add support for set weather newLocation, temorary location change --- wundergroundAPI.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/wundergroundAPI.pm b/wundergroundAPI.pm index 99c1d45..726b4eb 100644 --- a/wundergroundAPI.pm +++ b/wundergroundAPI.pm @@ -172,6 +172,15 @@ sub setRetrieveData { return 0; } +sub setLocation { + my ($self,$lat,$long) = @_; + + $self->{lat} = $lat; + $self->{long} = $long; + + return 0; +} + sub getFetchTime { my $self = shift; @@ -188,10 +197,19 @@ sub _RetrieveDataFromWU($) { my $self = shift; # retrieve data from cache - if ( ( time() - $self->{fetchTime} ) < $self->{cachemaxage} ) { + if ( ( time() - $self->{fetchTime} ) < $self->{cachemaxage} + and $self->{cached}->{lat} == $self->{lat} + and $self->{cached}->{long} == $self->{long} + ) + { return _CallWeatherCallbackFn($self); } + $self->{cached}->{lat} = $self->{lat} + unless ( $self->{cached}->{lat} == $self->{lat} ); + $self->{cached}->{long} = $self->{long} + unless ( $self->{cached}->{long} == $self->{long} ); + my $paramRef = { timeout => 15, self => $self,