return (1, $self->msg('qrashe1')) unless @list > 0;
my @out;
-my $fll;
-my $tll;
+
+# every thing is dealt with in upper case
+$line = uc $line;
+
+# convert a lat/long into a qra locator if we see a pattern looking like a lat/long
+if ($line =~ /^\d+\s+\d+\s*[NS]\s+\d+\s+\d+\s*[EW]/) {
+ $line =~ s/(\d)([NSEW])/$1 $2/g;
+ my ($llat, $llong) = DXBearing::stoll(uc $line);
+ return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
+}
+
+# get the user's lat/long else the cluster's (and whinge about it)
my $lat = $self->user->lat;
my $long = $self->user->long;
if (!$long && !$lat) {
$long = $main::mylongitude;
}
-my $fqra = DXBearing::is_qra($list[0]);
-my $sqra = $list[0] =~ /^[A-Za-z][A-Za-z]\d\d$/;
-my $ll = $line =~ /^\d+\s+\d+\s+[NSns]\s+\d+\s+\d+\s+[EWew]/;
-return (1, $self->msg('qrae2', $list[0])) unless $fqra || $sqra || $ll;
-
-# convert a lat/long into a qra locator
-if ($ll) {
- my ($llat, $llong) = DXBearing::stoll($line);
- return (1, "QRA $line = " . DXBearing::lltoqra($llat, $llong));
-}
-
unshift @list, $self->user->qra if @list == 1 && $self->user->qra;
unshift @list, DXBearing::lltoqra($lat, $long) unless @list > 1;
+# check from qra
my $f = uc $list[0];
$f .= 'MM' if $f =~ /^[A-Z][A-Z]\d\d$/;
+return (1, $self->msg('qrae2', $f)) unless DXBearing::is_qra($f);
($lat, $long) = DXBearing::qratoll($f);
-return (1, $self->msg('qrae2', $list[1])) unless (DXBearing::is_qra($list[1]) || $list[1] =~ /^[A-Za-z][A-Za-z]\d\d$/);
+# check to qra
my $l = uc $list[1];
-
-$fll = DXBearing::lltos($lat, $long);
+$l .= 'MM' if $l =~ /^[A-Z][A-Z]\d\d$/;
+return (1, $self->msg('qrae2', $l)) unless DXBearing::is_qra($l);
my ($qlat, $qlong) = DXBearing::qratoll($l);
-$tll = DXBearing::lltos($qlat, $qlong);
-$tll =~ s/\s+([NSEW])/$1/g;
+# generate alpha lat/long
+my $fll = DXBearing::lltos($lat, $long);
$fll =~ s/\s+([NSEW])/$1/g;
+my $tll = DXBearing::lltos($qlat, $qlong);
+$tll =~ s/\s+([NSEW])/$1/g;
+# calc bearings and distances
my ($b, $dx) = DXBearing::bdist($lat, $long, $qlat, $qlong);
my ($r, $rdx) = DXBearing::bdist($qlat, $qlong, $lat, $long);
my $to = '';
push @out, sprintf "$from$to To: %.0f Fr: %.0f Dst: %.0fMi %.0fKm", $b, $r, $dx * 0.62133785, $dx;
return (1, @out);
+