1. Various detail changes to remove some more warning with -w on
[spider.git] / cmd / show / station.pl
1 #
2 # show the station details
3 #
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
5 #
6 # Modifications by Iain Philipps G0RDI, 07-Dec-1998
7 #
8
9 my ($self, $line) = @_;
10 my @f = split /\s+/, uc $line;
11 my @out;
12 my $call;
13 my $seek;
14
15 if (@f == 0) {
16         return (1, $self->msg('e6')) if ($self->priv < 5); 
17         my @calls = DXUser::get_all_calls();
18         foreach $call (@calls) {
19                 my $ref = DXUser->get_current($call);
20                 next if !$ref;
21                 my $lat = $ref->lat;
22                 my $long = $ref->long;
23                 my $sort = $ref->sort || "";
24                 my $name = $ref->name || "";
25                 my $qth = $ref->qth || "";
26                 my $homenode = $ref->homenode || "";
27                 my $qra = $ref->qra || "";
28                 my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
29                 $latlong = "" unless $latlong;
30                 
31                 push @out, sprintf "%-9s %s %-12.12s %-27.27s %-9s %s %s", $call, $sort, $name, $qth, $homenode, $latlong, $qra;
32         }
33 } else {
34         foreach $call (@f) {
35                 my $ref = DXUser->get_current($call);
36                 if ($ref) {
37                         my $name = $ref->name;  
38                         my $qth = $ref->qth;
39                         my $lat = $ref->lat;
40                         my $long = $ref->long;
41                         my $node = $ref->node;
42                         my $homenode = $ref->homenode;
43                         my $lastin = $ref->lastin;
44                         my $latlong = DXBearing::lltos($lat, $long) if $lat || $long;
45                         my $last = DXUtil::cldatetime($lastin) if $ref->lastin;
46                         my $qra = $ref->qra;
47                         $qra = DXBearing::lltoqra($lat, $long) if !$qra && ($lat || $long);
48                         my $from;
49                         my ($dx, $bearing, $miles);
50                         if ($latlong) {
51                                 my ($hlat, $hlong) = ($self->user->lat, $self->user->long);
52                                 ($hlat, $hlong) = DXBearing::qratoll($self->user->qra) if $self->user->qra && !$hlat && !$hlong;
53                                 if (!$hlat && !$hlong) {
54                                         $from = "From $main::mycall";
55                                         $hlat = $main::mylatitude;
56                                         $hlong = $main::mylongitude;
57                                 }
58                                 ($bearing, $dx) = DXBearing::bdist($hlat, $hlong, $lat, $long);
59                                 $miles = $dx * 0.62133785;
60                         }
61                         
62                         my $cref = DXCluster->get($call);
63                         my $seek = $cref->mynode->call if $cref;
64
65                         if ($seek) {
66                                 push @out, "User         : $call (at $seek)";
67                         } else {
68                                 push @out, "User         : $call";
69                         }
70                         push @out, "Name         : $name" if $name;
71                         push @out, "Last Connect : $last" if $last;
72                         push @out, "QTH          : $qth" if $qth;
73                         push @out, "Location     : $latlong ($qra)" if $latlong || $qra ;
74                         push @out, sprintf("Heading      : %.0f Deg %.0f Mi. %.0f Km.", $bearing, $miles, $dx) if $latlong;
75                         push @out, "Home Node    : $homenode" if $homenode;
76                 } else {
77                         push @out, $self->msg('usernf', $call);
78                 }
79         }
80 }
81
82 return (1, @out);