-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
79 lines (62 loc) · 1.27 KB
/
models.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package slogo
import (
"fmt"
"io"
)
// Speed in knots
type Speed float32
// Depth in feet
type Depth float32
// Radians angle
type Radians float32
type Flags uint16
const (
F0 Flags = 1 << iota
F1
F2
F3
F4
)
// ToKph converts speed to kilometers per hour
func (s Speed) ToKph() float32 {
return float32(s) * 1.85200
}
// ToMps converts speed to meters per second
func (s Speed) ToMps() float32 {
return float32(s) * 0.514444
}
// ToMeters convert depth to meters
func (d Depth) ToMeters() float32 {
return FeetToMeter(float32(d))
}
func (r Radians) ToDeg() float32 {
return deg32(float32(r))
}
type Point struct {
YMerc int32
XMerc int32
}
func (p Point) GeoLatLon() (lat float64, lng float64) {
return Latitude(p.YMerc), Longitude(p.XMerc)
}
func (p Point) ToGMapsURL(zoom byte) string {
la, lo := p.GeoLatLon()
return fmt.Sprintf("https://maps.google.com/maps?q=@%f,%f&z=%d", la, lo, zoom)
}
func (p Point) String() string {
return fmt.Sprintf("<%d, %d>", p.YMerc, p.XMerc)
}
//Header represents the SLx file header. Same for all formats
type Header struct {
Format uint16
Version uint16
Blocksize uint16
Debug uint16
}
type Frame interface {
FrameReader
Location() Point
}
type FrameReader interface {
Read(r io.ReadSeeker, header *Header) error
}