Skip to content

Commit f4b26b4

Browse files
committed
Additional refactor to make sure we are compatible with @int2001/DXClusterAPI. This closes #9.
1 parent ccdf36d commit f4b26b4

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

internal/spot/spot.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (s Spot) MarshalJSON() ([]byte, error) {
4848
LoTWUser interface{} `json:"lotw_user"` // "2" or false
4949
Lat interface{} `json:"lat,omitempty"` // string in output
5050
Lng interface{} `json:"lng,omitempty"` // string in output
51+
CQZ interface{} `json:"cqz,omitempty"` // string in output - CQ Zone
5152
}
5253

5354
buildFlatInfo := func(info Info) *FlatInfo {
@@ -66,6 +67,9 @@ func (s Spot) MarshalJSON() ([]byte, error) {
6667
if info.DXCC.Longitude != 0 {
6768
flat.Lng = fmt.Sprintf("%.1f", info.DXCC.Longitude)
6869
}
70+
if info.DXCC.CQZ != 0 {
71+
flat.CQZ = fmt.Sprintf("%d", info.DXCC.CQZ)
72+
}
6973
}
7074
// LoTW user: "2" if user, false if not
7175
if info.IsLoTWUser && info.LoTW != nil {
@@ -76,31 +80,32 @@ func (s Spot) MarshalJSON() ([]byte, error) {
7680
return flat
7781
}
7882

79-
// Build the output structure - simple keys first, then objects
83+
// Build the output structure - match original field order
84+
// Original: spotter, spotted, frequency, message, when, source, dxcc_spotter, dxcc_spotted, band
8085
output := struct {
8186
Spotter string `json:"spotter"`
8287
Spotted string `json:"spotted"`
8388
Frequency float64 `json:"frequency"`
84-
Band string `json:"band"`
8589
Message string `json:"message"`
8690
When time.Time `json:"when"`
87-
Source string `json:"source,omitempty"` // Extra: helpful for debugging
88-
PotaRef string `json:"pota_ref,omitempty"` // Extra: POTA reference (only for POTA spots)
89-
PotaMode string `json:"pota_mode,omitempty"` // Extra: POTA mode (only for POTA spots)
91+
Source string `json:"source,omitempty"`
9092
DXCCSpotter *FlatInfo `json:"dxcc_spotter,omitempty"`
9193
DXCCSpotted *FlatInfo `json:"dxcc_spotted,omitempty"`
94+
Band string `json:"band"`
95+
PotaRef string `json:"pota_ref,omitempty"` // Extra: only for POTA spots
96+
PotaMode string `json:"pota_mode,omitempty"` // Extra: only for POTA spots
9297
}{
9398
Spotter: s.Spotter,
9499
Spotted: s.Spotted,
95100
Frequency: s.Frequency,
96-
Band: s.Band,
97101
Message: s.Message,
98102
When: s.When,
99103
Source: s.Source,
100-
PotaRef: s.AdditionalData.PotaRef,
101-
PotaMode: s.AdditionalData.PotaMode,
102104
DXCCSpotter: buildFlatInfo(s.SpotterInfo),
103105
DXCCSpotted: buildFlatInfo(s.SpottedInfo),
106+
Band: s.Band,
107+
PotaRef: s.AdditionalData.PotaRef,
108+
PotaMode: s.AdditionalData.PotaMode,
104109
}
105110

106111
return json.Marshal(output)

0 commit comments

Comments
 (0)