1. Sort out PC41 handling to include type 5 records for QRA locators and also
[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 push @f, $self->call unless @f;
15
16 if (@f == 1 && uc $f[0] eq 'ALL') {
17         return (1, $self->msg('e6')) if ($self->priv < 6); 
18         my @calls = DXUser::get_all_calls();
19         foreach $call (@calls) {
20                 my $ref = DXUser->get_current($call);
21                 next if !$ref;
22                 my $lat = $ref->lat;
23                 my $long = $ref->long;
24                 my $sort = $ref->sort || "";
25                 my $name = $ref->name || "";
26                 my $qth = $ref->qth || "";
27                 my $homenode = $ref->homenode || "";
28                 my $qra = $ref->qra || "";
29                 my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
30                 $latlong = "" unless $latlong;
31                 
32                 push @out, sprintf "%-9s %s %-12.12s %-27.27s %-9s %s %s", $call, $sort, $name, $qth, $homenode, $latlong, $qra;
33         }
34 } else {
35         foreach $call (@f) {
36                 my $ref = DXUser->get_current($call);
37                 if ($ref) {
38                         my $name = $ref->name;  
39                         my $qth = $ref->qth;
40                         my $lat = $ref->lat;
41                         my $long = $ref->long;
42                         my $node = $ref->node;
43                         my $homenode = $ref->homenode;
44                         my $lastin = $ref->lastin;
45                         my $latlong = DXBearing::lltos($lat, $long) if $lat || $long;
46                         my $last = DXUtil::cldatetime($lastin) if $ref->lastin;
47                         my $qra = $ref->qra;
48                         $qra = DXBearing::lltoqra($lat, $long) if !$qra && ($lat || $long);
49                         my $from;
50                         my ($dx, $bearing, $miles);
51                         if ($latlong) {
52                                 my ($hlat, $hlong) = ($self->user->lat, $self->user->long);
53                                 ($hlat, $hlong) = DXBearing::qratoll($self->user->qra) if $self->user->qra && !$hlat && !$hlong;
54                                 if (!$hlat && !$hlong) {
55                                         $from = "From $main::mycall";
56                                         $hlat = $main::mylatitude;
57                                         $hlong = $main::mylongitude;
58                                 }
59                                 ($bearing, $dx) = DXBearing::bdist($hlat, $hlong, $lat, $long);
60                                 $miles = $dx * 0.62133785;
61                         }
62                         
63                         my $cref = Route::get($call);
64                         my $seek = join(',', $cref->parents) if $cref;
65
66                         if ($seek) {
67                                 push @out, "User         : $call (at $seek)";
68                         } else {
69                                 push @out, "User         : $call";
70                         }
71                         push @out, "Name         : $name" if $name;
72                         push @out, "Last Connect : $last" if $last;
73                         push @out, "QTH          : $qth" if $qth;
74                         push @out, "Location     : $latlong ($qra)" if $latlong || $qra ;
75                         push @out, sprintf("Heading      : %.0f Deg %.0f Mi. %.0f Km.", $bearing, $miles, $dx) if $latlong;
76                         push @out, "Home Node    : $homenode" if $homenode;
77                 } else {
78                         push @out, $self->msg('usernf', $call);
79                 }
80         }
81 }
82
83 return (1, @out);