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
11 return (1, $self->msg('qrashe1')) unless @list > 0;
16 my $lat = $self->user->lat;
17 my $long = $self->user->long;
18 if (!$long && !$lat) {
19 push @out, $self->msg('heade1');
20 $lat = $main::mylatitude;
21 $long = $main::mylongitude;
24 my $fqra = DXBearing::is_qra($list[0]);
25 my $sqra = $list[0] =~ /^[A-Za-z][A-Za-z]\d\d$/;
26 my $ll = $line =~ /^\d+\s+\d+\s*[NSns]\s+\d+\s+\d+\s*[EWew]/;
27 return (1, $self->msg('qrae2', $list[0])) unless $fqra || $sqra || $ll;
29 # convert a lat/long into a qra locator
31 my ($llat, $llong) = DXBearing::stoll($line);
32 return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
35 unshift @list, $self->user->qra if @list == 1 && $self->user->qra;
36 unshift @list, DXBearing::lltoqra($lat, $long) unless @list > 1;
39 $f .= 'MM' if $f =~ /^[A-Z][A-Z]\d\d$/;
40 ($lat, $long) = DXBearing::qratoll($f);
41 return (1, $self->msg('qrae2', $list[1])) unless (DXBearing::is_qra($list[1]) || $list[1] =~ /^[A-Za-z][A-Za-z]\d\d$/);
45 $fll = DXBearing::lltos($lat, $long);
46 my ($qlat, $qlong) = DXBearing::qratoll($l);
47 $tll = DXBearing::lltos($qlat, $qlong);
49 $tll =~ s/\s+([NSEW])/$1/g;
50 $fll =~ s/\s+([NSEW])/$1/g;
52 my ($b, $dx) = DXBearing::bdist($lat, $long, $qlat, $qlong);
53 my ($r, $rdx) = DXBearing::bdist($qlat, $qlong, $lat, $long);
56 $to = "->\U$list[1]($tll)" if $f;
57 my $from = "\U$list[0]($fll)" ;
59 push @out, sprintf "$from$to To: %.0f Fr: %.0f Dst: %.0fMi %.0fKm", $b, $r, $dx * 0.62133785, $dx;