This commit is contained in:
2026-05-28 08:48:41 +02:00
parent 28da6f6165
commit a8b7622667
14 changed files with 2702 additions and 35 deletions
+21 -24
View File
@@ -140,8 +140,11 @@ func (m *Manager) Lookup(ctx context.Context, callsign string) (Result, error) {
return Result{}, lastErr
}
// fillFromDXCC fills in country/continent/zones/lat/lon from the cty.dat
// resolver when the provider returned them empty. Provider data wins.
// fillFromDXCC fills (or overrides) country/continent/zones/lat/lon from
// the cty.dat resolver. Default behaviour is "fill empty fields only";
// for slashed callsigns (IT9/DK6XZ, DL/F4NIE…) we OVERRIDE because the
// provider returned the home-call's entity, which is wrong for portable
// operations. The provider keeps Name/QTH/Address (still useful for QSL).
// Returns true if any field was filled.
func fillFromDXCC(r *Result, dxcc DXCCResolver) bool {
if dxcc == nil {
@@ -151,29 +154,23 @@ func fillFromDXCC(r *Result, dxcc DXCCResolver) bool {
if !ok {
return false
}
slashed := strings.ContainsRune(r.Callsign, '/')
shouldStr := func(existing string) bool { return existing == "" || slashed }
shouldInt := func(existing int) bool { return existing == 0 || slashed }
shouldF := func(existing float64) bool { return existing == 0 || slashed }
filled := false
if r.Country == "" && country != "" {
r.Country = country
filled = true
}
if r.Continent == "" && cont != "" {
r.Continent = cont
filled = true
}
if r.CQZ == 0 && cqz != 0 {
r.CQZ = cqz
filled = true
}
if r.ITUZ == 0 && ituz != 0 {
r.ITUZ = ituz
filled = true
}
if r.Lat == 0 && lat != 0 {
r.Lat = lat
filled = true
}
if r.Lon == 0 && lon != 0 {
r.Lon = lon
if country != "" && shouldStr(r.Country) { r.Country = country; filled = true }
if cont != "" && shouldStr(r.Continent) { r.Continent = cont; filled = true }
if cqz != 0 && shouldInt(r.CQZ) { r.CQZ = cqz; filled = true }
if ituz != 0 && shouldInt(r.ITUZ) { r.ITUZ = ituz; filled = true }
if lat != 0 && shouldF(r.Lat) { r.Lat = lat; filled = true }
if lon != 0 && shouldF(r.Lon) { r.Lon = lon; filled = true }
// QRZ's DXCC number is the home call's — wrong for portable ops.
// cty.dat has no DXCC# (only Clublog does), so clear it: the UI
// will fall back to callsign-level worked-before until we ship a
// proper entity-name → DXCC# mapping.
if slashed && r.DXCC != 0 {
r.DXCC = 0
filled = true
}
return filled