fix(adif): CNTY must be STATE,COUNTY

ADIF defines CNTY as "STATE,COUNTY" — "GA,BARROW". OpsLog wrote the bare county
name, which a receiving logger cannot resolve: county names repeat across
states, and there is a Washington County in thirty of them. The award engine
here was never affected, since it reads the columns rather than the ADIF; the
damage was to every file we hand to someone else.

One writer covers everything — writeRecord — so this fixes file exports and the
LoTW, Club Log, HRDLog and QRZ uploads together. MY_CNTY gets the same
treatment.

The county alone is still written when no state is known: a bare name is worth
more than nothing, and inventing a prefix would be worse than either. A value
that already carries a comma passes through untouched, so re-exporting an
imported record cannot double the prefix.

Import is the mirror: "GA,BARROW" fills both columns, and a file carrying the
bare county — as OpsLog's own older exports do — still imports unchanged. The
state parsed out of CNTY only fills a blank STATE, never overrides it: STATE is
the dedicated field and the more specific statement.
This commit is contained in:
2026-08-13 12:15:09 +02:00
parent 2695747db6
commit dc0b00b474
7 changed files with 124 additions and 27 deletions
+29 -7
View File
@@ -15,9 +15,9 @@ import (
// ExportResult summarises an ADIF export for the UI.
type ExportResult struct {
Path string `json:"path"`
Count int `json:"count"`
SizeKB int64 `json:"size_kb"`
Path string `json:"path"`
Count int `json:"count"`
SizeKB int64 `json:"size_kb"`
}
// Exporter streams every QSO in a repo to an ADIF (.adi) file.
@@ -221,7 +221,7 @@ func writeRecord(bw *bufio.Writer, q qso.QSO, includeApp bool, allow map[string]
w("VUCC_GRIDS", q.VUCCGrids)
w("COUNTRY", q.Country)
w("STATE", q.State)
w("CNTY", q.County)
w("CNTY", adifCounty(q.State, q.County))
wi("DXCC", q.DXCC)
w("CONT", q.Continent)
wi("CQZ", q.CQZ)
@@ -285,7 +285,7 @@ func writeRecord(bw *bufio.Writer, q qso.QSO, includeApp bool, allow map[string]
w("MY_GRIDSQUARE_EXT", q.MyGridExt)
w("MY_COUNTRY", q.MyCountry)
w("MY_STATE", q.MyState)
w("MY_CNTY", q.MyCounty)
w("MY_CNTY", adifCounty(q.MyState, q.MyCounty))
w("MY_IOTA", q.MyIOTA)
w("MY_SOTA_REF", q.MySOTARef)
w("MY_POTA_REF", q.MyPOTARef)
@@ -391,10 +391,10 @@ var parentMode = map[string]string{
"ISCAT": "MFSK", "Q65": "MFSK", "FST4": "MFSK", "FST4W": "MFSK",
"MFSK16": "MFSK", "MFSK32": "MFSK", "MFSK64": "MFSK", "MFSK128": "MFSK",
"OLIVIA": "MFSK",
"PSK31": "PSK", "PSK63": "PSK", "PSK125": "PSK", "PSK250": "PSK", "PSK500": "PSK",
"PSK31": "PSK", "PSK63": "PSK", "PSK125": "PSK", "PSK250": "PSK", "PSK500": "PSK",
"QPSK31": "PSK", "QPSK63": "PSK", "QPSK125": "PSK", "QPSK250": "PSK", "QPSK500": "PSK",
"FREEDV": "DIGITALVOICE",
"VARA": "DYNAMIC", "VARA HF": "DYNAMIC", "VARA FM": "DYNAMIC", "VARAC": "DYNAMIC",
"VARA": "DYNAMIC", "VARA HF": "DYNAMIC", "VARA FM": "DYNAMIC", "VARAC": "DYNAMIC",
"THOR4": "THOR", "THOR8": "THOR", "THOR16": "THOR", "THOR32": "THOR",
"DOMINOF": "DOMINO", "DOMINOEX": "DOMINO",
"HELL80": "HELL", "FMHELL": "HELL",
@@ -413,3 +413,25 @@ func modeForExport(mode, submode string) (string, string) {
}
return mode, ""
}
// adifCounty renders CNTY the way ADIF specifies: "STATE,COUNTY", e.g.
// "GA,BARROW".
//
// OpsLog stores the two apart, and exported only the county — which a receiving
// logger cannot resolve, since county names repeat across states (there is a
// Washington County in thirty of them). The award engine here was never
// affected because it reads the columns, not the ADIF; the damage was to
// everyone we send a file to.
//
// The county alone is still written when no state is known: a bare name is
// worth more than nothing, and inventing a prefix would be worse than either.
// A county that ALREADY carries a comma is passed through — it has been
// formatted once, and doubling the prefix would corrupt it.
func adifCounty(state, county string) string {
c := strings.TrimSpace(county)
s := strings.TrimSpace(state)
if c == "" || s == "" || strings.Contains(c, ",") {
return c
}
return strings.ToUpper(s) + "," + c
}