-
Notifications
You must be signed in to change notification settings - Fork 36
/
manualcollect.go
93 lines (73 loc) · 1.76 KB
/
manualcollect.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"sort"
"github.com/GeoNet/delta/meta"
)
func (n *Network) ManualCollection(set *meta.Set, network, label string) error {
for _, sample := range set.Samples() {
net, ok := set.Network(sample.Network)
if !ok {
continue
}
if net.Code != network {
continue
}
var sites []Site
for _, point := range set.Points() {
if point.Sample != sample.Code {
continue
}
var sensors []Sensor
for _, feature := range set.Features() {
if feature.Station != sample.Code {
continue
}
if feature.Location != point.Location {
continue
}
sensors = append(sensors, Sensor{
Code: feature.Sublocation,
Property: feature.Property,
Aspect: feature.Aspect,
Type: label,
Description: feature.Description,
StartDate: feature.Start,
EndDate: feature.End,
})
}
sort.Slice(sensors, func(i, j int) bool {
return sensors[i].Less(sensors[j])
})
sites = append(sites, Site{
Code: point.Location,
Latitude: point.Latitude,
Longitude: point.Longitude,
Elevation: point.Elevation,
Depth: point.Depth,
Datum: point.Datum,
Survey: point.Survey,
StartDate: point.Start,
EndDate: point.End,
Sensors: sensors,
})
}
sort.Slice(sites, func(i, j int) bool {
return sites[i].Less(sites[j])
})
n.Samples = append(n.Samples, Station{
Code: sample.Code,
Network: net.External,
Name: sample.Name,
Description: net.Description,
Latitude: sample.Latitude,
Longitude: sample.Longitude,
Elevation: sample.Elevation,
Depth: sample.Depth,
Datum: sample.Datum,
StartDate: sample.Start,
EndDate: sample.End,
Sites: sites,
})
}
return nil
}