From 94f3ebf53d852268666d532f6b0322b94887fc31 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 26 Feb 2024 15:10:32 +0000 Subject: [PATCH] [Clublog] Remap Sat names to conform with LoTW names This addresses issue where Clublog uses the SAT_NAMES from LOTW rather than the real names/oscar numbers. It also adds a parameter to the AdifHelper library to accept satellite_remap to rename them --- application/libraries/AdifHelper.php | 56 +++++++++++++++++++++++-- application/views/adif/data/clublog.php | 2 +- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/application/libraries/AdifHelper.php b/application/libraries/AdifHelper.php index 9b0472f8..22a9d02c 100644 --- a/application/libraries/AdifHelper.php +++ b/application/libraries/AdifHelper.php @@ -2,7 +2,14 @@ class AdifHelper { - public function getAdifLine($qso) { + /** + * Generates an ADIF line for a QSO record. + * + * @param object $qso The QSO record. + * @param bool $satellite_remap Flag indicating whether to remap satellite names. + * @return string The ADIF line. + */ + public function getAdifLine($qso, $satellite_remap = false) { $normalFields = array( 'ADDRESS', 'AGE', @@ -80,7 +87,6 @@ class AdifHelper { 'RST_SENT', 'RX_PWR', 'SAT_MODE', - 'SAT_NAME', 'SFI', 'SILENT_KEY', 'SKCC', @@ -183,11 +189,23 @@ class AdifHelper { $line .= $this->getAdifFieldLine("MY_GRIDSQUARE", $qso->station_gridsquare); } + if($qso->COL_SAT_NAME) { + if($satellite_remap === true) { + $satname = $this->lotw_satellite_map($qso->COL_SAT_NAME); + if($satname) { + $line .= $this->getAdifFieldLine("SAT_NAME", $satname); + } else { + $line .= $this->getAdifFieldLine("SAT_NAME", $qso->COL_SAT_NAME); + } + } else { + $line .= $this->getAdifFieldLine("SAT_NAME", $qso->COL_SAT_NAME); + } + } + $line .= $this->getAdifFieldLine("MY_IOTA", $qso->station_iota); $line .= $this->getAdifFieldLine("MY_SOTA_REF", $qso->station_sota); - $line .= $this->getAdifFieldLine("MY_POTA_REF", $qso->station_pota); $line .= $this->getAdifFieldLine("MY_CQ_ZONE", $qso->station_cq); @@ -258,4 +276,36 @@ class AdifHelper { return ""; } } + + /* + | Function: lotw_satellite_map + | Requires: OSCAR Satellite name $satname + | + | Outputs if LoTW uses a different satellite name + | + */ + function lotw_satellite_map($satname) { + $arr = array( + "ARISS" => "ISS", + "UKUBE1" => "UKUBE-1", + "KEDR" => "ARISSAT-1", + "TO-108" => "CAS-6", + "TAURUS" => "TAURUS-1", + "AISAT1" => "AISAT-1", + 'UVSQ' => "UVSQ-SAT", + 'CAS-3H' => "LILACSAT-2", + 'IO-117' => "GREENCUBE", + "TEVEL1" => "TEVEL-1", + "TEVEL2" => "TEVEL-2", + "TEVEL3" => "TEVEL-3", + "TEVEL4" => "TEVEL-4", + "TEVEL5" => "TEVEL-5", + "TEVEL6" => "TEVEL-6", + "TEVEL7" => "TEVEL-7", + "TEVEL8" => "TEVEL-8", + "INSPR7" => "INSPIRE-SAT 7", + ); + + return array_search(strtoupper($satname),$arr,true); + } } diff --git a/application/views/adif/data/clublog.php b/application/views/adif/data/clublog.php index 3e44ae4f..b4b07d09 100644 --- a/application/views/adif/data/clublog.php +++ b/application/views/adif/data/clublog.php @@ -9,5 +9,5 @@ $CI =& get_instance(); $CI->load->library('AdifHelper'); foreach ($qsos->result() as $qso) { - echo $CI->adifhelper->getAdifLine($qso); + echo $CI->adifhelper->getAdifLine($qso, $satellite_remap = true); }