Skip to content

Commit 10bcdb4

Browse files
Answer an array of MEOS values as the classes they are
MEOS returns many values two ways: an array of pointers (`Temporal **`, `TInstant **`) and an array of the values themselves, walked at the struct's own stride (`Span *`, `TBox *`, `STBox *`). Both reach the wrapper as an array of pointers, so both wrap element by element into the class each value's own header names, and the object layer answers `Span?[]`, `STBox?[]`, `Temporal?[]` where it answered nothing before. That is 29 more methods: `SpanSet.Spans`, `STBox.QuadSplit`, `Temporal.Instants`, the `bins` and `splitNSpans` families, 607 of the model's methods against 578. Three tests read them: the spans of a float span set come back as `FloatSpan` printing `[8, 10]` and `[11, 12]`, the four quadrants of an STBox come back as boxes, and the instants of a temporal float sequence come back as `TFloatInst`.
1 parent 7b0da8d commit 10bcdb4

17 files changed

Lines changed: 145 additions & 2 deletions

‎MEOS.NET.Tests/ValueArrayTests.cs‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using MEOS.NET.Types;
2+
3+
namespace MEOS.NET.Tests
4+
{
5+
/// <summary>
6+
/// A method that answers many MEOS values answers them as the classes their
7+
/// own headers name, whether MEOS returns an array of pointers or an array of
8+
/// the values themselves walked at the struct's stride.
9+
/// </summary>
10+
[TestClass]
11+
public class ValueArrayTests : MeosTest
12+
{
13+
[TestMethod]
14+
public void TheSpansOfASpanSetComeBackAsSpans()
15+
{
16+
SpanSet spanset = FloatSpanSet.In("{[8, 10], [11, 12]}")!;
17+
18+
Span?[] spans = spanset.Spans();
19+
20+
Assert.AreEqual(2, spans.Length);
21+
Assert.IsInstanceOfType(spans[0], typeof(FloatSpan));
22+
Assert.AreEqual("[8, 10]", spans[0]!.ToString());
23+
Assert.AreEqual("[11, 12]", spans[1]!.ToString());
24+
}
25+
26+
[TestMethod]
27+
public void TheQuadrantsOfABoxComeBackAsBoxes()
28+
{
29+
STBox box = STBox.In("STBOX X((0,0),(4,4))")!;
30+
31+
STBox?[] quadrants = box.QuadSplit();
32+
33+
Assert.AreEqual(4, quadrants.Length);
34+
foreach (STBox? quadrant in quadrants)
35+
{
36+
StringAssert.StartsWith(quadrant!.ToString(), "STBOX X(");
37+
}
38+
}
39+
40+
[TestMethod]
41+
public void TheInstantsOfASequenceComeBackAsTemporalValues()
42+
{
43+
Temporal temp = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;
44+
45+
Temporal?[] instants = temp.Instants();
46+
47+
Assert.AreEqual(2, instants.Length);
48+
Assert.IsInstanceOfType(instants[0], typeof(TFloatInst));
49+
Assert.AreEqual("25@2024-12-06 00:00:00+00", instants[0]!.ToString());
50+
}
51+
}
52+
}

