fix(dxcc): a retired prefix is not a wrong one

Reported from a real import: every ZK2 contact came back New Zealand and
Niue vanished from a DXCC that had it confirmed. cty.dat is not wrong,
it is CURRENT — Niue moved to E6, so ZK2 reverted to New Zealand there.
ZK1 loses the Cook Islands the same way, and the reporter was right to
suspect more.

ClubLog's prefix table is date-ranged and still knows both, which is the
whole reason for enabling its country file. We consulted it only for
callsigns that already HAD a per-callsign exception — so a ZK2 with no
exception never reached it. It is now asked whenever no exception covers
the QSO's date.

Two limits keep the blast radius honest. It never overrules an exact
'=CALLSIGN' entry in cty.dat — that is somebody having looked at this
very callsign, and a prefix rule does not overrule it, which is why
Match now says how it matched. And where ClubLog has no answer (E6, TO5A
and their like are absent from its prefix table) cty.dat still decides,
because silence is not an answer. Measured before changing: on a sample
of thirty calls the two files agreed on twenty-eight, and both
disagreements were this bug. Opens 0.27.11.
This commit is contained in:
2026-09-03 22:11:55 +02:00
parent 4dbc773343
commit b00552f617
4 changed files with 103 additions and 9 deletions
+11 -1
View File
@@ -40,6 +40,14 @@ type Match struct {
Continent string `json:"continent"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
// Exact marks a hit on cty.dat's "=CALLSIGN" list rather than on a prefix.
//
// The two carry very different authority. A prefix match is a rule of thumb
// about a block of callsigns; an exact entry is somebody having looked at
// THIS callsign and written down where it was. A second country file may
// improve on the first kind and should not be allowed to overrule the
// second.
Exact bool `json:"exact,omitempty"`
}
type prefixEntry struct {
@@ -149,7 +157,9 @@ func (db *DB) Lookup(callsign string) (Match, bool) {
return Match{}, false
}
if e, ok := db.exact[call]; ok {
return materialize(e), true
m := materialize(e)
m.Exact = true
return m, true
}
// KG4 special case: Guantanamo Bay (DXCC 105) is "KG4" followed by EXACTLY
// two characters (KG4XX). "KG4", "KG4X", "KG4XYZ"… are continental USA.