From 68754a82b1456d2d2a4da79ca33ec7cac2241831 Mon Sep 17 00:00:00 2001 From: Eric Codes Date: Wed, 30 Oct 2024 20:15:03 -0400 Subject: [PATCH] Add support for POTA hunters POTA references in non-POTA logs are supported by the canonical FLE app. This patch enables that functionality in FLEcli Branch: support-pota-hunters --- fleprocess/adif_write.go | 16 ++++---- fleprocess/adif_write_test.go | 24 +++++++++++ fleprocess/braketedData.go | 2 +- test/bats-scripts/test.bats | 8 +++- test/data/sample_pota_hunter.txt | 51 ++++++++++++++++++++++++ test/docker-FLEcli.sh | 2 +- test/output/POTA/sample_pota_hunter.adif | 22 ++++++++++ 7 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 test/data/sample_pota_hunter.txt create mode 100644 test/output/POTA/sample_pota_hunter.adif diff --git a/fleprocess/adif_write.go b/fleprocess/adif_write.go index 1274759..8a48838 100644 --- a/fleprocess/adif_write.go +++ b/fleprocess/adif_write.go @@ -53,15 +53,15 @@ func buildAdif(fullLog []LogLine, adifParams AdifParams) (adifList []string) { } adifLine.WriteString(adifElement("RST_SENT", logLine.RSTsent)) adifLine.WriteString(adifElement("RST_RCVD", logLine.RSTrcvd)) + if logLine.GridLoc != "" { + adifLine.WriteString(adifElement("GRIDSQUARE", logLine.GridLoc)) + } if logLine.Comment != "" { adifLine.WriteString(adifElement("COMMENT", logLine.Comment)) } if logLine.OMname != "" { adifLine.WriteString(adifElement("NAME", logLine.OMname)) } - if logLine.GridLoc != "" { - adifLine.WriteString(adifElement("GRIDSQUARE", logLine.GridLoc)) - } if logLine.QSLmsg != "" { adifLine.WriteString(adifElement("QSLMSG", logLine.QSLmsg)) } @@ -76,11 +76,13 @@ func buildAdif(fullLog []LogLine, adifParams AdifParams) (adifList []string) { if adifParams.IsPOTA { adifLine.WriteString(adifElement("MY_SIG", "POTA")) adifLine.WriteString(adifElement("MY_SIG_INFO", logLine.MyPOTA)) - if logLine.POTA != "" { - adifLine.WriteString(adifElement("SIG", "POTA")) - adifLine.WriteString(adifElement("SIG_INFO", logLine.POTA)) - } } + + if logLine.POTA != "" { + adifLine.WriteString(adifElement("SIG", "POTA")) + adifLine.WriteString(adifElement("SIG_INFO", logLine.POTA)) + } + if adifParams.IsSOTA { adifLine.WriteString(adifElement("MY_SOTA_REF", logLine.MySOTA)) if logLine.SOTA != "" { diff --git a/fleprocess/adif_write_test.go b/fleprocess/adif_write_test.go index 782cc47..9e20701 100644 --- a/fleprocess/adif_write_test.go +++ b/fleprocess/adif_write_test.go @@ -124,6 +124,22 @@ func Test_buildAdif(t *testing.T) { "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 POTA ON-00259 POTA DL-00001 ON4KJM JO40eu 15.1234567 -123.1234567 ", } + sampleFilledLogPOTAHunter := []LogLine{ + {MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", MyGrid: "JO40eu", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", GridLoc: "JO50", Operator: "ON4KJM", Nickname: "ON-00259-1"}, + {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", MyGrid: "JO40eu", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", Operator: "ON4KJM", POTA: "DL-00001"}, + {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", MyGrid: "JO40eu", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", Operator: "ON4KJM", POTA: "DL-00001", MyLat: "15.1234567", MyLon: "-123.1234567"}, + } + + expectedOutputPOTAHunter := []string{ + "ADIF Export for Fast Log Entry by DF3CB", + "FLE", + "3.1.0", + "", + "ON4KJM/P S57LC 20200524 1310 20m CW 14.045 599 599 JO50 ON4KJM JO40eu ON-00259-1 ", + "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 POTA DL-00001 ON4KJM JO40eu ", + "ON4KJM/P ON4LY 20200524 1312 20m CW 559 599 POTA DL-00001 ON4KJM JO40eu 15.1234567 -123.1234567 ", + } + type args struct { fullLog []LogLine adifParams AdifParams @@ -172,6 +188,14 @@ func Test_buildAdif(t *testing.T) { }, expectedOutputPOTA2, }, + { + "Happy case-POTA Hunter", + args{ + fullLog: sampleFilledLogPOTAHunter, + adifParams: AdifParams{IsPOTA: false}, + }, + expectedOutputPOTAHunter, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/fleprocess/braketedData.go b/fleprocess/braketedData.go index 01c4d11..fefc79d 100644 --- a/fleprocess/braketedData.go +++ b/fleprocess/braketedData.go @@ -59,5 +59,5 @@ func getBraketedData(inputLine string, braketType BraketType) (braketedData, cle braketedData = inputLine[posFirstAdjusted:posLast] cleanedLine = strings.Replace(inputLine, a+braketedData+b, "", 1) - return braketedData, cleanedLine + return strings.TrimSpace(braketedData), cleanedLine } diff --git a/test/bats-scripts/test.bats b/test/bats-scripts/test.bats index 305a79e..fcf3fa2 100644 --- a/test/bats-scripts/test.bats +++ b/test/bats-scripts/test.bats @@ -17,6 +17,12 @@ output=$(test/docker-FLEcli.sh load -i test/data/ON4KJM@ONFF-025920200524.txt) } +@test "Is the generated ADIF from a POTA hunter equivalent to the canonical one?" { + mkdir -p test/output/temp + output=$(test/docker-FLEcli.sh adif -o -i test/data/sample_pota_hunter.txt test/output/temp/sample_pota_hunter.adif) + diff test/output/temp/sample_pota_hunter.adif test/output/POTA/sample_pota_hunter.adif --strip-trailing-cr +} + @test "Is the generated SOTA csv equivalent to the canonical one?" { mkdir -p test/output/temp output=$(test/docker-FLEcli.sh csv -o -i test/FLE-sample/sota_wwff.txt test/output/temp/sota_wwff.csv) @@ -41,4 +47,4 @@ @test "Processing a big FLE file" { run test/docker-FLEcli.sh csv -o -i test/data/fle-6-bigFile.txt test/output/temp/fle-6-bigFile.csv -} \ No newline at end of file +} diff --git a/test/data/sample_pota_hunter.txt b/test/data/sample_pota_hunter.txt new file mode 100644 index 0000000..b36ef2a --- /dev/null +++ b/test/data/sample_pota_hunter.txt @@ -0,0 +1,51 @@ +# Header +mycall kc3yqi +mygrid FM19je + +2024-05-10 +20m SSB +0000 14.26 cu2yk 59 57 #HM77DT +2137 14.273 kc0qna pota us-2481 55 55 #EN24pk + +20m + +2024-06-05 14.317 SSB 0220 kp4pr @Jose #FK68xk +2024-06-05 14.270 SSB 0234 lz2vu @Juli #KN33gs + +SSB + +# 20m General is >= 14.225 <= 14.347 + +2024-06-07 +0448 14.250 dl5pia 57 59 @Petra < Mother of Pia > #JN48kn +0448 14.250 dl7pia 57 59 @Pia < Daughter of Petra > #JN48kn + +40m SSB + +7.266 SSB +2024-06-12 0045 kd4ge 57 57 @Darryl #EM93dk + +7.216 SSB +2024-06-12 0129 ko4nll 55 55 + +20m SSB + +2024-06-13 0301 14.225 r5aj 59 59 @Valery < Moscow, will upload to youtube > #KO95iu +2024-06-13 0225 14.280 lz2vu 59 59 < Bulgaria 1kW > @Juli #KN22dq + +40m SSB +2024-06-15 2257 7.225 k4oki 55 55 @Ryan US-6907 + +20m SSB +14.225 + +2024-06-18 2348 14.308 KI5YOO 57 57 US-0307 < D'Arbonne National Wildlife Refuge > #EM32vp @Mark +2024-06-18 2350 14.333 WI0O 57 57 US-11701 < Wood-Rill SNA State Sanctuary > #EN34fx @Sean +2024-06-18 2350 14.333 WI0O 57 57 US-9387 < Luce Line State Trail > #EN34gx @Sean +2024-06-19 0003 14.336 N4SAX 59 59 US-1873 < Fred Gannon Rocky Bayou State Park > #EM60sl @Randall #EM60sl + +40m SSB + +2024-06-19 0008 7.248 KD2ZWM 56 55 US-0064 < Shenandoah National Park > #FM08vv @Brady +2024-06-19 0012 7.267 KO4ZRX 55 57 US-1790 @Ronny < Trail of Tears State Park > #EM57gk +2024-06-19 0012 7.267 KO4ZRX 55 57 US-3791 @Ronny < Trail of Tears Trail > #EM57gk diff --git a/test/docker-FLEcli.sh b/test/docker-FLEcli.sh index d871d41..1e56d8a 100755 --- a/test/docker-FLEcli.sh +++ b/test/docker-FLEcli.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash CURRENT_UID=$(id -u):$(id -g) docker run --rm -t --user ${CURRENT_UID} -v "$(pwd)":/FLEcli_data on4kjm/flecli:latest "$@" diff --git a/test/output/POTA/sample_pota_hunter.adif b/test/output/POTA/sample_pota_hunter.adif new file mode 100644 index 0000000..06fa954 --- /dev/null +++ b/test/output/POTA/sample_pota_hunter.adif @@ -0,0 +1,22 @@ +ADIF Export for Fast Log Entry by DF3CB +FLE +3.1.0 + +KC3YQI CU2YK 20240510 0000 20m SSB 14.260 59 57 HM77dt FM19je +KC3YQI KC0QNA 20240510 2137 20m SSB 14.273 55 55 EN24pk POTA US-2481 FM19je +KC3YQI KP4PR 20240605 0220 20m SSB 14.317 59 59 FK68xk Jose FM19je +KC3YQI LZ2VU 20240605 0234 20m SSB 14.270 59 59 KN33gs Juli FM19je +KC3YQI DL5PIA 20240607 0448 20m SSB 14.250 57 59 JN48kn Mother of Pia Petra FM19je +KC3YQI DL7PIA 20240607 0448 20m SSB 14.250 57 59 JN48kn Daughter of Petra Pia FM19je +KC3YQI KD4GE 20240612 0045 40m SSB 7.266 57 57 EM93dk Darryl FM19je +KC3YQI KO4NLL 20240612 0129 40m SSB 7.216 55 55 FM19je +KC3YQI R5AJ 20240613 0301 20m SSB 14.225 59 59 KO95iu Moscow, will upload to youtube Valery FM19je +KC3YQI LZ2VU 20240613 0225 20m SSB 14.280 59 59 KN22dq Bulgaria 1kW Juli FM19je +KC3YQI K4OKI 20240615 2257 40m SSB 7.225 55 55 Ryan POTA US-6907 FM19je +KC3YQI KI5YOO 20240618 2348 20m SSB 14.308 57 57 EM32vp D'Arbonne National Wildlife Refuge Mark POTA US-0307 FM19je +KC3YQI WI0O 20240618 2350 20m SSB 14.333 57 57 EN34fx Wood-Rill SNA State Sanctuary Sean POTA US-11701 FM19je +KC3YQI WI0O 20240618 2350 20m SSB 14.333 57 57 EN34gx Luce Line State Trail Sean POTA US-9387 FM19je +KC3YQI N4SAX 20240619 0003 20m SSB 14.336 59 59 EM60sl Fred Gannon Rocky Bayou State Park Randall POTA US-1873 FM19je +KC3YQI KD2ZWM 20240619 0008 40m SSB 7.248 56 55 FM08vv Shenandoah National Park Brady POTA US-0064 FM19je +KC3YQI KO4ZRX 20240619 0012 40m SSB 7.267 55 57 EM57gk Trail of Tears State Park Ronny POTA US-1790 FM19je +KC3YQI KO4ZRX 20240619 0012 40m SSB 7.267 55 57 EM57gk Trail of Tears Trail Ronny POTA US-3791 FM19je