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:
+29
-2
@@ -428,7 +428,12 @@ func recordToQSO(rec Record) (qso.QSO, bool) {
|
||||
q.VUCCGrids = strings.ToUpper(rec["vucc_grids"])
|
||||
q.Country = rec["country"]
|
||||
q.State = strings.ToUpper(rec["state"])
|
||||
q.County = rec["cnty"]
|
||||
q.County, _ = splitADIFCounty(rec["cnty"])
|
||||
if st := rec["state"]; strings.TrimSpace(st) == "" {
|
||||
if _, fromCnty := splitADIFCounty(rec["cnty"]); fromCnty != "" {
|
||||
q.State = fromCnty
|
||||
}
|
||||
}
|
||||
if v, ok := parseInt(rec["dxcc"]); ok {
|
||||
q.DXCC = &v
|
||||
}
|
||||
@@ -515,7 +520,12 @@ func recordToQSO(rec Record) (qso.QSO, bool) {
|
||||
q.MyGridExt = strings.ToUpper(rec["my_gridsquare_ext"])
|
||||
q.MyCountry = rec["my_country"]
|
||||
q.MyState = strings.ToUpper(rec["my_state"])
|
||||
q.MyCounty = rec["my_cnty"]
|
||||
q.MyCounty, _ = splitADIFCounty(rec["my_cnty"])
|
||||
if st := rec["my_state"]; strings.TrimSpace(st) == "" {
|
||||
if _, fromCnty := splitADIFCounty(rec["my_cnty"]); fromCnty != "" {
|
||||
q.MyState = fromCnty
|
||||
}
|
||||
}
|
||||
q.MyIOTA = strings.ToUpper(rec["my_iota"])
|
||||
q.MySOTARef = strings.ToUpper(rec["my_sota_ref"])
|
||||
q.MyPOTARef = strings.ToUpper(rec["my_pota_ref"])
|
||||
@@ -698,3 +708,20 @@ var promotableSubmodes = map[string]bool{
|
||||
func submodeSubsumesParent(submode string) bool {
|
||||
return promotableSubmodes[submode]
|
||||
}
|
||||
|
||||
// splitADIFCounty reads CNTY, which ADIF defines as "STATE,COUNTY".
|
||||
//
|
||||
// Returns the county on its own plus the state the field carried, so an import
|
||||
// from a logger that follows the standard fills BOTH columns here. Files that
|
||||
// write the bare county — as OpsLog itself used to — still import unchanged.
|
||||
//
|
||||
// The state from the field never overrides an explicit STATE tag: STATE is the
|
||||
// dedicated field and the more specific statement. It only fills a blank.
|
||||
func splitADIFCounty(cnty string) (county, state string) {
|
||||
cnty = strings.TrimSpace(cnty)
|
||||
i := strings.Index(cnty, ",")
|
||||
if i < 0 {
|
||||
return cnty, ""
|
||||
}
|
||||
return strings.TrimSpace(cnty[i+1:]), strings.ToUpper(strings.TrimSpace(cnty[:i]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user