-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplace.go
43 lines (38 loc) · 797 Bytes
/
place.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
package novas
/*
#include "NOVAS_novas.h"
*/
import "C"
import (
"fmt"
)
type Place struct {
place C.on_surface
lat, long, h, t, p float64
}
// Defines an observer location, somewhere on earth.
func NewPlace(latitude, longitude, height, temperature, pressure float64) *Place {
p := Place{lat: latitude, long: longitude, h:height, t: temperature, p: pressure}
C.make_on_surface(
C.double(latitude),
C.double(longitude),
C.double(height),
C.double(temperature),
C.double(pressure),
&p.place)
return &p
}
func (p Place) String() string {
var s string
if p.lat < 0 {
s = fmt.Sprintf("%.3f°S", -p.lat)
} else {
s = fmt.Sprintf("%.3f°N", p.lat)
}
if p.long < 0 {
s += fmt.Sprintf(" %.3f°W", -p.long)
} else {
s += fmt.Sprintf(" %.3f°E", p.long)
}
return s
}