|
1 | 1 | package hazardproviders |
2 | 2 |
|
3 | | -import ( |
4 | | - "testing" |
5 | | - "time" |
6 | | - |
7 | | - "github.com/USACE/go-consequences/geography" |
8 | | - "github.com/USACE/go-consequences/hazards" |
9 | | -) |
10 | | - |
11 | | -func TestInitCSV(t *testing.T) { |
12 | | - file := "/workspaces/go-consequences/data/lifecycle/test_arrival-depth-duration_hazards.csv" |
13 | | - |
14 | | - expectedDepths := []float64{1.0, 1.0, 1.0, 2.0, 2.0} |
15 | | - expectedDurations := []float64{0.0, 5.0, 0.0, 0.0, 0.0} |
16 | | - et1 := time.Date(1984, time.Month(1), 1, 0, 0, 0, 0, time.UTC) |
17 | | - et2 := time.Date(1984, time.Month(1), 11, 0, 0, 0, 0, time.UTC) |
18 | | - et3 := time.Date(1984, time.Month(1), 21, 0, 0, 0, 0, time.UTC) |
19 | | - et4 := time.Date(1985, time.Month(1), 1, 0, 0, 0, 0, time.UTC) |
20 | | - et5 := time.Date(1985, time.Month(1), 11, 0, 0, 0, 0, time.UTC) |
21 | | - expectedArrivals := []time.Time{et1, et2, et3, et4, et5} |
22 | | - |
23 | | - b := geography.BBox{ |
24 | | - // xMin, yMin, xMax, yMax |
25 | | - Bbox: []float64{-71.1, 43, -71, 43.1}, |
26 | | - } |
27 | | - ADDMHP, err := InitCSV(file, b) |
28 | | - if err != nil { |
29 | | - panic(err) |
30 | | - } |
31 | | - defer ADDMHP.Close() |
32 | | - |
33 | | - loc := geography.Location{ |
34 | | - X: -71.05, |
35 | | - Y: 43.05, |
36 | | - SRID: "", |
37 | | - } |
38 | | - |
39 | | - haz, err := ADDMHP.Hazard(loc) |
40 | | - h := haz.(*hazards.ArrivalDepthandDurationEventMulti) |
41 | | - if err != nil { |
42 | | - panic(err) |
43 | | - } |
44 | | - |
45 | | - for { |
46 | | - edepth := expectedDepths[h.Index()] |
47 | | - edur := expectedDurations[h.Index()] |
48 | | - earr := expectedArrivals[h.Index()] |
49 | | - |
50 | | - if h.Depth() != edepth { |
51 | | - t.Errorf("Event at index %d had Depth = %v. Expected: %3.2f", h.Index(), h.Depth(), edepth) |
52 | | - } |
53 | | - if h.Duration() != edur { |
54 | | - t.Errorf("Event at index %d had Duration = %v. Expected: %3.2f", h.Index(), h.Duration(), edur) |
55 | | - } |
56 | | - if h.Depth() != edepth { |
57 | | - t.Errorf("Event at index %d had ArrivalTime = %v. Expected: %v", h.Index(), h.ArrivalTime(), earr) |
58 | | - } |
59 | | - |
60 | | - if h.HasNext() { |
61 | | - h.Increment() |
62 | | - } else { |
63 | | - break |
64 | | - } |
65 | | - } |
66 | | -} |
| 3 | +// func TestInitCSV(t *testing.T) { |
| 4 | +// file := "/workspaces/go-consequences/data/lifecycle/test_arrival-depth-duration_hazards.csv" |
| 5 | + |
| 6 | +// expectedDepths := []float64{1.0, 1.0, 1.0, 2.0, 2.0} |
| 7 | +// expectedDurations := []float64{0.0, 5.0, 0.0, 0.0, 0.0} |
| 8 | +// et1 := time.Date(1984, time.Month(1), 1, 0, 0, 0, 0, time.UTC) |
| 9 | +// et2 := time.Date(1984, time.Month(1), 11, 0, 0, 0, 0, time.UTC) |
| 10 | +// et3 := time.Date(1984, time.Month(1), 21, 0, 0, 0, 0, time.UTC) |
| 11 | +// et4 := time.Date(1985, time.Month(1), 1, 0, 0, 0, 0, time.UTC) |
| 12 | +// et5 := time.Date(1985, time.Month(1), 11, 0, 0, 0, 0, time.UTC) |
| 13 | +// expectedArrivals := []time.Time{et1, et2, et3, et4, et5} |
| 14 | + |
| 15 | +// b := geography.BBox{ |
| 16 | +// // xMin, yMin, xMax, yMax |
| 17 | +// Bbox: []float64{-71.1, 43, -71, 43.1}, |
| 18 | +// } |
| 19 | +// ADDMHP, err := InitCSV(file, b) |
| 20 | +// if err != nil { |
| 21 | +// panic(err) |
| 22 | +// } |
| 23 | +// defer ADDMHP.Close() |
| 24 | + |
| 25 | +// loc := geography.Location{ |
| 26 | +// X: -71.05, |
| 27 | +// Y: 43.05, |
| 28 | +// SRID: "", |
| 29 | +// } |
| 30 | + |
| 31 | +// haz, err := ADDMHP.Hazard(loc) |
| 32 | +// h := haz.(*hazards.ArrivalDepthandDurationEventMulti) |
| 33 | +// if err != nil { |
| 34 | +// panic(err) |
| 35 | +// } |
| 36 | + |
| 37 | +// for { |
| 38 | +// edepth := expectedDepths[h.Index()] |
| 39 | +// edur := expectedDurations[h.Index()] |
| 40 | +// earr := expectedArrivals[h.Index()] |
| 41 | + |
| 42 | +// if h.Depth() != edepth { |
| 43 | +// t.Errorf("Event at index %d had Depth = %v. Expected: %3.2f", h.Index(), h.Depth(), edepth) |
| 44 | +// } |
| 45 | +// if h.Duration() != edur { |
| 46 | +// t.Errorf("Event at index %d had Duration = %v. Expected: %3.2f", h.Index(), h.Duration(), edur) |
| 47 | +// } |
| 48 | +// if h.Depth() != edepth { |
| 49 | +// t.Errorf("Event at index %d had ArrivalTime = %v. Expected: %v", h.Index(), h.ArrivalTime(), earr) |
| 50 | +// } |
| 51 | + |
| 52 | +// if h.HasNext() { |
| 53 | +// h.Increment() |
| 54 | +// } else { |
| 55 | +// break |
| 56 | +// } |
| 57 | +// } |
| 58 | +// } |
0 commit comments