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
39 changes: 39 additions & 0 deletions MEOS.NET.Tests/WrappedOutParameterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using MEOS.NET.Types;

namespace MEOS.NET.Tests
{
/// <summary>
/// Some values MEOS writes through a pointer to a pointer, saying whether the
/// value exists at all: the method answers the value as its own class, or
/// null.
/// </summary>
[TestClass]
public class WrappedOutParameterTests : MeosTest
{
[TestMethod]
public void AGeometrySetAnswersTheGeometryAtAnIndex()
{
GeomSet set = (GeomSet)GeomSet.In("{POINT(1 1), POINT(2 2)}")!;

Geo? first = set.ValueN(1);

Assert.IsNotNull(first);
Assert.AreEqual("POINT(1 1)", first!.AsText(6));
Assert.IsNull(set.ValueN(3));
}

[TestMethod]
public void ATemporalTextAnswersItsValueAtAMoment()
{
TText temp = (TText)TText.In("[AA@2024-12-06, AA@2024-12-08]")!;

Text? inside = temp.ValueAtTimestamptz(
new DateTime(2024, 12, 7, 0, 0, 0, DateTimeKind.Utc), true);

Assert.IsNotNull(inside);
Assert.AreEqual("AA", inside!.ToString());
Assert.IsNull(temp.ValueAtTimestamptz(
new DateTime(2024, 12, 9, 0, 0, 0, DateTimeKind.Utc), true));
}
}
}
18 changes: 18 additions & 0 deletions MEOS.NET/Types/CbufferSet.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ public string Out(int maxdd)
public Cbuffer? StartValue()
=> MEOSFactory.WrapCbuffer(Meos.CbuffersetStartValue(this.Ptr));

