From d0905266e12b65730fff106c92e0085d44ceabbe Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Tue, 27 Jun 2023 16:49:22 +0200 Subject: [PATCH] Fix typo and improve direction calculations Correct typos related to Angle naming and update calculations for start and end ranges in direction mapping. This ensures accurate and valid directional values are used in the application. --- direction.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/direction.go b/direction.go index 14fcca2..8afd1d6 100644 --- a/direction.go +++ b/direction.go @@ -12,10 +12,10 @@ import ( ) const ( - // DirectionMinAngel is the minimum angel for a direction - DirectionMinAngel = 0 - // DirectionMaxAngel is the maximum angel for a direction - DirectionMaxAngel = 360 + // DirectionMinAngle is the minimum angel for a direction + DirectionMinAngle = 0 + // DirectionMaxAngle is the maximum angel for a direction + DirectionMaxAngle = 360 ) // WindDirAbbrMap is a map to associate a wind direction degree value with @@ -84,7 +84,7 @@ func (d Direction) Source() Source { // Direction returns the abbreviation string for a given Direction type func (d Direction) Direction() string { - if d.fv < DirectionMinAngel || d.fv > DirectionMaxAngel { + if d.fv < DirectionMinAngle || d.fv > DirectionMaxAngle { return ErrUnsupportedDirection } if ds, ok := WindDirAbbrMap[d.fv]; ok { @@ -95,7 +95,7 @@ func (d Direction) Direction() string { // DirectionFull returns the full string for a given Direction type func (d Direction) DirectionFull() string { - if d.fv < DirectionMinAngel || d.fv > DirectionMaxAngel { + if d.fv < DirectionMinAngle || d.fv > DirectionMaxAngle { return ErrUnsupportedDirection } if ds, ok := WindDirFullMap[d.fv]; ok { @@ -125,8 +125,8 @@ func findDirection(v float64, m map[float64]string) string { break } } - sr := math.Mod(v, sv) - er := math.Mod(ev, v) + sr := v - sv + er := ev - v if er > sr { return m[sv] }