X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fsun.pl;h=07172ce05b34cafaa794bf840b9d7d6a2fc51fa0;hb=35432a9f25350b9a5db513efbe248b61176b0684;hp=5104e2276035d73d0b13a0f452aee701d89a7b09;hpb=0e84728de35d2dadbb9d624614a471b68ae9eef6;p=spider.git diff --git a/cmd/show/sun.pl b/cmd/show/sun.pl index 5104e227..07172ce0 100644 --- a/cmd/show/sun.pl +++ b/cmd/show/sun.pl @@ -3,7 +3,7 @@ # show sunrise and sunset times for each callsign or prefix entered # # 1999/11/9 Steve Franke K9AN -# +# 2000/10/27 fixed bug involving degree to radian conversion. my ($self, $line) = @_; my @list = split /\s+/, $line; @@ -15,21 +15,41 @@ my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime))[0,1,2,3,4,5]; $month++; $yr += 1900; -foreach $l (@list) { - # prefixes ---> - my @ans = Prefix::extract($l); - next if !@ans; - my $pre = shift @ans; - my $a; - foreach $a (@ans) { - $lat = $a->{lat}; - $lon = $a->{long}; - $lat *= $d2r; - $lon *= -$d2r; - my $string=Sun::riseset($yr,$month,$day,$lat,$lon); - push @out,sprintf("%-2s %s %s",$pre,$a->name(),$string); - $l=""; +my @in; + +if (@list) { + foreach $l (@list) { + my $user = DXUser->get_current(uc $l); + if ($user && $user->lat && $user->long) { + push @in, [$user->qth, $user->lat, -$user->long, uc $l ]; + } else { + # prefixes ---> + my @ans = Prefix::extract($l); + next if !@ans; + my $pre = shift @ans; + my $a; + foreach $a (@ans) { + $lat = $a->{lat}; + $lon = -$a->{long}; + push @in, [ $a->name, $lat, $lon, $pre ]; + } + } + } +} else { + if ($self->user->lat && $self->user->long) { + push @in, [$self->user->qth, $self->user->lat, -$self->user->long, $self->call ]; + } else { + push @in, [$main::myqth, $main::mylatitude, -$main::mylongitude, $main::mycall ]; } } +push @out, $self->msg('sun'); +foreach $l (@in) { + my ($rise, $set, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0); + $l->[3] =~ s{(-\d+|/\w+)$}{}; + push @out,sprintf("%-6.6s %-30.30s %s %s %6.1f %6.1f ", $l->[3], $l->[0], $rise, $set, $az, $dec); +} + + + return (1, @out);