Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: python3 tools/objectgen.py "${{ steps.provision.outputs.catalog-path }}" --report

- name: Report binding drift
run: git --no-pager diff --stat -- MEOS.NET/Functions MEOS.NET/Types/Generated || true
run: git --no-pager diff --stat -- MEOS.NET/Functions MEOS.NET/Types || true

- name: Build solution
run: dotnet build MEOS.NET.sln -c Release
Expand Down
111 changes: 48 additions & 63 deletions ExampleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,48 @@
using MEOS.NET.Exceptions;
using MEOS.NET.Lifecycle;
using MEOS.NET.Types.Collections;
using MEOS.NET.Types.Collections.Float;
using MEOS.NET.Types.Temporal.Number.Float;

var timezone = "UTC";
MEOSLifecycle.Initialize(timezone);

try
{
Console.WriteLine("Creating temporal float instant with string : \"25.0@2024-12-06\"");
var tfi = TemporalFloatInstant.FromString("25.0@2024-12-06");
Console.WriteLine($"Temporal Float Instant To String : {tfi}");
Console.WriteLine($"Temporal Float Instant Timestamp : {tfi.Timestamp().ToLongDateString()}");
Console.WriteLine($"Temporal Float Instant HexWKB : {tfi.BoundingBox().ToHexWKB()}");
Console.WriteLine($"Temporal Float Instant Max Time: {tfi.BoundingBox().MaxT()}");
Console.WriteLine($"Temporal Float Instant always 25.0 ? : {tfi.IsAlwaysEqualTo(25)}\n\n");


Console.WriteLine("Creating temporal float instant from current date (UTC), with value 26");
var tfi2 = TemporalFloatInstant.FromTimestamp(DateTime.UtcNow, 26);
Console.WriteLine($"Temporal Float Instant To String : {tfi2}");
Console.WriteLine($"Temporal Float Instant Timestamp : {tfi2.Timestamp().ToLongDateString()}");
Console.WriteLine($"Temporal Float Instant HexWKB : {tfi2.BoundingBox().ToHexWKB()}");
Console.WriteLine($"Temporal Float Instant Max Time: {tfi2.BoundingBox().MaxT()}");
Console.WriteLine($"Temporal Float Instant always less than 30.0 ? : {tfi2.IsAlwaysLessThanOrEqualTo(30)}");
Console.WriteLine("Adding 34 to value of instant...");
var tfi3 = tfi2.Add(34);
Console.WriteLine($"Temporal Float Instant (after addition) To String : {tfi3}");
Console.WriteLine($"Temporal Float Instant (after addition) always less than 30.0 ? : {tfi3.IsAlwaysLessThanOrEqualTo(30)}\n\n"); // Should be false since we used "Add"

Console.WriteLine("Creating float spanset with string \"{[8, 10], [11, 12]}\"");
var spanSet = FloatSpanSet.FromString("{[8, 10], [11, 12]}");
Console.WriteLine("Dividing into spans...");
var spans = spanSet.GetSpans();
Console.WriteLine($"There are {spans.Count()} spans.");
var bytes = spanSet.ToBytes();
Console.WriteLine($"Bytes of the spanset : ");
foreach (var b in bytes)
{
Console.Write(b + ", ");
}
Console.WriteLine("\n\n");

Console.WriteLine("Creating a new float spanset2 from the bytes of the preceding one");
var spanSetRecreated = SpanSet.FromBytes(bytes);
Console.WriteLine($"Are the two spansets equal ? : {spanSetRecreated == spanSet}");
Console.WriteLine("Dividing spanset2 into spans again...");
var spans2 = spanSetRecreated.GetSpans();
Console.WriteLine($"There are {spans2.Count()} spans in spanset2 !\n\n");

Console.WriteLine("Trying creation of temporal float instant with erroneous string : \"e25.0@2024-12-06\"");
TemporalFloatInstant.FromString("e25.0@2024-12-06");
}
catch (MEOSException e)
{
Console.WriteLine($"An error occurred in MEOS : {e.Code} - {e.Message}");
}
finally
{
MEOSLifecycle.Terminate();
}
using MEOS.NET.Exceptions;
using MEOS.NET.Functions;
using MEOS.NET.Lifecycle;
using MEOS.NET.Types;

MEOSLifecycle.Initialize("UTC");