public Cbuffer? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.CbuffersetValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapCbuffer(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Cbuffer?[] Values()
=> MEOSFactory.WrapCbufferArray(Meos.CbuffersetValues(this.Ptr));

Expand Down
18 changes: 18 additions & 0 deletions MEOS.NET/Types/GeomSet.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ internal GeomSet(IntPtr ptr) : base(ptr) { }
public Geo? StartValue()
=> MEOSFactory.WrapGeo(Meos.GeosetStartValue(this.Ptr));

public Geo? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.GeosetValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapGeo(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Geo?[] Values()
=> MEOSFactory.WrapGeoArray(Meos.GeosetValues(this.Ptr));

Expand Down
18 changes: 18 additions & 0 deletions MEOS.NET/Types/NpointSet.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ public string Out(int maxdd)
public Npoint? StartValue()
=> MEOSFactory.WrapNpoint(Meos.NpointsetStartValue(this.Ptr));

public Npoint? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.NpointsetValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapNpoint(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Npoint?[] Values()
=> MEOSFactory.WrapNpointArray(Meos.NpointsetValues(this.Ptr));

Expand Down
18 changes: 18 additions & 0 deletions MEOS.NET/Types/PoseSet.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ public string Out(int maxdd)
public Pose? StartValue()
=> MEOSFactory.WrapPose(Meos.PosesetStartValue(this.Ptr));

public Pose? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.PosesetValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapPose(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Pose?[] Values()
=> MEOSFactory.WrapPoseArray(Meos.PosesetValues(this.Ptr));

Expand Down
36 changes: 36 additions & 0 deletions MEOS.NET/Types/TCbuffer.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,42 @@ internal TCbuffer(IntPtr ptr) : base(ptr) { }
public Geo? TraversedArea(bool unary_union)
=> MEOSFactory.WrapGeo(Meos.TcbufferTraversedArea(this.Ptr, unary_union));

public Cbuffer? ValueAtTimestamptz(DateTime t, bool strict)
{
IntPtr _value = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TcbufferValueAtTimestamptz(this.Ptr, MEOSConvert.ToTimestampTz(t), strict, _value))
{
return null;
}

return MEOSFactory.WrapCbuffer(Marshal.ReadIntPtr(_value));
}
finally
{
Marshal.FreeHGlobal(_value);
}
}

public Cbuffer? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TcbufferValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapCbuffer(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Cbuffer?[] Values()
=> MEOSFactory.WrapCbufferArray(Meos.TcbufferValues(this.Ptr));

Expand Down
36 changes: 36 additions & 0 deletions MEOS.NET/Types/TGeo.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ internal TGeo(IntPtr ptr) : base(ptr) { }
public Geo? TraversedArea(bool unary_union)
=> MEOSFactory.WrapGeo(Meos.TgeoTraversedArea(this.Ptr, unary_union));

public Geo? ValueAtTimestamptz(DateTime t, bool strict)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TgeoValueAtTimestamptz(this.Ptr, MEOSConvert.ToTimestampTz(t), strict, _result))
{
return null;
}

return MEOSFactory.WrapGeo(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Geo? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TgeoValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapGeo(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Geo?[] Values()
=> MEOSFactory.WrapGeoArray(Meos.TgeoValues(this.Ptr));

Expand Down
36 changes: 36 additions & 0 deletions MEOS.NET/Types/TJsonb.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,42 @@ public string Out()
public Temporal? ToTtext()
=> MEOSFactory.WrapTemporal(Meos.TjsonbToTtext(this.Ptr));

public Jsonb? ValueAtTimestamptz(DateTime t, bool strict)
{
IntPtr _value = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TjsonbValueAtTimestamptz(this.Ptr, MEOSConvert.ToTimestampTz(t), strict, _value))
{
return null;
}

return MEOSFactory.WrapJsonb(Marshal.ReadIntPtr(_value));
}
finally
{
Marshal.FreeHGlobal(_value);
}
}

public Jsonb? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TjsonbValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapJsonb(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Jsonb?[] Values()
=> MEOSFactory.WrapJsonbArray(Meos.TjsonbValues(this.Ptr));

Expand Down
36 changes: 36 additions & 0 deletions MEOS.NET/Types/TNpoint.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,42 @@ public long Route()
public Geo? Twcentroid()
=> MEOSFactory.WrapGeo(Meos.TnpointTwcentroid(this.Ptr));

public Npoint? ValueAtTimestamptz(DateTime t, bool strict)
{
IntPtr _value = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TnpointValueAtTimestamptz(this.Ptr, MEOSConvert.ToTimestampTz(t), strict, _value))
{
return null;
}

return MEOSFactory.WrapNpoint(Marshal.ReadIntPtr(_value));
}
finally
{
Marshal.FreeHGlobal(_value);
}
}

public Npoint? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TnpointValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapNpoint(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Npoint?[] Values()
=> MEOSFactory.WrapNpointArray(Meos.TnpointValues(this.Ptr));

Expand Down
18 changes: 18 additions & 0 deletions MEOS.NET/Types/TPoint.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ public double Length()
public Temporal? Speed()
=> MEOSFactory.WrapTemporal(Meos.TpointSpeed(this.Ptr));

public Geo? TfloatToGeomeas(Temporal measure, bool segmentize)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TpointTfloatToGeomeas(this.Ptr, measure.Ptr, segmentize, _result))
{
return null;
}

return MEOSFactory.WrapGeo(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Geo? Trajectory(bool unary_union)
=> MEOSFactory.WrapGeo(Meos.TpointTrajectory(this.Ptr, unary_union));

Expand Down
36 changes: 36 additions & 0 deletions MEOS.NET/Types/TPose.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@ public string AsGeoposeStreamElement(Temporal inst, int precision)
public Geo? Trajectory()
=> MEOSFactory.WrapGeo(Meos.TposeTrajectory(this.Ptr));

public Pose? ValueAtTimestamptz(DateTime t, bool strict)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TposeValueAtTimestamptz(this.Ptr, MEOSConvert.ToTimestampTz(t), strict, _result))
{
return null;
}

return MEOSFactory.WrapPose(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Pose? ValueN(int n)
{
IntPtr _result = Marshal.AllocHGlobal(8);
try
{
if (!Meos.TposeValueN(this.Ptr, n, _result))
{
return null;
}

return MEOSFactory.WrapPose(Marshal.ReadIntPtr(_result));
}
finally
{
Marshal.FreeHGlobal(_result);
}
}

public Pose?[] Values()
=> MEOSFactory.WrapPoseArray(Meos.TposeValues(this.Ptr));

Expand Down
Loading
Loading