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,