try
{
Console.WriteLine("Reading a temporal float instant from \"25.0@2024-12-06\"");
Temporal tfi = TFloat.In("25.0@2024-12-06")!;
Console.WriteLine($" class : {tfi.GetType().Name}");
Console.WriteLine($" text : {Meos.TfloatOut(tfi.Ptr, 15)}");
Console.WriteLine($" start timestamp : {tfi.StartTimestamptz():u}");
Console.WriteLine($" MF-JSON : {tfi.AsMFJSON(false, 0, 6, string.Empty)}");
Console.WriteLine($" always 25.0? : {Meos.AlwaysEqTfloatFloat(tfi.Ptr, 25.0) == 1}\n");

Console.WriteLine("Making one from a value and a moment");
Temporal made = TFloatInst.Make(26.0, DateTime.UtcNow)!;
Console.WriteLine($" text : {Meos.TfloatOut(made.Ptr, 15)}");
Console.WriteLine(" adding 34 to its value");
Temporal sum = MEOSFactory.WrapTemporal(Meos.AddTfloatFloat(made.Ptr, 34.0))!;
Console.WriteLine($" text : {Meos.TfloatOut(sum.Ptr, 15)}");
Console.WriteLine($" always <= 30.0? : {Meos.AlwaysLeTfloatFloat(sum.Ptr, 30.0) == 1}\n");

Console.WriteLine("Reading a float span set from \"{[8, 10], [11, 12]}\"");
SpanSet spanset = FloatSpanSet.In("{[8, 10], [11, 12]}")!;
Console.WriteLine($" class : {spanset.GetType().Name}");
Console.WriteLine($" spans : {spanset.NumSpans()}");
foreach (Span? span in spanset.Spanarr())
{
Console.WriteLine($" {((FloatSpan)span!).Out(15)}");
}

Console.WriteLine($" contains 9.0? : {Meos.ContainsSpansetFloat(spanset.Ptr, 9.0)}");
Console.WriteLine($" width : {((FloatSpanSet)spanset).Width(false)}\n");

Console.WriteLine("Reading a temporal float instant from \"e25.0@2024-12-06\"");
TFloat.In("e25.0@2024-12-06");
}
catch (MEOSException e)
{
Console.WriteLine($" MEOS reports {e.Code}: {e.Message}");
}
finally
{
MEOSLifecycle.Terminate();
}
25 changes: 16 additions & 9 deletions MEOS.NET.Tests/BorrowedStringTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MEOS.NET.Enums;
using MEOS.NET.Types.Temporal.Number.Float;
using MEOS.NET.Types;

namespace MEOS.NET.Tests
{
Expand All @@ -14,26 +13,34 @@ public class BorrowedStringTests : MeosTest
[TestMethod]
public void InterpolationOfALinearSequenceIsRead()
{
TemporalFloat temp = TemporalFloat.FromString("[25.0@2024-12-06, 27.0@2024-12-07]");
Temporal temp = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;

Assert.AreEqual(InterpolationType.Linear, temp.Interpolation());
Assert.AreEqual("Linear", temp.Interp());
}

[TestMethod]
public void InterpolationOfADiscreteSequenceIsRead()
{
TemporalFloat temp = TemporalFloat.FromString("{25.0@2024-12-06, 27.0@2024-12-07}");
Temporal temp = TFloat.In("{25.0@2024-12-06, 27.0@2024-12-07}")!;

Assert.AreEqual(InterpolationType.Discrete, temp.Interpolation());
Assert.AreEqual("Discrete", temp.Interp());
}

[TestMethod]
public void TheSameBorrowedNameIsReadableTwice()
{
TemporalFloat first = TemporalFloat.FromString("[25.0@2024-12-06, 27.0@2024-12-07]");
TemporalFloat second = TemporalFloat.FromString("[1.0@2024-12-06, 2.0@2024-12-07]");
Temporal first = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;
Temporal second = TFloat.In("[1.0@2024-12-06, 2.0@2024-12-07]")!;

Assert.AreEqual(first.Interpolation(), second.Interpolation());
Assert.AreEqual(first.Interp(), second.Interp());
}

[TestMethod]
public void SubtypeOfASequenceIsRead()
{
Temporal temp = TFloat.In("[25.0@2024-12-06, 27.0@2024-12-07]")!;

Assert.AreEqual("Sequence", temp.Subtype());
}
}
}
2 changes: 1 addition & 1 deletion MEOS.NET.Tests/GeneratedObjectLayerTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MEOS.NET.Exceptions;
using MEOS.NET.Types.Generated;
using MEOS.NET.Types;

namespace MEOS.NET.Tests
{
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.Native.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.CodeDom.Compiler;
using System.Runtime.InteropServices;

Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.hashtable.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_catalog.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_cbuffer.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_cellindex.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_geo.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_h3.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_internal.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_internal_geo.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_json.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_npoint.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_pointcloud.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_pose.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_quadbin.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_raster.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_rgeo.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.meos_s2cell.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pc_api.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_bool.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_date.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_float.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_int.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_interval.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_numeric.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_text.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_time.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pg_timestamp.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pgsql_compat.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
2 changes: 2 additions & 0 deletions MEOS.NET/Functions/Meos.pgtypes.g.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable enable

using System.Runtime.InteropServices;

namespace MEOS.NET.Functions
Expand Down
Loading
Loading