25db6ba609259c4c3f2f803f4edfe7decd4ca4a4
[spider.git] / cmd / set / location.pl
1 #
2 # set the latitude and longtitude field
3 #
4 # Copyright (c) 1998 - Dirk Koopman
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my $call = $self->call;
11 my $user;
12
13 # remove leading and trailing spaces
14 $line =~ s/^\s+//;
15 $line =~ s/\s+$//;
16
17 return (1, $self->msg('loce1')) if !$line;
18 return (1, $self->msg('loce3', uc $line)) if DXBearing::is_qra($line);
19 return (1, $self->msg('loce2', $line)) unless $line =~ /\d+ \d+ [NnSs] \d+ \d+ [EeWw]/o;
20
21 $user = DXUser->get_current($call);
22 if ($user) {
23         $line = uc $line;
24         my ($lat, $long) = DXBearing::stoll($line);
25         $user->lat($lat);
26         $user->long($long);
27         my $s = DXProt::pc41($call, 3, $line);
28         DXProt::eph_dup($s);
29         DXProt::broadcast_all_ak1a($s, $DXProt::me) ;
30         unless ($user->qra && DXBearing::is_qra($user->qra) ) {
31                 my $qra = DXBearing::lltoqra($lat, $long);
32                 $user->qra($qra);
33         }
34         
35         $user->put();
36         return (1, $self->msg('loc', $line));
37 } else {
38         return (1, $self->msg('namee2', $call));
39 }