本文整理匯總了Golang中github.com/GeoNet/delta/meta.LoadList函數的典型用法代碼示例。如果您正苦於以下問題:Golang LoadList函數的具體用法?Golang LoadList怎麽用?Golang LoadList使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了LoadList函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestConstituents
func TestConstituents(t *testing.T) {
gauges := make(map[string]meta.Gauge)
{
t.Log("Load installed gauges file")
var list meta.GaugeList
if err := meta.LoadList("../network/gauges.csv", &list); err != nil {
t.Fatal(err)
}
for _, g := range list {
gauges[g.Code] = g
}
}
var constituents meta.ConstituentList
if err := meta.LoadList("../network/constituents.csv", &constituents); err != nil {
t.Fatal(err)
}
for i := 0; i < len(constituents); i++ {
for j := i + 1; j < len(constituents); j++ {
if constituents[i].Gauge == constituents[j].Gauge && constituents[i].Number == constituents[j].Number {
t.Error("contituent duplication: " + constituents[i].Gauge + "/" + strconv.Itoa(constituents[i].Number))
}
}
}
for _, c := range constituents {
if _, ok := gauges[c.Gauge]; !ok {
t.Error("unknown gauge: " + c.Gauge)
}
}
}
示例2: TestMonuments
func TestMonuments(t *testing.T) {
var monuments meta.MonumentList
t.Log("Load network monuments file")
{
if err := meta.LoadList("../network/monuments.csv", &monuments); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(monuments); i++ {
for j := i + 1; j < len(monuments); j++ {
if monuments[i].Mark == monuments[j].Mark {
t.Errorf("monument duplication: " + monuments[i].Mark)
}
}
}
for _, m := range monuments {
if m.GroundRelationship > 0.0 {
t.Errorf("positive monuments ground relationship: %s [%g]", m.Mark, m.GroundRelationship)
}
switch m.Type {
case "Shallow Rod / Braced Antenna Mount":
case "Wyatt/Agnew Drilled-Braced":
case "Pillar":
case "Steel Mast":
case "Unknown":
default:
t.Errorf("unknown monument type: %s [%s]", m.Mark, m.Type)
}
}
}
示例3: TestGauges
func TestGauges(t *testing.T) {
stas := make(map[string]meta.Station)
{
var list meta.StationList
t.Log("Load stations file")
if err := meta.LoadList("../network/stations.csv", &list); err != nil {
t.Fatal(err)
}
for _, s := range list {
stas[s.Code] = s
}
}
var gauges meta.GaugeList
t.Log("Load installed gauges file")
{
if err := meta.LoadList("../network/gauges.csv", &gauges); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(gauges); i++ {
for j := i + 1; j < len(gauges); j++ {
if gauges[i].Code == gauges[j].Code {
t.Errorf("gauge code duplication: " + gauges[i].Code)
}
if gauges[i].Number == gauges[j].Number {
t.Errorf("gauge number duplication: " + gauges[i].Code)
}
}
}
for _, g := range gauges {
if _, ok := stas[g.Code]; !ok {
t.Error("unknown gauge station: " + g.Code)
}
}
}
示例4: TestSites
func TestSites(t *testing.T) {
var sites meta.SiteList
t.Log("Load installed sites file")
{
if err := meta.LoadList("../network/sites.csv", &sites); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(sites); i++ {
for j := i + 1; j < len(sites); j++ {
if sites[i].Station == sites[j].Station && sites[i].Location == sites[j].Location {
t.Errorf("site duplication: " + sites[i].Station + "/" + sites[i].Location)
}
}
}
}
示例5: TestNetworks
func TestNetworks(t *testing.T) {
var networks meta.NetworkList
t.Log("Load installed sensors file")
{
if err := meta.LoadList("../network/networks.csv", &networks); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(networks); i++ {
for j := i + 1; j < len(networks); j++ {
if networks[i].Code == networks[j].Code {
t.Errorf("network duplication: " + networks[i].Code)
}
}
}
}
示例6: TestStations
func TestStations(t *testing.T) {
var stations meta.StationList
t.Log("Load installed sensors file")
{
if err := meta.LoadList("../network/stations.csv", &stations); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(stations); i++ {
for j := i + 1; j < len(stations); j++ {
if stations[i].Code == stations[j].Code {
t.Errorf("station duplication: " + stations[i].Code)
}
}
}
}
示例7: TestMarks
func TestMarks(t *testing.T) {
var marks meta.MarkList
t.Log("Load network marks file")
{
if err := meta.LoadList("../network/marks.csv", &marks); err != nil {
t.Fatal(err)
}
}
for i := 0; i < len(marks); i++ {
for j := i + 1; j < len(marks); j++ {
if marks[i].Code == marks[j].Code {
t.Errorf("mark duplication: " + marks[i].Code)
}
}
}
}
示例8: TestRecorders
func TestRecorders(t *testing.T) {
var recorders meta.InstalledRecorderList
t.Log("Load installed recorders file")
{
if err := meta.LoadList("../install/recorders.csv", &recorders); err != nil {
t.Fatal(err)
}
}
t.Log("Check for recorder installation equipment overlaps")
{
installs := make(map[string]meta.InstalledRecorderList)
for _, s := range recorders {
_, ok := installs[s.Model]
if ok {
installs[s.Model] = append(installs[s.Model], s)
} else {
installs[s.Model] = meta.InstalledRecorderList{s}
}
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].Serial != v[j].Serial:
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("recorder %s/%s at %-5s has location %-2s overlap between %s and %s",
v[i].Model, v[i].Serial, v[i].Station, v[i].Location, v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
t.Log("Check for missing recorder stations")
{
var stations meta.StationList
if err := meta.LoadList("../network/stations.csv", &stations); err != nil {
t.Fatal(err)
}
keys := make(map[string]interface{})
for _, s := range stations {
keys[s.Code] = true
}
for _, s := range recorders {
if _, ok := keys[s.Station]; ok {
continue
}
t.Errorf("unable to find recorder installed station %-5s", s.Station)
}
}
var assets meta.AssetList
t.Log("Load recorder assets file")
{
if err := meta.LoadList("../assets/recorders.csv", &assets); err != nil {
t.Fatal(err)
}
}
t.Log("Check for recorder assets")
{
for _, r := range recorders {
model := r.DataloggerModel
if r.DataloggerModel != r.Model {
model = strings.Join([]string{r.DataloggerModel, r.Model}, " ")
}
var found bool
for _, a := range assets {
if a.Model != model {
continue
}
if a.Serial != r.Serial {
continue
}
found = true
}
if !found {
t.Errorf("unable to find recorders asset: %s [%s]", model, r.Serial)
}
//.........這裏部分代碼省略.........
示例9: TestStationsProto
// TestStationsProto creates a Protobuf file of Stations.
func TestStationsProto(t *testing.T) {
var networks meta.NetworkList
if err := meta.LoadList("../network/networks.csv", &networks); err != nil {
t.Error(err)
}
var net = make(map[string]*delta.Network)
for _, v := range networks {
n := delta.Network{
Code: v.Code,
External: v.External,
Description: v.Description,
Restricted: v.Restricted,
}
net[v.Code] = &n
}
var stations meta.StationList
if err := meta.LoadList("../network/stations.csv", &stations); err != nil {
t.Error(err)
}
if len(stations) == 0 {
t.Error("zero length stations list.")
}
var s delta.Stations
s.Stations = make(map[string]*delta.Station)
for _, v := range stations {
pt := delta.Point{
Longitude: v.Longitude,
Latitude: v.Latitude,
Elevation: v.Elevation,
Datum: v.Datum,
}
sp := delta.Span{
Start: v.Start.Unix(),
End: v.End.Unix(),
}
st := delta.Station{
Code: v.Code,
Name: v.Name,
Network: net[v.Network],
Point: &pt,
Span: &sp,
}
s.Stations[st.Code] = &st
}
b, err := proto.Marshal(&s)
if err != nil {
t.Error(err)
}
t.Log(s)
if err := os.MkdirAll(apiDir, 0777); err != nil {
t.Error(err)
}
if err := ioutil.WriteFile(apiDir+"/stations.pb", b, 0644); err != nil {
t.Error(err)
}
}
示例10: TestMarksProto
// TestMarksProto creates protobuf and JSON files of Marks.
// These are pushed to S3 (by Travis) for use in api.geonet.org.nz
// Three files are created:
// marks.pb - fully hydrated protobuf will all GNSS Mark information.
// marks.json - JSON version of marks.pb (for use in browsers).
// marks.geojson - GeoJSON of Mark locations.
func TestMarksProto(t *testing.T) {
var networks meta.NetworkList
if err := meta.LoadList("../network/networks.csv", &networks); err != nil {
t.Error(err)
}
var net = make(map[string]*delta.Network)
for _, v := range networks {
n := delta.Network{
Code: v.Code,
External: v.External,
Description: v.Description,
Restricted: v.Restricted,
}
net[v.Code] = &n
}
var marks meta.MarkList
if err := meta.LoadList("../network/marks.csv", &marks); err != nil {
t.Error(err)
}
if len(marks) == 0 {
t.Error("zero length mark list.")
}
var m delta.Marks
m.Marks = make(map[string]*delta.Mark)
for _, v := range marks {
pt := delta.Point{
Longitude: v.Longitude,
Latitude: v.Latitude,
Elevation: v.Elevation,
Datum: v.Datum,
}
s := delta.Span{
Start: v.Start.Unix(),
End: v.End.Unix(),
}
mk := delta.Mark{
Code: v.Code,
Name: v.Name,
Network: net[v.Network],
Point: &pt,
Span: &s,
}
m.Marks[mk.Code] = &mk
}
var monuments meta.MonumentList
if err := meta.LoadList("../network/monuments.csv", &monuments); err != nil {
t.Error(err)
}
for _, v := range monuments {
s := delta.Span{
Start: v.Start.Unix(),
End: v.End.Unix(),
}
mn := delta.Monument{
DomesNumber: v.DomesNumber,
MarkType: v.MarkType,
Type: v.Type,
GroundRelationship: v.GroundRelationship,
FoundationType: v.FoundationType,
FoundationDepth: v.FoundationDepth,
Bedrock: v.Bedrock,
Geology: v.Geology,
Span: &s,
}
if _, ok := m.Marks[v.Mark]; ok {
m.Marks[v.Mark].Monument = &mn
}
}
var antennas meta.InstalledAntennaList
if err := meta.LoadList("../install/antennas.csv", &antennas); err != nil {
t.Error(err)
}
for _, v := range antennas {
e := delta.Equipment{
Make: v.Make,
Model: v.Model,
Serial: v.Serial,
//.........這裏部分代碼省略.........
示例11: TestSensors
func TestSensors(t *testing.T) {
var installed meta.InstalledSensorList
t.Log("Load installed sensors file")
{
if err := meta.LoadList("../install/sensors.csv", &installed); err != nil {
t.Fatal(err)
}
sort.Sort(installed)
}
t.Log("Check for missing sensors")
{
var sensors meta.AssetList
if err := meta.LoadList("../assets/sensors.csv", &sensors); err != nil {
t.Fatal(err)
}
sort.Sort(sensors)
for _, i := range installed {
n := sort.Search(len(sensors), func(j int) bool { return !sensors[j].Equipment.Less(i.Equipment) })
if n < 0 || i.Equipment.Less(sensors[n].Equipment) {
t.Errorf("unable to find sensor: %s", i.String())
}
}
}
t.Log("Check for sensor installation overlaps")
{
installs := make(map[string]meta.InstalledSensorList)
for _, s := range installed {
_, ok := installs[s.Model]
if ok {
installs[s.Model] = append(installs[s.Model], s)
} else {
installs[s.Model] = meta.InstalledSensorList{s}
}
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].Serial != v[j].Serial:
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("sensor %s/%s at %-5s has location %-2s overlap between %s and %s",
v[i].Model, v[i].Serial, v[i].Station, v[i].Location, v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
/*
t.Log("Check for missing sensor stations")
{
var stations meta.StationList
if err := meta.LoadList("../network/stations.csv", &stations); err != nil {
t.Fatal(err)
}
sort.Sort(stations)
for _, i := range installed {
n := sort.Search(len(stations), func(j int) bool { return !(stations[j].Code < i.StationCode) })
if n < 0 || i.StationCode != stations[n].Code {
t.Errorf("unable to find station: %s", i.StationCode)
} else {
if i.Start.Before(stations[n].Start) {
t.Errorf("installed sensor before station has been opened: %s: %s (%s %s)", i.String(), i.Start.String(), stations[n].Code, stations[n].Start.String())
}
if i.End.After(stations[n].End) {
t.Errorf("installed sensor after station has been closed: %s: %s (%s %s)", i.String(), i.End.String(), stations[n].Code, stations[n].End.String())
}
}
}
}
t.Log("Check for missing sensor sites")
{
var sites meta.SiteList
if err := meta.LoadList("../network/sites.csv", &sites); err != nil {
t.Fatal(err)
}
sort.Sort(sites)
//.........這裏部分代碼省略.........
示例12: TestReceivers
func TestReceivers(t *testing.T) {
var receivers meta.DeployedReceiverList
t.Log("Load deployed receivers file")
{
if err := meta.LoadList("../install/receivers.csv", &receivers); err != nil {
t.Fatal(err)
}
}
t.Log("Check for particular receiver installation overlaps")
{
installs := make(map[string]meta.DeployedReceiverList)
for _, s := range receivers {
if _, ok := installs[s.Model]; !ok {
installs[s.Model] = meta.DeployedReceiverList{}
}
installs[s.Model] = append(installs[s.Model], s)
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].Serial != v[j].Serial:
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("receiver %s [%s] at %s has overlap with %s between times %s and %s",
v[i].Model, v[i].Serial, v[i].Mark, v[j].Mark, v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
t.Log("Check for receiver sites installation equipment overlaps")
{
installs := make(map[string]meta.DeployedReceiverList)
for _, s := range receivers {
if _, ok := installs[s.Mark]; !ok {
installs[s.Mark] = meta.DeployedReceiverList{}
}
installs[s.Mark] = append(installs[s.Model], s)
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("receivers %s [%s] / %s [%s] at %s has overlap between %s and %s",
v[i].Model, v[i].Serial, v[j].Model, v[j].Serial, v[i].Mark, v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
t.Log("Check for missing receiver marks")
{
var marks meta.MarkList
if err := meta.LoadList("../network/marks.csv", &marks); err != nil {
t.Fatal(err)
}
keys := make(map[string]interface{})
for _, m := range marks {
keys[m.Code] = true
}
for _, r := range receivers {
if _, ok := keys[r.Mark]; ok {
continue
}
t.Errorf("unable to find receiver mark %-5s", r.Mark)
//.........這裏部分代碼省略.........
示例13: TestConnections
func TestConnections(t *testing.T) {
var connections meta.ConnectionList
t.Log("Load connections file")
if err := meta.LoadList("../install/connections.csv", &connections); err != nil {
t.Fatal(err)
}
for i := 0; i < len(connections); i++ {
for j := i + 1; j < len(connections); j++ {
if connections[i].Station != connections[j].Station {
continue
}
if connections[i].Location != connections[j].Location {
continue
}
if connections[i].Start.After(connections[j].End) {
continue
}
if connections[i].End.Before(connections[j].Start) {
continue
}
t.Errorf("connection overlap: " + strings.Join([]string{
connections[i].Station,
connections[i].Location,
connections[i].Start.String(),
connections[i].End.String(),
}, " "))
}
}
stas := make(map[string]meta.Station)
{
var list meta.StationList
t.Log("Load stations file")
if err := meta.LoadList("../network/stations.csv", &list); err != nil {
t.Fatal(err)
}
for _, s := range list {
stas[s.Code] = s
}
}
sites := make(map[string]map[string]meta.Site)
{
var list meta.SiteList
t.Log("Load sites file")
if err := meta.LoadList("../network/sites.csv", &list); err != nil {
t.Fatal(err)
}
for _, s := range list {
if _, ok := sites[s.Station]; !ok {
sites[s.Station] = make(map[string]meta.Site)
}
sites[s.Station][s.Location] = s
}
}
for _, c := range connections {
if _, ok := stas[c.Station]; !ok {
t.Log("unknown connection station: " + c.Station)
} else if s, ok := sites[c.Station]; !ok {
t.Log("unknown connection station: " + c.Station)
} else if _, ok := s[c.Location]; !ok {
t.Log("unknown connection station/location: " + c.Station + "/" + c.Location)
}
if c.Start.After(c.End) {
t.Log("connection span mismatch: " + strings.Join([]string{
c.Station,
c.Location,
c.Start.String(),
"after",
c.End.String(),
}, " "))
}
}
places := make(map[string]string)
{
var list meta.DeployedDataloggerList
t.Log("Load installed dataloggers file")
if err := meta.LoadList("../install/dataloggers.csv", &list); err != nil {
t.Fatal(err)
}
for _, d := range list {
if d.Role != "" {
places[d.Place+"/"+d.Role] = d.Place
} else {
places[d.Place] = d.Place
}
}
}
for _, c := range connections {
if c.Role != "" {
if _, ok := places[c.Place+"/"+c.Role]; !ok {
t.Log("warning: unknown datalogger place/role: " + c.Place + "/" + c.Role)
}
} else {
//.........這裏部分代碼省略.........
示例14: TestStreams
func TestStreams(t *testing.T) {
var streams meta.StreamList
t.Log("Load streams file")
if err := meta.LoadList("../install/streams.csv", &streams); err != nil {
t.Fatal(err)
}
for i := 0; i < len(streams); i++ {
for j := i + 1; j < len(streams); j++ {
if streams[i].Station != streams[j].Station {
continue
}
if streams[i].Location != streams[j].Location {
continue
}
if streams[i].Start.After(streams[j].End) {
continue
}
if streams[i].End.Before(streams[j].Start) {
continue
}
if streams[i].SamplingRate != streams[j].SamplingRate {
continue
}
t.Errorf("stream overlap: " + strings.Join([]string{
streams[i].Station,
streams[i].Location,
streams[i].Start.String(),
streams[i].End.String(),
}, " "))
}
}
stas := make(map[string]meta.Station)
{
var list meta.StationList
t.Log("Load stations file")
if err := meta.LoadList("../network/stations.csv", &list); err != nil {
t.Fatal(err)
}
for _, s := range list {
stas[s.Code] = s
}
}
sites := make(map[string]map[string]meta.Site)
{
var list meta.SiteList
t.Log("Load sites file")
if err := meta.LoadList("../network/sites.csv", &list); err != nil {
t.Fatal(err)
}
for _, s := range list {
if _, ok := sites[s.Station]; !ok {
sites[s.Station] = make(map[string]meta.Site)
}
sites[s.Station][s.Location] = s
}
}
for _, c := range streams {
if _, ok := stas[c.Station]; !ok {
t.Log("unknown stream station: " + c.Station)
} else if s, ok := sites[c.Station]; !ok {
t.Log("unknown stream station: " + c.Station)
} else if _, ok := s[c.Location]; !ok {
t.Log("unknown stream station/location: " + c.Station + "/" + c.Location)
}
if c.Start.After(c.End) {
t.Log("stream span mismatch: " + strings.Join([]string{
c.Station,
c.Location,
c.Start.String(),
"after",
c.End.String(),
}, " "))
}
}
}
示例15: TestAntennas
func TestAntennas(t *testing.T) {
var antennas meta.InstalledAntennaList
t.Log("Load deployed antennas file")
{
if err := meta.LoadList("../install/antennas.csv", &antennas); err != nil {
t.Fatal(err)
}
}
t.Log("Check for antenna installation equipment overlaps")
{
installs := make(map[string]meta.InstalledAntennaList)
for _, s := range antennas {
if _, ok := installs[s.Model]; !ok {
installs[s.Model] = meta.InstalledAntennaList{}
}
installs[s.Model] = append(installs[s.Model], s)
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].Serial != v[j].Serial:
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("antennas %s [%s] at %s has overlap at %s between %s and %s",
v[i].Model, v[i].Serial, v[i].Mark, v[j].Mark, v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
t.Log("Check for antenna installation mark overlaps")
{
installs := make(map[string]meta.InstalledAntennaList)
for _, s := range antennas {
if _, ok := installs[s.Mark]; !ok {
installs[s.Mark] = meta.InstalledAntennaList{}
}
installs[s.Mark] = append(installs[s.Mark], s)
}
var keys []string
for k, _ := range installs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := installs[k]
for i, n := 0, len(v); i < n; i++ {
for j := i + 1; j < n; j++ {
switch {
case v[i].End.Before(v[j].Start):
case v[i].Start.After(v[j].End):
case v[i].End.Equal(v[j].Start):
case v[i].Start.Equal(v[j].End):
default:
t.Errorf("antennas %s [%s] and %s [%s] at %s has overlap between %s and %s",
v[i].Model, v[i].Serial, v[j].Model, v[j].Serial, v[i].Mark,
v[i].Start.Format(meta.DateTimeFormat), v[i].End.Format(meta.DateTimeFormat))
}
}
}
}
}
t.Log("Check for missing antenna marks")
{
var marks meta.MarkList
if err := meta.LoadList("../network/marks.csv", &marks); err != nil {
t.Fatal(err)
}
keys := make(map[string]interface{})
for _, m := range marks {
keys[m.Code] = true
}
for _, c := range antennas {
if _, ok := keys[c.Mark]; ok {
continue
}
//.........這裏部分代碼省略.........