1. Do some range checking for spots and WWV in the future (got a WWV for Oct
[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('loce2', $line)) unless $line =~ /\d+ \d+ [NnSs] \d+ \d+ [EeWw]/o;
19
20 $user = DXUser->get_current($call);
21 if ($user) {
22         $line = uc $line;
23         my ($lat, $long) = DXBearing::stoll($line);
24         $user->lat($lat);
25         $user->long($long);
26         DXProt::broadcast_ak1a(DXProt::pc41($call, 3, $line), $DXProt::me);
27         if (!$user->qra) {
28                 my $qra = DXBearing::lltos($lat, $long);
29                 $user->qra($qra);
30         }
31         
32         $user->put();
33         return (1, $self->msg('loc', $line));
34 } else {
35         return (1, $self->msg('namee2', $call));
36 }