This repository was archived by the owner on Nov 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRes1DQuery.cs
78 lines (63 loc) · 2.66 KB
/
Res1DQuery.cs
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
using System.Collections.Generic;
using System.Linq;
namespace DHI.Res1DReader
{
/// <summary>
/// Create query for specific quantity in res1d file.
/// </summary>
public abstract class Res1DQuery
{
public string Quantity, Res1DFileKey, Type, Name;
public List<string> Ids { get; }
protected Res1DQuery(string res1DFileKey, IEnumerable<string> ids, string quantity, string type)
{
Ids = ids.ToList();
Quantity = quantity;
Res1DFileKey = res1DFileKey;
Type = type;
}
protected Res1DQuery(string res1DFileKey, string id, string quantity, string type) : this(res1DFileKey, new[] { id }, quantity, type) { }
public abstract Res1DData GetData(Res1DReader res1D);
public override string ToString()
{
return Res1DFileKey + Type + Quantity;
}
}
public class Res1DQueryReach : Res1DQuery
{
public bool? AtFromNode;
public Res1DQueryReach(string res1DFileKey, IEnumerable<string> ids, string quantity, bool? atFromNode = null)
: base(res1DFileKey, ids, quantity, "Reach")
{
AtFromNode = atFromNode;
}
public Res1DQueryReach(IEnumerable<string> ids, string quantity, bool? atFromNode = null)
: this("res1d", ids, quantity, atFromNode) { }
public override Res1DData GetData(Res1DReader res1D)
{
return new Res1DData(Ids, Ids.Select(id => res1D.GetReach(id, Quantity, AtFromNode, Res1DFileKey)));
}
public override string ToString()
{
return Res1DFileKey + Type + Quantity + AtFromNode;
}
}
public class Res1DQueryNode : Res1DQuery
{
public Res1DQueryNode(string res1DFileKey, IEnumerable<string> ids, string quantity) : base(res1DFileKey, ids, quantity, "Node") { }
public Res1DQueryNode(IEnumerable<string> ids, string quantity) : this("res1d", ids, quantity) { }
public override Res1DData GetData(Res1DReader res1D)
{
return new Res1DData(Ids, Ids.Select(id => res1D.GetNode(id, Quantity, Res1DFileKey)));
}
}
public class Res1DQueryCatchment : Res1DQuery
{
public Res1DQueryCatchment(string res1DFileKey, IEnumerable<string> ids, string quantity) : base(res1DFileKey, ids, quantity, "Catchment") { }
public Res1DQueryCatchment(IEnumerable<string> ids, string quantity) : this("res1d", ids, quantity) { }
public override Res1DData GetData(Res1DReader res1D)
{
return new Res1DData(Ids, Ids.Select(id => res1D.GetCatchment(id, Quantity, Res1DFileKey)));
}
}
}