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 ($line =~ /^\d+\s+\d+\s*[NS]\s+\d+\s+\d+\s*[EW]/) {
20 $line =~ s/(\d)([NSEW])/$1 $2/g;
21 my ($llat, $llong) = DXBearing::stoll(uc $line);
22 return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
25 # get the user's lat/long else the cluster's (and whinge about it)
26 my $lat = $self->user->lat;
27 my $long = $self->user->long;
28 if (!$long && !$lat) {
29 push @out, $self->msg('heade1');
30 $lat = $main::mylatitude;
31 $long = $main::mylongitude;
34 unshift @list, $self->user->qra if @list == 1 && $self->user->qra;
35 unshift @list, DXBearing::lltoqra($lat, $long) unless @list > 1;
39 $f .= 'MM' if $f =~ /^[A-Z][A-Z]\d\d$/;
40 return (1, $self->msg('qrae2', $f)) unless DXBearing::is_qra($f);
41 ($lat, $long) = DXBearing::qratoll($f);
45 $l .= 'MM' if $l =~ /^[A-Z][A-Z]\d\d$/;
46 return (1, $self->msg('qrae2', $l)) unless DXBearing::is_qra($l);
47 my ($qlat, $qlong) = DXBearing::qratoll($l);
49 # generate alpha lat/long
50 my $fll = DXBearing::lltos($lat, $long);
51 $fll =~ s/\s+([NSEW])/$1/g;
52 my $tll = DXBearing::lltos($qlat, $qlong);
53 $tll =~ s/\s+([NSEW])/$1/g;
55 # calc bearings and distances
56 my ($b, $dx) = DXBearing::bdist($lat, $long, $qlat, $qlong);
57 my ($r, $rdx) = DXBearing::bdist($qlat, $qlong, $lat, $long);
60 $to = "->\U$list[1]($tll)" if $f;
61 my $from = "\U$list[0]($fll)" ;
63 push @out, sprintf "$from$to To: %.0f Fr: %.0f Dst: %.0fMi %.0fKm", $b, $r, $dx * 0.62133785, $dx;