From eb301296b8a837d2b87fc236b07e25b2cfea3935 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 13 Dec 2023 00:38:37 +0100 Subject: [PATCH 1/5] Allow grids up to 10 chars --- application/libraries/Qra.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index 48532f1a..4ffcf53b 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -215,16 +215,17 @@ function qra2latlong($strQRA) { } } - if ((strlen($strQRA) % 2 == 0) && (strlen($strQRA) <= 8)) { // Check if QRA is EVEN (the % 2 does that) and smaller/equal 8 + if ((strlen($strQRA) % 2 == 0) && (strlen($strQRA) <= 10)) { // Check if QRA is EVEN (the % 2 does that) and smaller/equal 8 $strQRA = strtoupper($strQRA); if (strlen($strQRA) == 4) $strQRA .= "MM"; // Only 4 Chars? Fill with center "MM" if (strlen($strQRA) == 6) $strQRA .= "55"; // Only 6 Chars? Fill with center "55" + if (strlen($strQRA) == 8) $strQRA .= "MM"; // Only 6 Chars? Fill with center "MM" - if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}$/', $strQRA)) { + if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$/', $strQRA)) { return false; } - list($a, $b, $c, $d, $e, $f, $g, $h) = str_split($strQRA, 1); // Maidenhead is always alternating. e.g. "AA00AA00AA00" - doesn't matter how deep. 2 chars, 2 numbers, etc. + list($a, $b, $c, $d, $e, $f, $g, $h, $i, $j) = str_split($strQRA, 1); // Maidenhead is always alternating. e.g. "AA00AA00AA00" - doesn't matter how deep. 2 chars, 2 numbers, etc. $a = ord($a) - ord('A'); $b = ord($b) - ord('A'); $c = ord($c) - ord('0'); @@ -233,6 +234,8 @@ function qra2latlong($strQRA) { $f = ord($f) - ord('A'); $g = ord($g) - ord('0'); $h = ord($h) - ord('0'); + $i = ord($i) - ord('A'); + $j = ord($j) - ord('A'); $nLong = ($a*20) + ($c*2) + (($e+0.5)/12) + (($g-5)/120) - 180; // the 4th pair is "in the middle", so we've to substract 5 $nLat = ($b*10) + $d + (($f+0.5)/24) + (($h-5)/240) - 90; From 235611cfd885340fd4e3e67d8706e7a8f43301bd Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 13 Dec 2023 01:18:35 +0100 Subject: [PATCH 2/5] Consider up to 10 digits for qra2latlon calcs --- application/libraries/Qra.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index 4ffcf53b..40fc8562 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -217,9 +217,9 @@ function qra2latlong($strQRA) { if ((strlen($strQRA) % 2 == 0) && (strlen($strQRA) <= 10)) { // Check if QRA is EVEN (the % 2 does that) and smaller/equal 8 $strQRA = strtoupper($strQRA); - if (strlen($strQRA) == 4) $strQRA .= "MM"; // Only 4 Chars? Fill with center "MM" + if (strlen($strQRA) == 4) $strQRA .= "LL"; // Only 4 Chars? Fill with center "LL" as only A-R allowed if (strlen($strQRA) == 6) $strQRA .= "55"; // Only 6 Chars? Fill with center "55" - if (strlen($strQRA) == 8) $strQRA .= "MM"; // Only 6 Chars? Fill with center "MM" + if (strlen($strQRA) == 8) $strQRA .= "LL"; // Only 8 Chars? Fill with center "LL" as only A-R allowed if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$/', $strQRA)) { return false; @@ -237,8 +237,8 @@ function qra2latlong($strQRA) { $i = ord($i) - ord('A'); $j = ord($j) - ord('A'); - $nLong = ($a*20) + ($c*2) + (($e+0.5)/12) + (($g-5)/120) - 180; // the 4th pair is "in the middle", so we've to substract 5 - $nLat = ($b*10) + $d + (($f+0.5)/24) + (($h-5)/240) - 90; + $nLong = ($a*20) + ($c*2) + ($e/12) + ($g/120) + ($i/2880) - 180; + $nLat = ($b*10) + $d + ($f/24) + ($h/240) + ($j/5760) - 90; $arLatLong = array($nLat, $nLong); return $arLatLong; From 74d37b1e220af9f7527a4aa3e2f95bbe2ef76b6f Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 13 Dec 2023 07:13:55 +0100 Subject: [PATCH 3/5] Allow 10-digit grid in QSO input --- application/controllers/Qso.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index b0d9f07f..a78840bc 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -597,7 +597,7 @@ class QSO extends CI_Controller { // Allow empty locator if (preg_match('/^$/', $grid)) return true; // Allow 6-digit locator - if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}$/', $grid)) return true; + if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Xa-x]{2}$/', $grid)) return true; // Allow 4-digit locator else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true; // Allow 4-digit grid line @@ -607,7 +607,9 @@ class QSO extends CI_Controller { // Allow 2-digit locator else if (preg_match('/^[A-Ra-r]{2}$/', $grid)) return true; // Allow 8-digit locator - else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}[0-9]{2}$/', $grid)) return true; + else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Xa-x]{2}[0-9]{2}$/', $grid)) return true; + // Allow 10-digit locator + else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Xa-x]{2}[0-9]{2}[A-Xa-x]{2}$/', $grid)) return true; else { $this->form_validation->set_message('check_locator', 'Please check value for grid locator ('.strtoupper($grid).').'); return false; From 77cabef52a1427dba08ee38755523d5074a2ac7c Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 13 Dec 2023 08:10:13 +0100 Subject: [PATCH 4/5] We do not need to load Qra lib again --- application/views/view_log/qso.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 3b6f1c9e..2e38cfe4 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -128,9 +128,7 @@ load->library('qra'); // Cacluate Distance $distance = $CI->qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, $measurement_base); From 82ec9845c3ea037efab3c9b643af7d76f1b036ee Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 13 Dec 2023 08:12:57 +0100 Subject: [PATCH 5/5] Loading of CI not needed --- application/views/view_log/qso.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 2e38cfe4..4485334f 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -128,10 +128,8 @@ qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, $measurement_base); + $distance = $this->qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, $measurement_base); switch ($measurement_base) { case 'M':