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;
15 # every thing is dealt with in upper case
18 # convert a lat/long into a qra locator if we see a pattern looking like a lat/long
19 if (is_latlong($line)) {
20 my ($llat, $llong) = DXBearing::stoll(uc $line);
21 return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
24 # get the user's lat/long else the cluster's (and whinge about it)
25 my $lat = $self->user->lat;
26 my $long = $self->user->long;
27 if (!$long && !$lat) {
28 push @out, $self->msg('heade1');
29 $lat = $main::mylatitude;
30 $long = $main::mylongitude;
33 unshift @list, $self->user->qra if @list == 1 && $self->user->qra;
34 unshift @list, DXBearing::lltoqra($lat, $long) unless @list > 1;
38 $f .= 'MM' if $f =~ /^[A-Z][A-Z]\d\d$/;
39 return (1, $self->msg('qrae2', $f)) unless is_qra($f);
40 ($lat, $long) = DXBearing::qratoll($f);
44 $l .= 'MM' if $l =~ /^[A-Z][A-Z]\d\d$/;
45 return (1, $self->msg('qrae2', $l)) unless is_qra($l);
46 my ($qlat, $qlong) = DXBearing::qratoll($l);
48 # generate alpha lat/long
49 my $fll = DXBearing::lltos($lat, $long);
50 $fll =~ s/\s+([NSEW])/$1/g;
51 my $tll = DXBearing::lltos($qlat, $qlong);
52 $tll =~ s/\s+([NSEW])/$1/g;
54 # calc bearings and distances
55 my ($b, $dx) = DXBearing::bdist($lat, $long, $qlat, $qlong);
56 my ($r, $rdx) = DXBearing::bdist($qlat, $qlong, $lat, $long);
59 $to = "->\U$list[1]($tll)" if $f;
60 my $from = "\U$list[0]($fll)" ;
62 push @out, sprintf "$from$to To: %.0f Fr: %.0f Dst: %.0fMi %.0fKm", $b, $r, $dx * 0.62133785, $dx;