Add support for MY_CNTY adif tag. (#128)

* Add support for exporting MY_CNTY using mycounty in the header e.g. 'mycounty Ham County'.

* Add MyCounty to displayLog in the nice console summary.

---------

Co-authored-by: Jean-Marc MEESSEN <jean-marc@meessen-web.org>
pull/129/head
Nic Heath 6 months ago committed by GitHub
parent 170eb1b0da
commit 5b40643868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -93,6 +93,9 @@ func buildAdif(fullLog []LogLine, adifParams AdifParams) (adifList []string) {
if logLine.MyGrid != "" {
adifLine.WriteString(adifElement("MY_GRIDSQUARE", logLine.MyGrid))
}
if logLine.MyCounty != "" {
adifLine.WriteString(adifElement("MY_CNTY", logLine.MyCounty))
}
if logLine.Nickname != "" {
adifLine.WriteString(adifElement("APP_EQSL_QTH_NICKNAME", logLine.Nickname))
}

@ -96,7 +96,7 @@ func Test_buildAdif(t *testing.T) {
sampleFilledLogPOTA := []LogLine{
{MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM", Nickname: "ON-00259-1"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MyPOTA: "ON-00259", Operator: "ON4KJM", MyCounty: "Ham County"},
}
expectedOutputPOTA := []string{
@ -105,7 +105,7 @@ func Test_buildAdif(t *testing.T) {
"<ADIF_VER:5>3.1.0",
"<EOH>",
"<STATION_CALLSIGN:8>ON4KJM/P <CALL:5>S57LC <QSO_DATE:8>20200524 <TIME_ON:4>1310 <BAND:3>20m <MODE:2>CW <FREQ:6>14.045 <RST_SENT:3>599 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:8>ON-00259 <OPERATOR:6>ON4KJM <APP_EQSL_QTH_NICKNAME:10>ON-00259-1 <EOR>",
"<STATION_CALLSIGN:8>ON4KJM/P <CALL:5>ON4LY <QSO_DATE:8>20200524 <TIME_ON:4>1312 <BAND:3>20m <MODE:2>CW <RST_SENT:3>559 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:8>ON-00259 <OPERATOR:6>ON4KJM <EOR>",
"<STATION_CALLSIGN:8>ON4KJM/P <CALL:5>ON4LY <QSO_DATE:8>20200524 <TIME_ON:4>1312 <BAND:3>20m <MODE:2>CW <RST_SENT:3>559 <RST_RCVD:3>599 <MY_SIG:4>POTA <MY_SIG_INFO:8>ON-00259 <OPERATOR:6>ON4KJM <MY_CNTY:10>Ham County <EOR>",
}
sampleFilledLogPOTA2 := []LogLine{

@ -79,6 +79,10 @@ func SprintHeaderValues(logLine LogLine) string {
output.WriteString("MyGrid " + logLine.MyGrid + "\n")
}
if logLine.MyCounty != "" {
output.WriteString("MyCounty " + logLine.MyCounty + "\n")
}
return output.String()
}

@ -64,6 +64,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
regexpHeaderMySota := regexp.MustCompile(`(?i)^mysota\s+`)
regexpHeaderMyPota := regexp.MustCompile(`(?i)^mypota\s+`)
regexpHeaderMyGrid := regexp.MustCompile(`(?i)^mygrid\s+`)
regexpHeaderMyCounty := regexp.MustCompile(`(?i)^mycounty\s+`)
regexpHeaderQslMsg := regexp.MustCompile(`(?i)^qslmsg\s+`)
regexpHeaderNickname := regexp.MustCompile(`(?i)^nickname\s+`)
@ -73,6 +74,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
headerMySOTA := ""
headerMyPOTA := ""
headerMyGrid := ""
headerMyCounty := ""
headerQslMsg := ""
headerNickname := ""
//headerDate := ""
@ -245,6 +247,16 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
continue
}
//My County
if regexpHeaderMyCounty.MatchString(eachline) {
myMyCountyList := regexpHeaderMyCounty.Split(eachline, -1)
if len(myMyCountyList[1]) > 0 {
headerMyCounty = myMyCountyList[1]
}
//If there is no data after the marker, we just skip the data.
continue
}
//QSL Message
if regexpHeaderQslMsg.MatchString(eachline) {
myQslMsgList := regexpHeaderQslMsg.Split(eachline, -1)
@ -283,6 +295,7 @@ func LoadFile(inputFilename string, isInterpolateTime bool) (filleFullLog []LogL
previousLogLine.MyPOTA = headerMyPOTA
previousLogLine.MySOTA = headerMySOTA
previousLogLine.MyGrid = headerMyGrid
previousLogLine.MyCounty = headerMyCounty
previousLogLine.QSLmsg = headerQslMsg //previousLogLine.QslMsg is redundant
previousLogLine.Nickname = headerNickname

@ -42,6 +42,7 @@ func TestLoadFile_happyCase(t *testing.T) {
dataArray = append(dataArray, "mySota on/on-001")
dataArray = append(dataArray, "myPota k-0802")
dataArray = append(dataArray, "myGrid jo50")
dataArray = append(dataArray, "myCounty Ham County")
dataArray = append(dataArray, "QslMsg This is a QSL message")
dataArray = append(dataArray, " ")
dataArray = append(dataArray, " #Log")
@ -87,6 +88,10 @@ func TestLoadFile_happyCase(t *testing.T) {
if loadedLogFile[0].QSLmsg != expectedValue {
t.Errorf("Not the expected QSL Message from Header value: %s (expecting %s)", loadedLogFile[0].QSLmsg, expectedValue)
}
expectedValue = "Ham County"
if loadedLogFile[0].MyCounty != expectedValue {
t.Errorf("Not the expected MyCounty from Header value: %s (expecting %s)", loadedLogFile[0].MyCounty, expectedValue)
}
expectedValue = "IK5ZVE/5"
if loadedLogFile[0].Call != expectedValue {
t.Errorf("Not the expected Call[0] value: %s (expecting %s)", loadedLogFile[0].Call, expectedValue)

@ -34,6 +34,7 @@ type LogLine struct {
MyPota string
MySota string
MyGrid string
MyCounty string
QslMsgFromHeader string
Nickname string
Mode string

Loading…
Cancel
Save