From e5fde70ca6ca0ea1ef0b02549169192244746224 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 6 Mar 2026 16:08:49 +0000 Subject: [PATCH 1/2] Prevent populating unitialized distance-buckets --- application/models/Distances_model.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/models/Distances_model.php b/application/models/Distances_model.php index f02375b01..0c02ed85e 100644 --- a/application/models/Distances_model.php +++ b/application/models/Distances_model.php @@ -172,7 +172,15 @@ class Distances_model extends CI_Model echo json_encode(array('Error' => 'Error. There is a problem with the gridsquare ('.$stationgrid.') set in your profile!')); exit; } else { - // Making the array we will use for plotting, we save occurrences of the length of each qso in the array + // Build the chart buckets in 50-unit steps up to the max chart distance ($dist). + // Each bucket covers a 50-unit range, e.g. in km mode: + // $dataarray[0] => "0km - 50km" + // $dataarray[1] => "50km - 100km" + // ... + // $dataarray[399] => "19950km - 20000km" (last valid index, since 20000/50 - 1 = 399) + // A QSO at 31,450 km would map to bucket index 629 (31450/50 = 629), + // which is never initialized here, causing "Undefined array key 629" warnings. + // The isset() guard further below skips any QSO whose distance exceeds this range. $j = 0; for ($i = 0; $j < $dist; $i++) { $dataarray[$i]['dist'] = $j . $unit . ' - ' . ($j + 50) . $unit; @@ -205,6 +213,9 @@ class Distances_model extends CI_Model $qrb['Callsign'] = $qso['callsign']; $qrb['Grid'] = $qso['grid']; } + if (!isset($dataarray[$arrayplacement])) { // QSO distance exceeds chart range, skip plotting + continue; + } $dataarray[$arrayplacement]['count']++; // Used for counting total qsos plotted if ($dataarray[$arrayplacement]['callcount'] < 5) { // Used for tooltip in graph, set limit to 5 calls shown if ($dataarray[$arrayplacement]['callcount'] > 0) { From 46cdcaaab65ed79e045fe20cef2833789bd37ad6 Mon Sep 17 00:00:00 2001 From: "Joerg (DJ7NT)" Date: Fri, 6 Mar 2026 17:48:14 +0100 Subject: [PATCH 2/2] Update max distance values for measurement buckets Longpath is valid. --- application/models/Distances_model.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/application/models/Distances_model.php b/application/models/Distances_model.php index 0c02ed85e..8c6b12e3f 100644 --- a/application/models/Distances_model.php +++ b/application/models/Distances_model.php @@ -152,19 +152,19 @@ class Distances_model extends CI_Model switch ($measurement_base) { case 'M': $unit = "mi"; - $dist = '13000'; + $dist = '26000'; break; case 'K': $unit = "km"; - $dist = '20000'; + $dist = '40050'; break; case 'N': $unit = "nmi"; - $dist = '11000'; + $dist = '22000'; break; default: $unit = "km"; - $dist = '20000'; + $dist = '40050'; } if (!$this->valid_locator($stationgrid)) { @@ -177,10 +177,7 @@ class Distances_model extends CI_Model // $dataarray[0] => "0km - 50km" // $dataarray[1] => "50km - 100km" // ... - // $dataarray[399] => "19950km - 20000km" (last valid index, since 20000/50 - 1 = 399) - // A QSO at 31,450 km would map to bucket index 629 (31450/50 = 629), - // which is never initialized here, causing "Undefined array key 629" warnings. - // The isset() guard further below skips any QSO whose distance exceeds this range. + // till 40050 (longpath) $j = 0; for ($i = 0; $j < $dist; $i++) { $dataarray[$i]['dist'] = $j . $unit . ' - ' . ($j + 50) . $unit;