This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwaveforecastitem.go
46 lines (42 loc) · 1.54 KB
/
waveforecastitem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package surfnerd
// Data container for WaveWatch data at a specific timestep and location.
type WaveForecastItem struct {
Date string
Time string
SignificantWaveHeight float64
DominantWaveDirection float64
MeanWavePeriod float64
PrimarySwellWaveHeight float64
PrimarySwellDirection float64
PrimarySwellPeriod float64
SecondarySwellWaveHeight float64
SecondarySwellDirection float64
SecondarySwellPeriod float64
WindSwellWaveHeight float64
WindSwellDirection float64
WindSwellPeriod float64
SurfaceWindSpeed float64
SurfaceWindDirection float64
Units UnitSystem
}
func (w *WaveForecastItem) ChangeUnits(newUnits UnitSystem) {
if w.Units == newUnits {
return
}
switch newUnits {
case Metric:
w.SignificantWaveHeight = FeetToMeters(w.SignificantWaveHeight)
w.PrimarySwellWaveHeight = FeetToMeters(w.PrimarySwellWaveHeight)
w.SecondarySwellWaveHeight = FeetToMeters(w.SecondarySwellWaveHeight)
w.WindSwellWaveHeight = FeetToMeters(w.WindSwellWaveHeight)
w.SurfaceWindSpeed = MilesPerHourToMetersPerSecond(w.SurfaceWindSpeed)
case English:
w.SignificantWaveHeight = MetersToFeet(w.SignificantWaveHeight)
w.PrimarySwellWaveHeight = MetersToFeet(w.PrimarySwellWaveHeight)
w.SecondarySwellWaveHeight = MetersToFeet(w.SecondarySwellWaveHeight)
w.WindSwellWaveHeight = MetersToFeet(w.WindSwellWaveHeight)
w.SurfaceWindSpeed = MetersPerSecondToMilesPerHour(w.SurfaceWindSpeed)
default:
}
w.Units = newUnits
}