fix: Better matching of the counties for the USA-CA
This commit is contained in:
@@ -4707,7 +4707,9 @@ var bulkFieldColumns = map[string]string{
|
|||||||
"prop_mode": "prop_mode",
|
"prop_mode": "prop_mode",
|
||||||
"sat_name": "sat_name",
|
"sat_name": "sat_name",
|
||||||
"sat_mode": "sat_mode",
|
"sat_mode": "sat_mode",
|
||||||
// Contacted station activation refs / SIG
|
// Contacted station location + activation refs / SIG
|
||||||
|
"state": "state",
|
||||||
|
"cnty": "cnty",
|
||||||
"pota_ref": "pota_ref",
|
"pota_ref": "pota_ref",
|
||||||
"sota_ref": "sota_ref",
|
"sota_ref": "sota_ref",
|
||||||
"wwff_ref": "wwff_ref",
|
"wwff_ref": "wwff_ref",
|
||||||
@@ -7925,6 +7927,15 @@ func (a *App) BackfillUSCounties() (BackfillUSCountiesResult, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
// Set of valid USA-CA county keys, so we can tell a good county from a bad one
|
||||||
|
// (a wrong county for the state, a bare city, "0", …) and re-resolve only the
|
||||||
|
// bad ones.
|
||||||
|
validRef := map[string]bool{}
|
||||||
|
if refs, ok := awardref.BuiltinRefs("USA-CA"); ok {
|
||||||
|
for _, r := range refs {
|
||||||
|
validRef[r.Code] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
for i := range rows {
|
for i := range rows {
|
||||||
q := &rows[i]
|
q := &rows[i]
|
||||||
if q.DXCC == nil {
|
if q.DXCC == nil {
|
||||||
@@ -7936,7 +7947,12 @@ func (a *App) BackfillUSCounties() (BackfillUSCountiesResult, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
res.Scanned++
|
res.Scanned++
|
||||||
needCounty := strings.TrimSpace(q.County) == ""
|
// A county "needs" filling when it maps to NO valid USA-CA county: empty,
|
||||||
|
// garbage, or a wrong county for the state. A legitimate DC operation
|
||||||
|
// (state=DC) is left alone — DC simply isn't a USA-CA county, not an error.
|
||||||
|
curKey := award.USCountyKey(q.State, q.County)
|
||||||
|
stateUp := strings.ToUpper(strings.TrimSpace(q.State))
|
||||||
|
needCounty := !validRef[curKey] && stateUp != "DC"
|
||||||
needGrid := strings.TrimSpace(q.Grid) == ""
|
needGrid := strings.TrimSpace(q.Grid) == ""
|
||||||
if !needCounty && !needGrid {
|
if !needCounty && !needGrid {
|
||||||
continue
|
continue
|
||||||
@@ -7946,13 +7962,33 @@ func (a *App) BackfillUSCounties() (BackfillUSCountiesResult, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
changed := false
|
changed := false
|
||||||
if needCounty && loc.CNTY() != "" {
|
if needCounty {
|
||||||
q.County = loc.CNTY()
|
// The logged county maps to no real USA-CA county (wrong state, wrong
|
||||||
if strings.TrimSpace(q.State) == "" {
|
// county, empty…). Fix it from the ULS, PREFERRING to keep the operator's
|
||||||
q.State = loc.State
|
// county and correct only the state — their county often came from QRZ
|
||||||
|
// and is finer than the ZIP-derived one (e.g. K1LZ logged ME,Middlesex →
|
||||||
|
// Middlesex is a MA county, so → MA,Middlesex). Fall back to the ULS
|
||||||
|
// county when even that is invalid. Never stamp an unrecognised value
|
||||||
|
// (e.g. a Connecticut 2022 "planning region" GeoNames now returns). A
|
||||||
|
// portable op keeps a suffix that won't resolve in the ULS, so only
|
||||||
|
// fixed-station bad data is ever touched.
|
||||||
|
name := q.County
|
||||||
|
if i := strings.IndexByte(name, ','); i >= 0 {
|
||||||
|
name = name[i+1:]
|
||||||
|
}
|
||||||
|
name = strings.TrimSpace(name)
|
||||||
|
var stState, stName string
|
||||||
|
if name != "" && validRef[award.USCountyKey(loc.State, name)] {
|
||||||
|
stState, stName = loc.State, name
|
||||||
|
} else if validRef[award.USCountyKey(loc.State, loc.County)] {
|
||||||
|
stState, stName = loc.State, loc.County
|
||||||
|
}
|
||||||
|
if stName != "" {
|
||||||
|
q.State = stState
|
||||||
|
q.County = stState + "," + stName
|
||||||
|
res.County++
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
res.County++
|
|
||||||
changed = true
|
|
||||||
}
|
}
|
||||||
if needGrid && loc.Grid != "" {
|
if needGrid && loc.Grid != "" {
|
||||||
q.Grid = loc.Grid
|
q.Grid = loc.Grid
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ const FIELDS: FieldDef[] = [
|
|||||||
{ id: 'prop_mode', label: 'bulk.fPropMode', group: 'Propagation', kind: 'text', upper: true },
|
{ id: 'prop_mode', label: 'bulk.fPropMode', group: 'Propagation', kind: 'text', upper: true },
|
||||||
{ id: 'sat_name', label: 'bulk.fSatName', group: 'Propagation', kind: 'text', upper: true },
|
{ id: 'sat_name', label: 'bulk.fSatName', group: 'Propagation', kind: 'text', upper: true },
|
||||||
{ id: 'sat_mode', label: 'bulk.fSatMode', group: 'Propagation', kind: 'text', upper: true },
|
{ id: 'sat_mode', label: 'bulk.fSatMode', group: 'Propagation', kind: 'text', upper: true },
|
||||||
// Contacted station (activation refs / SIG)
|
// Contacted station (location / activation refs / SIG)
|
||||||
|
{ id: 'state', label: 'bulk.fState', group: 'Contacted station', kind: 'text', upper: true },
|
||||||
|
{ id: 'cnty', label: 'bulk.fCnty', group: 'Contacted station', kind: 'text' },
|
||||||
{ id: 'pota_ref', label: 'bulk.fPotaRef', group: 'Contacted station', kind: 'text', upper: true },
|
{ id: 'pota_ref', label: 'bulk.fPotaRef', group: 'Contacted station', kind: 'text', upper: true },
|
||||||
{ id: 'sota_ref', label: 'bulk.fSotaRef', group: 'Contacted station', kind: 'text', upper: true },
|
{ id: 'sota_ref', label: 'bulk.fSotaRef', group: 'Contacted station', kind: 'text', upper: true },
|
||||||
{ id: 'wwff_ref', label: 'bulk.fWwffRef', group: 'Contacted station', kind: 'text', upper: true },
|
{ id: 'wwff_ref', label: 'bulk.fWwffRef', group: 'Contacted station', kind: 'text', upper: true },
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user