Showing 1 changed files with 14 additions and 21 deletions
+14 -21
Nasal/softkeys.nas
... ...
@@ -548,29 +548,22 @@ var softkeysClass = {
548 548
                     else {
549 549
                         results = findNavaidsWithinRange(100, type);
550 550
                     }
551
-                    if (where != 'OMNI') {
552
-                        var norm_360 = func (a) return math.periodic(0, 360, a);
553
-                        if    (where == 'FRONT') var side = norm_360(data.hdg);
554
-                        elsif (where == 'RIGHT') var side = norm_360(data.hdg + 90);
555
-                        elsif (where == 'LEFT')  var side = norm_360(data.hdg - 90);
556
-                        elsif (where == 'REAR')  var side = norm_360(data.hdg + 180);
557
-                        foreach (var n; results) {
558
-                            var (course, dist) = courseAndDistance(n);
551
+                    var norm_360 = func (a) return math.periodic(0, 360, a);
552
+                    if    (where == 'OMNI')  var side = -1;
553
+                    elsif (where == 'FRONT') var side = norm_360(data.hdg);
554
+                    elsif (where == 'RIGHT') var side = norm_360(data.hdg + 90);
555
+                    elsif (where == 'LEFT')  var side = norm_360(data.hdg - 90);
556
+                    elsif (where == 'REAR')  var side = norm_360(data.hdg + 180);
557
+                    foreach (var n; results) {
558
+                        var (course, dist) = courseAndDistance(n);
559
+                        if (side > -1) {
559 560
                             var angle = 180 - abs(abs(course - side) - 180);
560
-                            if (angle < 50) {
561
-                                append(list, [n, course, dist]);
562
-                                if (size(list) == 5)
563
-                                    break;
564
-                            }
565
-                        }
566
-                    }
567
-                    else {
568
-                        foreach (var n; results) {
569
-                            var (course, dist) = courseAndDistance(n);
570
-                            append(list, [n, course, dist]);
571
-                            if (size(list) == 5)
572
-                                break;
561
+                            if (angle > 50)
562
+                                continue;
573 563
                         }
564
+                        append(list, [n, course, dist]);
565
+                        if (size(list) == 5)
566
+                            break;
574 567
                     }
575 568
                     var obj_infos = [
576 569
                         { text: sprintf('NEAREST %s (%s)', string.uc(type), where), type: 'title' },