]> gb7djk.dxcluster.net Git - spider.git/blob - cmd/show/station.pl
make DXUser use JSON::XS and Sqlite
[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 <= 2 && uc $f[0] eq 'ALL') {
17         return (1, $self->msg('e6')) if $self->remotecmd && $self->priv < 6; 
18         return (1, $self->msg('e6')) if $self->priv < 5; 
19         shift @f;
20         my $exp = shellregex(uc shift @f) if @f; 
21         my @calls;
22         if ($exp) {
23                 @calls = grep {m{$exp}} DXUser::get_all_calls();
24     } else {
25                 @calls = DXUser::get_all_calls();
26         }
27         
28         foreach $call (@calls) {
29                 my $ref = DXUser::get_current($call);
30                 next if !$ref;
31                 my $lat = $ref->lat;
32                 my $long = $ref->long;
33                 my $sort = $ref->sort || "";
34                 my $name = $ref->name || "";
35                 my $qth = $ref->qth || "";
36                 my $homenode = $ref->homenode || "";
37                 my $qra = $ref->qra || "";
38                 my $latlong = DXBearing::lltos($lat, $long) if $lat && $long;
39                 $latlong = "" unless $latlong;
40                 
41                 push @out, sprintf "%-9s %s %-12.12s %-27.27s %-9s %s %s", $call, $sort, $name, $qth, $homenode, $latlong, $qra;
42         }
43 } else {
44         foreach $call (@f) {
45                 my $ref = DXUser::get_current($call);
46                 if ($ref) {
47                         my $name = $ref->name;  
48                         my $qth = $ref->qth;
49                         my $lat = $ref->lat;
50                         my $long = $ref->long;
51                         my $node = $ref->node;
52                         my $homenode = $ref->homenode;
53                         my $lastin = $ref->lastin;
54                         my $latlong = DXBearing::lltos($lat, $long) if $lat || $long;
55                         my $last = DXUtil::cldatetime($lastin) if $ref->lastin;
56                         my $qra = $ref->qra;
57                         $qra = DXBearing::lltoqra($lat, $long) if !$qra && ($lat || $long);
58                         my $from;
59                         my ($dx, $bearing, $miles);
60                         if ($latlong) {
61                                 my ($hlat, $hlong) = ($self->user->lat, $self->user->long);
62                                 ($hlat, $hlong) = DXBearing::qratoll($self->user->qra) if $self->user->qra && !$hlat && !$hlong;
63                                 if (!$hlat && !$hlong) {
64                                         $from = "From $main::mycall";
65                                         $hlat = $main::mylatitude;
66                                         $hlong = $main::mylongitude;
67                                 }
68                                 ($bearing, $dx) = DXBearing::bdist($hlat, $hlong, $lat, $long);
69                                 $miles = $dx * 0.62133785;
70                         }
71                         
72                         my $cref = Route::get($call);
73                         my $seek = $cref->isa('Route::Node') ? $call : join(',', $cref->parents) if $cref;
74
75                         if ($seek) {
76                                 push @out, sprintf("%-13s: %s (%s %s)", $self->msg('user'), $call, $self->msg('at'), $seek);
77                         } else {
78                                 push @out, sprintf("%-13s: %s", $self->msg('user'), $call);
79                         }
80                         push @out, sprintf("%-13s: %s", $self->msg('name1'), $name) if $name;
81                         push @out, sprintf("%-13s: %s", $self->msg('lastconn'), $last) if $last;
82                         push @out, sprintf("%-13s: %s", 'QTH', $qth) if $qth;
83                         push @out, sprintf("%-13s: %s", $self->msg('location'), "$latlong ($qra)") if $latlong || $qra ;
84                         push @out, sprintf("%-13s: %.0f Deg. %.0f Mi. %.0f Km.", $self->msg('heading'), $bearing, $miles, $dx) if $latlong;
85                         push @out, sprintf("%-13s: %s", $self->msg('homenode2'), $homenode) if $homenode;
86                 } else {
87                         push @out, $self->msg('usernf', $call);
88                 }
89         }
90 }
91
92 return (1, @out);