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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions LinqToDBPostGisNetTopologySuite.Tests/MeasurementFunctionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NTSG = NetTopologySuite.Geometries.Geometry;

using LinqToDBPostGisNetTopologySuite.Tests.Entities;
using System;

namespace LinqToDBPostGisNetTopologySuite.Tests
{
Expand Down Expand Up @@ -606,6 +607,28 @@ public void TestST3DPerimeter()
}
}

[Test]
public void TestSTProject()
{
const string wkt = "POINT(0 0)";
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
{
var result1 = db.Select(() => MeasurementFunctions.STProject(GeometryInput.STGeomFromText(wkt),100000,(Math.PI/180.0)*45.0)) as NTSGS.Point;
var result2 = db.Select(() => MeasurementFunctions.STProject(wkt, 100000, (Math.PI / 180.0) * 45.0)) as NTSGS.Point;
var result3 = db.Select(() => MeasurementFunctions.STProject((NTSG)null, 100000, (Math.PI / 180.0) * 45.0)) as NTSGS.Point;

Assert.IsNotNull(result1);
Assert.AreEqual(0.635231029125537,result1.X,1.0E-5);
Assert.AreEqual(0.639472334729198,result1.Y,1.0E-5);

Assert.IsNotNull(result2);
Assert.AreEqual(0.635231029125537,result2.X,1.0E-5);
Assert.AreEqual(0.639472334729198,result2.Y,1.0E-5);

Assert.IsNull(result3);
}
}

[Test]
public void TestSTShortestLine()
{
Expand Down
32 changes: 31 additions & 1 deletion LinqToDBPostGisNetTopologySuite/MeasurementFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,37 @@ public static NTSG STMinimumClearanceLine(string geometry)
throw new InvalidOperationException();
}

// TODO: ST_Project(geography)
/// <summary>
/// Returns a point projected from a start point along a geodesic using a given distance and azimuth (bearing)
/// </summary>
/// <remarks>
/// See https://postgis.net/docs/ST_Project.html
/// </remarks>
/// <param name="geography">Input geography</param>
/// <param name="distance">Distance given in meters.Negative values are supported</param>
/// <param name="azimuth">Azimuth (bearing) given in radians, measured clockwise.Negative values and values greater than 2π (360 degrees) are supported</param>
/// <returns>Point projected</returns>
[Sql.Function("ST_Project", ServerSideOnly = true)]
public static NTSG STProject(this NTSG geography, double distance, double azimuth)
{
throw new InvalidOperationException();
}

/// <summary>
/// Returns a point projected from a start point along a geodesic using a given distance and azimuth (bearing)
/// </summary>
/// <remarks>
/// See https://postgis.net/docs/ST_Project.html
/// </remarks>
/// <param name="geography">Input geography</param>
/// <param name="distance">Distance given in meters.Negative values are supported</param>
/// <param name="azimuth">Azimuth (bearing) given in radians, measured clockwise.Negative values and values greater than 2π (360 degrees) are supported</param>
/// <returns>Point projected</returns>
[Sql.Function("ST_Project", ServerSideOnly = true)]
public static NTSG STProject(string geography, double distance, double azimuth)
{
throw new InvalidOperationException();
}

/// <summary>
/// Returns the 2D shortest line between two input geometries.
Expand Down