‎MEOS.NET/Types/BigIntSpan.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal BigIntSpan(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out();
1717

18+
public Span?[] Bins(long vsize, long vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.BigintspanBins(this.Ptr, vsize, vorigin));
20+
1821
public Span? Expand(long value)
1922
=> MEOSFactory.WrapSpan(Meos.BigintspanExpand(this.Ptr, value));
2023

‎MEOS.NET/Types/BigIntSpanSet.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal BigIntSpanSet(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out();
1717

18+
public Span?[] Bins(long vsize, long vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.BigintspansetBins(this.Ptr, vsize, vorigin));
20+
1821
public long Lower()
1922
=> Meos.BigintspansetLower(this.Ptr);
2023

‎MEOS.NET/Types/FloatSpan.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal FloatSpan(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out(15);
1717

18+
public Span?[] Bins(double vsize, double vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.FloatspanBins(this.Ptr, vsize, vorigin));
20+
1821
public Span? Ceil()
1922
=> MEOSFactory.WrapSpan(Meos.FloatspanCeil(this.Ptr));
2023

‎MEOS.NET/Types/FloatSpanSet.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal FloatSpanSet(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out(15);
1717

18+
public Span?[] Bins(double vsize, double vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.FloatspansetBins(this.Ptr, vsize, vorigin));
20+
1821
public SpanSet? Ceil()
1922
=> MEOSFactory.WrapSpanSet(Meos.FloatspansetCeil(this.Ptr));
2023

‎MEOS.NET/Types/IntSpan.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal IntSpan(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out();
1717

18+
public Span?[] Bins(int vsize, int vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.IntspanBins(this.Ptr, vsize, vorigin));
20+
1821
public Span? Expand(int value)
1922
=> MEOSFactory.WrapSpan(Meos.IntspanExpand(this.Ptr, value));
2023

‎MEOS.NET/Types/IntSpanSet.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ internal IntSpanSet(IntPtr ptr) : base(ptr) { }
1515
public override string ToString()
1616
=> this.Out();
1717

18+
public Span?[] Bins(int vsize, int vorigin)
19+
=> MEOSFactory.WrapSpanArray(Meos.IntspansetBins(this.Ptr, vsize, vorigin));
20+
1821
public int Lower()
1922
=> Meos.IntspansetLower(this.Ptr);
2023

‎MEOS.NET/Types/STBox.g.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public string Out(int maxdd)
7272
public double Perimeter(bool spheroid)
7373
=> Meos.StboxPerimeter(this.Ptr, spheroid);
7474

75+
public STBox?[] QuadSplit()
76+
=> MEOSFactory.WrapSTBoxArray(Meos.StboxQuadSplit(this.Ptr));
77+
7578
public STBox? Round(int maxdd)
7679
=> MEOSFactory.WrapSTBox(Meos.StboxRound(this.Ptr, maxdd));
7780

‎MEOS.NET/Types/Set.g.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public int NumValues()
4747
public Set? Round(int maxdd)
4848
=> MEOSFactory.WrapSet(Meos.SetRound(this.Ptr, maxdd));
4949

50+
public Span?[] Spans()
51+
=> MEOSFactory.WrapSpanArray(Meos.SetSpans(this.Ptr));
52+
53+
public Span?[] SplitEachNSpans(int elems_per_span)
54+
=> MEOSFactory.WrapSpanArray(Meos.SetSplitEachNSpans(this.Ptr, elems_per_span));
55+
56+
public Span?[] SplitNSpans(int span_count)
57+
=> MEOSFactory.WrapSpanArray(Meos.SetSplitNSpans(this.Ptr, span_count));
58+
5059
public Span? ToSpan()
5160
=> MEOSFactory.WrapSpan(Meos.SetToSpan(this.Ptr));
5261

‎MEOS.NET/Types/SpanSet.g.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public int NumSpans()
5959
public Span?[] Spanarr()
6060
=> MEOSFactory.WrapSpanArray(Meos.SpansetSpanarr(this.Ptr));
6161

62+
public Span?[] Spans()
63+
=> MEOSFactory.WrapSpanArray(Meos.SpansetSpans(this.Ptr));
64+
65+
public Span?[] SplitEachNSpans(int elems_per_span)
66+
=> MEOSFactory.WrapSpanArray(Meos.SpansetSplitEachNSpans(this.Ptr, elems_per_span));
67+
68+
public Span?[] SplitNSpans(int span_count)
69+
=> MEOSFactory.WrapSpanArray(Meos.SpansetSplitNSpans(this.Ptr, span_count));
70+
6271
public Span? StartSpan()
6372
=> MEOSFactory.WrapSpan(Meos.SpansetStartSpan(this.Ptr));
6473

0 commit comments

Comments
 (0)