Documentation
¶
Index ¶
- func CalculateBearing(lat1, lon1, lat2, lon2 float64) float64
- func GetLongPathBearing(localGridSquare, remoteGridSquare string) (float64, error)
- func GetLongPathDistance(localGridSquare, remoteGridSquare string) (float64, float64, error)
- func GetShortPathBearing(localGridSquare, remoteGridSquare string) (float64, error)
- func GetShortPathDistance(localGridSquare, remoteGridSquare string) (float64, float64, error)
- func LatitudeFromGridSquare(gridSquare string) (float64, error)
- func LongitudeFromGridSquare(gridSquare string) (float64, error)
- type Location
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateBearing ¶
CalculateBearing calculates the initial bearing (or heading) from one point to another given their latitude and longitude coordinates.
Parameters:
- lat1: Latitude of the starting point in degrees
- lon1: Longitude of the starting point in degrees
- lat2: Latitude of the destination point in degrees
- lon2: Longitude of the destination point in degrees
Returns:
- float64: The initial bearing in degrees from the starting point to the destination (0-360°), rounded to the nearest 0.1 degree
func GetLongPathBearing ¶
func GetLongPathDistance ¶
func GetShortPathBearing ¶
GetShortPathBearing computes the initial bearing between two Maidenhead Grid Square locations. It takes two grid square strings (case-insensitive), validates them, and returns the bearing in degrees or an error if invalid.
Parameters:
- localGridSquare: The Maidenhead Grid Square of the local station (6 characters)
- remoteGridSquare: The Maidenhead Grid Square of the remote station (6 characters)
Returns:
- float64: The bearing in degrees from the local to the remote grid square (0-360°)
- error: An error if either grid square is invalid
func GetShortPathDistance ¶
GetShortPathDistance calculates the distance in kilometers and miles between two Maidenhead Grid Square locations. It takes two grid square strings (case-insensitive) as input and returns the distances and an error if the inputs are invalid.
Parameters:
- localGridSquare: The Maidenhead Grid Square of the local station (6 characters)
- remoteGridSquare: The Maidenhead Grid Square of the remote station (6 characters)
Returns:
- float64: The distance in kilometers between the grid squares
- float64: The distance in miles between the grid squares
- error: An error if either grid square is invalid
func LatitudeFromGridSquare ¶
LatitudeFromGridSquare calculates the latitude from a Maidenhead Grid Square identifier. The input gridSquare is case-insensitive and must be a valid 6-character grid square format. Returns the latitude or an error if the input is invalid.
func LongitudeFromGridSquare ¶
LongitudeFromGridSquare calculates the longitude from a Maidenhead Grid Square and returns it as a float64. It expects a 6-character grid square string (case-insensitive) and validates its format before processing.
Types ¶
type Location ¶
type Location struct {
LocalGridSquare string `json:"localGridSquare"`
RemoteGridSquare string `json:"remoteGridSquare"`
ShortPathBearing float64 `json:"short_path_bearing"`
LongPathBearing float64 `json:"long_path_bearing"`
ShortPathDistanceKm int64 `json:"short_path_distance_km"`
ShortPathDistanceMiles int64 `json:"short_path_distance_miles"`
LongPathDistanceKm int64 `json:"long_path_distance_km"`
LongPathDistanceMiles int64 `json:"long_path_distance_miles"`
}
func GetLocation ¶
GetLocation calculates the distance, bearing, and other information between two Maidenhead Grid Square locations. It returns a `Location` struct containing the computed results or an error if the inputs are invalid. Grid square input is case-insensitive (e.g., JN58TD and jn58td are both accepted).
Parameters:
- localGridSquare: The Maidenhead Grid Square of the local station (6 characters)
- remoteGridSquare: The Maidenhead Grid Square of the remote station (6 characters)
Returns:
- *Location: A struct containing the bearing, distance in km and miles, and the original grid squares
- error: An error if either grid square is invalid or if calculations fail