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
45 changes: 45 additions & 0 deletions LinqToDBPostGisNetTopologySuite.Tests/SpatialRelationshipsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,51 @@ public void TestSTOrderingEquals()
}
}

[Test]
public void TestSTPointInsideCircle()
{
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
{
const string point1 = "POINT(1 1)";
const string point2 = "POINT(100 100)";

const double circleX = 1.0;
const double circleY = 1.0;

db.TestGeometries
.Value(g => g.Id, 1)
.Value(g => g.Geometry, () => GeometryInput.STGeomFromText(point1))
.Insert();
db.TestGeometries
.Value(g => g.Id, 2)
.Value(g => g.Geometry, () => GeometryInput.STGeomFromText(point2))
.Insert();
var result1 = db.TestGeometries.Where(t => t.Id == 1)
.Select(t => t.Geometry)
.Select(g => g.STPointInsideCircle(circleX, circleY, 11))
.Single();

var result2 = db.TestGeometries.Where(t => t.Id == 2)
.Select(t => t.Geometry)
.Select(g => g.STPointInsideCircle(circleX, circleY, 11))
.Single();

Assert.NotNull(result1);
Assert.NotNull(result2);

Assert.AreEqual(true, result1);
Assert.AreEqual(false, result2);

var result3 = db
.TestGeometries.Where(t => t.Id == 3)
.Select(t => t.Geometry)
.Select(g => g.STPointInsideCircle(circleX,circleY,11))
.FirstOrDefault();

Assert.IsNull(result3);
}
}

[Test]
public void TestST3DDWithin()
{
Expand Down
17 changes: 17 additions & 0 deletions LinqToDBPostGisNetTopologySuite/SpatialRelationships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ public static class SpatialRelationships
throw new InvalidOperationException();
}

/// <summary>
/// Returns true if the geometry is a point and is inside the circle. Returns false otherwise
/// </summary>
/// <remarks>
/// See https://postgis.net/docs/manual-3.0/ST_PointInsideCircle.html
/// </remarks>
/// <param name="geometry">Input point geometry</param>
/// <param name="centerX">Input circle x</param>
/// <param name="centerY">Input circle y</param>
/// <param name="radius">Radius of circle</param>
/// <returns>Is this point inside the circle</returns>
[Sql.Function("ST_PointInsideCircle", ServerSideOnly = true)]
public static bool? STPointInsideCircle(this NTSG geometry, double centerX, double centerY, double radius)
{
throw new InvalidOperationException();
}

/// <summary>
/// Returns true if the only points in common between geometry 1 and geometry 2 lie in the union of the boundaries of geometry 1 and geometry 2.
/// </summary>
Expand Down