2 # show the distance and bearing to a QRA locator
4 # you can enter two qra locators and it will calc the distance between them
9 my ($self, $line) = @_;
10 my @list = split /\s+/, $line; # generate a list of callsigns
15 my $lat = $self->user->lat;
16 my $long = $self->user->long;
17 if (!$long && !$lat) {
18 push @out, $self->msg('heade1');
19 $lat = $main::mylatitude;
20 $long = $main::mylongitude;
23 my $fqra = DXBearing::is_qra($list[0]);
24 my $sqra = $list[0] =~ /^[A-Za-z][A-Za-z]\d\d$/;
25 my $ll = $line =~ /^\d+\s+\d+\s*[NSns]\s+\d+\s+\d+\s*[EWew]/;
26 return (1, $self->msg('qrashe1')) unless @list > 0;
27 return (1, $self->msg('qrae2', $list[0])) unless $fqra || $sqra || $ll;
30 my ($llat, $llong) = DXBearing::stoll($line);
31 return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
34 #print "$lat $long\n";
41 $f .= 'MM' if $f =~ /^[A-Z][A-Z]\d\d$/;
42 ($lat, $long) = DXBearing::qratoll($f);
43 $fll = DXBearing::lltos($lat, $long);
44 #print "$lat $long\n";
46 return (1, $self->msg('qrae2', $list[1])) unless (DXBearing::is_qra($list[1]) || $list[1] =~ /^[A-Za-z][A-Za-z]\d\d$/);
50 $l .= 'MM' if $l =~ /^[A-Z][A-Z]\d\d$/;
52 my ($qlat, $qlong) = DXBearing::qratoll($l);
53 #print "$qlat $qlong\n";
54 $fll = DXBearing::lltos($lat, $long);
55 $fll =~ s/\s+([NSEW])/$1/g;
56 $tll = DXBearing::lltos($qlat, $qlong);
57 $tll =~ s/\s+([NSEW])/$1/g;
59 my ($b, $dx) = DXBearing::bdist($lat, $long, $qlat, $qlong);
60 my ($r, $rdx) = DXBearing::bdist($qlat, $qlong, $lat, $long);
63 $to = "->\U$list[1]($tll)" if $f;
64 my $from = "\U$list[0]($fll)" ;
66 push @out, sprintf "$from$to To: %.0f Fr: %.0f Dst: %.0fMi %.0fKm", $b, $r, $dx * 0.62133785, $dx;