up
This commit is contained in:
@@ -209,7 +209,13 @@ func parseEntityHeader(line string) *Entity {
|
||||
e.CQZone, _ = strconv.Atoi(strings.TrimSpace(parts[1]))
|
||||
e.ITUZone, _ = strconv.Atoi(strings.TrimSpace(parts[2]))
|
||||
e.Lat, _ = strconv.ParseFloat(strings.TrimSpace(parts[4]), 64)
|
||||
e.Lon, _ = strconv.ParseFloat(strings.TrimSpace(parts[5]), 64)
|
||||
// cty.dat longitude is "+ for West" (e.g. France 2°E = -2.00, USA 92°W =
|
||||
// +91.87). Negate it to the standard "+ for East" the rest of the app uses
|
||||
// (grids, bearing/distance math), otherwise every cty.dat-derived azimuth and
|
||||
// cluster distance is mirrored east↔west.
|
||||
if lon, err := strconv.ParseFloat(strings.TrimSpace(parts[5]), 64); err == nil {
|
||||
e.Lon = -lon
|
||||
}
|
||||
e.TZOffset, _ = strconv.ParseFloat(strings.TrimSpace(parts[6]), 64)
|
||||
if e.Name == "" {
|
||||
return nil
|
||||
@@ -241,7 +247,8 @@ func parsePrefix(s string, e *Entity) (prefixEntry, bool) {
|
||||
lat, e1 := strconv.ParseFloat(a, 64)
|
||||
lon, e2 := strconv.ParseFloat(b, 64)
|
||||
if e1 == nil && e2 == nil {
|
||||
out.latOverride, out.lonOverride = lat, lon
|
||||
// Same "+ for West" → "+ for East" flip as the entity header.
|
||||
out.latOverride, out.lonOverride = lat, -lon
|
||||
out.hasLatLon = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,22 @@ United States: 05: 08: NA: 37.53: 91.67: 5.0: K:
|
||||
=W1AW(5)[7],K,N,W,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK;
|
||||
`
|
||||
|
||||
// cty.dat stores longitude "+ for West"; we normalise to the standard
|
||||
// "+ for East" so bearing/distance math (and the cluster map) aren't mirrored.
|
||||
// Regression guard for the Svalbard-azimuth bug (356° instead of 4°).
|
||||
func TestLongitudeSign(t *testing.T) {
|
||||
db, err := Load(strings.NewReader(sampleCty))
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
if m, ok := db.Lookup("F4BPO"); !ok || m.Lon <= 0 { // France 2°E → +2
|
||||
t.Errorf("France lon = %v, want positive (East)", m.Lon)
|
||||
}
|
||||
if m, ok := db.Lookup("K1ABC"); !ok || m.Lon >= 0 { // USA 92°W → ~-91.67
|
||||
t.Errorf("USA lon = %v, want negative (West)", m.Lon)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLookup(t *testing.T) {
|
||||
db, err := Load(strings.NewReader(sampleCty))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user