Documentation
¶
Index ¶
- func BandFromFreq(frequency interface{}) string
- func FormatFrequency(hz int64) string
- func FormatFrequencyAs(hz int64, unit FrequencyUnit) string
- func FrequencyDeviation(freq1, freq2 int64, toleranceHz int64) bool
- func FrequencyTo(hz int64, unit FrequencyUnit) interface{}
- func LookupDXCC(call string, client DXCCLookupClient) (*dxcc.DxccInfo, error)
- func NormalizeCallsign(raw string) string
- func NormalizeToHz(input interface{}) (int64, error)
- func ParseFrequency(input interface{}) (int64, error)
- type DXCCLookupClient
- type FrequencyUnit
- type ParsedCallsign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BandFromFreq ¶
func BandFromFreq(frequency interface{}) string
BandFromFreq converts a frequency to a ham radio band string. Accepts frequency in Hz (int64), kHz, or MHz and automatically detects the unit. Also accepts string representations of frequencies.
func FormatFrequency ¶
FormatFrequency formats a frequency in Hz to a human-readable string. Automatically chooses the best unit (GHz, MHz, kHz, or Hz) for readability.
Output format:
- Hz: "1500000" (no decimals)
- kHz: "1500.000 kHz" (3 decimals minimum)
- MHz: "1.500 MHz" (3 decimals minimum)
- GHz: "1.500 GHz" (3 decimals minimum)
Example outputs:
- 14250000 Hz -> "14.250 MHz"
- 50125000 Hz -> "50.125 MHz"
- 2400000000 Hz -> "2.400 GHz"
- 1200000 Hz -> "1200.000 kHz"
func FormatFrequencyAs ¶
func FormatFrequencyAs(hz int64, unit FrequencyUnit) string
FormatFrequencyAs formats a frequency in Hz to a specific unit with 3 decimal places. For Hz, returns an integer with no decimals.
Examples:
- FormatFrequencyAs(14250000, MHzUnit) -> "14.250 MHz"
- FormatFrequencyAs(14250000, KHzUnit) -> "14250.000 kHz"
- FormatFrequencyAs(1200000000, GHzUnit) -> "1.200 GHz"
- FormatFrequencyAs(1500000, HzUnit) -> "1500000 Hz"
func FrequencyDeviation ¶
FrequencyDeviation checks if two frequencies (in Hz) are within a certain tolerance. Useful for detecting duplicate spots with slight frequency drift.
Parameters:
- freq1, freq2: frequencies in Hz (int64)
- toleranceHz: tolerance in Hz (e.g., 3000 for ±3 kHz)
Returns: true if |freq1 - freq2| <= toleranceHz
func FrequencyTo ¶
func FrequencyTo(hz int64, unit FrequencyUnit) interface{}
FrequencyTo converts a frequency from Hz to a target unit. Returns the frequency value in the target unit with appropriate precision.
For Hz: always returns integer (no decimals) For kHz, MHz, GHz: returns float64 with proper decimal representation
func LookupDXCC ¶
func LookupDXCC(call string, client DXCCLookupClient) (*dxcc.DxccInfo, error)
LookupDXCC performs DXCC entity lookup for a callsign.
func NormalizeCallsign ¶
NormalizeCallsign removes common system suffixes and invalid characters from a raw callsign string, returning the cleaned canonical form. This is used to strip POTA system suffixes (like "-#") and other automatic system markers from callsigns before storage/output.
func NormalizeToHz ¶
NormalizeToHz takes any frequency representation and returns it as Hz (int64). This is a convenience wrapper around ParseFrequency for code that always expects Hz output.
Example:
- NormalizeToHz("14250") -> 14250000
- NormalizeToHz(14.250) -> 14250000
func ParseFrequency ¶
ParseFrequency parses a frequency string or number and returns it in Hz (integer). Automatically detects the input unit (Hz, kHz, MHz, GHz) based on magnitude.
Input examples:
- "14250" -> auto-detected as kHz -> 14250000 Hz
- "14.250" -> auto-detected as MHz -> 14250000 Hz
- "0.014250" -> auto-detected as GHz -> 14250000 Hz
- "14250000" -> auto-detected as Hz -> 14250000 Hz
- 14250 (int) -> auto-detected as kHz -> 14250000 Hz
- 14.250 (float) -> auto-detected as MHz -> 14250000 Hz
Returns: frequency in Hz (int64), or error if parsing fails
Types ¶
type DXCCLookupClient ¶ added in v1.1.3
type DXCCLookupClient interface {
GetException(call string) (*dxcc.DxccInfo, bool)
GetPrefix(prefix string) (*dxcc.DxccInfo, bool)
}
DXCCLookupClient is an interface for DXCC lookup operations
type FrequencyUnit ¶
type FrequencyUnit int
FrequencyUnit represents the unit of a frequency value
const ( HzUnit FrequencyUnit = iota KHzUnit MHzUnit GHzUnit )
type ParsedCallsign ¶
type ParsedCallsign struct {
Original string // Original input
A string // Prefix (before first /)
B string // Core callsign (between / or start/end)
C string // Suffix (after second /)
Raw string // Cleaned for regex matching (uppercase, trimmed)
}
ParsedCallsign represents a tokenized callsign: A/B/C structure.
func ParseCallsign ¶
func ParseCallsign(raw string) ParsedCallsign
ParseCallsign tokenizes a raw callsign into A/B/C structure (prefix/callsign/suffix). Does NOT apply DXCC special rules; that is done by LookupDXCC.