]> scm.dxcluster.org Git - spider.git/blob - cmd/show/station.pl
fixed sh/dx
[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 $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
24                 push @out, sprintf "%-9s %s %-12.12s %-27.27s %-9s %s %s", $call, $ref->sort, $ref->name, $ref->qth, $ref->homenode, $latlong, $ref->qra;
25         }
26 } else {
27         foreach $call (@f) {
28                 my $ref = DXUser->get_current($call);
29                 if ($ref) {
30                         my $name = $ref->name;  
31                         my $qth = $ref->qth;
32                         my $lat = $ref->lat;
33                         my $long = $ref->long;
34                         my $node = $ref->node;
35                         my $homenode = $ref->homenode;
36                         my $lastin = $ref->lastin;
37                         my $latlong = DXBearing::lltos($lat, $long) if $lat || $long;
38                         my $last = DXUtil::cldatetime($lastin) if $ref->lastin;
39                         my $qra = $ref->qra;
40                         $qra = DXBearing::lltoqra($lat, $long) if !$qra && ($lat || $long);
41                         my $from;
42                         my ($dx, $bearing, $miles);
43                         if ($latlong) {
44                                 my ($hlat, $hlong) = ($self->user->lat, $self->user->long);
45                                 ($hlat, $hlong) = DXBearing::qratoll($self->user->qra) if $self->user->qra && !$hlat && !$hlong;
46                                 if (!$hlat && !$hlong) {
47                                         $from = "From $main::mycall";
48                                         $hlat = $main::mylatitude;
49                                         $hlong = $main::mylongitude;
50                                 }
51                                 ($bearing, $dx) = DXBearing::bdist($hlat, $hlong, $lat, $long);
52                                 $miles = $dx * 0.62133785;
53                         }
54                         
55                         my $cref = DXCluster->get($call);
56                         my $seek = $cref->mynode->call if $cref;
57
58                         if ($seek) {
59                                 push @out, "User         : $call (at $seek)";
60                         } else {
61                                 push @out, "User         : $call";
62                         }
63                         push @out, "Name         : $name" if $name;
64                         push @out, "Last Connect : $last" if $last;
65                         push @out, "QTH          : $qth" if $qth;
66                         push @out, "Location     : $latlong ($qra)" if $latlong || $qra ;
67                         push @out, sprintf("Heading      : %.0f Deg %.0f Mi. %.0f Km. $from", $bearing, $miles, $dx) if $latlong;
68                         push @out, "Home Node    : $homenode" if $homenode;
69                 } else {
70                         push @out, $self->msg('usernf', $call);
71                 }
72         }
73 }
74
75 return (1, @out);