Skip to content

Commit ab95ce3

Browse files
committed
Fixed Spatial Relationships methods return type (nullable bool)
1 parent df9c868 commit ab95ce3

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

LinqToDBPostGisNetTopologySuite.Tests/GeometryInputTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public void TestSTGeomFromText()
3939

4040
var ewkt2 = db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STAsEWKT()).Single();
4141
Assert.AreEqual("SRID=3857;POINT(100 250)", ewkt2);
42+
43+
db.TestGeometries.Value(g => g.Id, 3).Value(p => p.Geometry, () => null).Insert();
44+
var srid3 = db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STSrId()).Single();
45+
Assert.IsNull(srid3);
4246
}
4347
}
4448
}

LinqToDBPostGisNetTopologySuite.Tests/SpatialRelationshipsTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void Setup()
1919
}
2020

2121
[Test]
22-
public void TestSTCoversSTExteriorRing()
22+
public void TestSTContainsSTCoversSTExteriorRing()
2323
{
2424
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
2525
{
@@ -41,7 +41,11 @@ public void TestSTCoversSTExteriorRing()
4141
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STExteriorRing().STCoveredBy(bigc)).Single());
4242
Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STExteriorRing().STWithin(bigc)).Single());
4343

44+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STContains(null)).Single());
45+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STCovers(null)).Single());
46+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STCoveredBy(null)).Single());
4447
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STExteriorRing()).Single());
48+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STExteriorRing().STWithin(null)).Single());
4549
}
4650
}
4751

@@ -58,6 +62,7 @@ public void TestSTDisjoint()
5862
var point = new NTSG.Point(new NTSG.Coordinate(0, 0));
5963
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STDisjoint(point)).Single());
6064
Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STDisjoint(point)).Single());
65+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STDisjoint(null)).Single());
6166
}
6267
}
6368

@@ -74,6 +79,7 @@ public void TestSTEquals()
7479
var geometry2 = db.TestGeometries.Where(g => g.Id == 2).Single().Geometry;
7580
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STEquals(geometry2)).Single());
7681
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STReverse().STEquals(geometry2)).Single());
82+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STReverse().STEquals(null)).Single());
7783
}
7884
}
7985

@@ -89,11 +95,9 @@ public void TestSTIntersects()
8995

9096
var point = new NTSG.Point(new NTSG.Coordinate(0, 0));
9197

92-
var intersects1 = db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STIntersects(point)).Single();
93-
var intersects2 = db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIntersects(point)).Single();
94-
95-
Assert.IsFalse(intersects1);
96-
Assert.IsTrue(intersects2);
98+
Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STIntersects(point)).Single());
99+
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIntersects(point)).Single());
100+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIntersects(null)).Single());
97101
}
98102
}
99103

@@ -110,6 +114,7 @@ public void TestSTOrderingEquals()
110114
var geometry2 = db.TestGeometries.Single(g => g.Id == 2).Geometry;
111115
Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STOrderingEquals(geometry2)).Single());
112116
Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STReverse().STOrderingEquals(geometry2)).Single());
117+
Assert.IsNull(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STReverse().STOrderingEquals(null)).Single());
113118
}
114119
}
115120
}

LinqToDBPostGisNetTopologySuite/SpatialReferenceSystemFunctions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class SpatialReferenceSystemFunctions
2323
/// <param name="geometry">Input geometry</param>
2424
/// <returns>Spatial Reference System Identifier</returns>
2525
[Sql.Function("ST_SRID", ServerSideOnly = true)]
26-
public static int STSrId(this NTSG geometry)
26+
public static int? STSrId(this NTSG geometry)
2727
{
2828
throw new InvalidOperationException();
2929
}

LinqToDBPostGisNetTopologySuite/SpatialRelationships.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static class SpatialRelationships
2424
/// <param name="other">Input geometry 2</param>
2525
/// <returns>Is contains</returns>
2626
[Sql.Function("ST_Contains", ServerSideOnly = true)]
27-
public static bool STContains(this NTSG geometry, NTSG other)
27+
public static bool? STContains(this NTSG geometry, NTSG other)
2828
{
2929
throw new InvalidOperationException();
3030
}
@@ -39,7 +39,7 @@ public static bool STContains(this NTSG geometry, NTSG other)
3939
/// <param name="other">Input geometry 2</param>
4040
/// <returns>Is covers</returns>
4141
[Sql.Function("ST_Covers", ServerSideOnly = true)]
42-
public static bool STCovers(this NTSG geometry, NTSG other)
42+
public static bool? STCovers(this NTSG geometry, NTSG other)
4343
{
4444
throw new InvalidOperationException();
4545
}
@@ -54,7 +54,7 @@ public static bool STCovers(this NTSG geometry, NTSG other)
5454
/// <param name="other">Input geometry 2</param>
5555
/// <returns>Is covered by</returns>
5656
[Sql.Function("ST_CoveredBy", ServerSideOnly = true)]
57-
public static bool STCoveredBy(this NTSG geometry, NTSG other)
57+
public static bool? STCoveredBy(this NTSG geometry, NTSG other)
5858
{
5959
throw new InvalidOperationException();
6060
}
@@ -69,7 +69,7 @@ public static bool STCoveredBy(this NTSG geometry, NTSG other)
6969
/// <param name="other">Input geometry 2</param>
7070
/// <returns>Is crosses</returns>
7171
[Sql.Function("ST_Crosses", ServerSideOnly = true)]
72-
public static bool STCrosses(this NTSG geometry, NTSG other)
72+
public static bool? STCrosses(this NTSG geometry, NTSG other)
7373
{
7474
throw new InvalidOperationException();
7575
}
@@ -84,7 +84,7 @@ public static bool STCrosses(this NTSG geometry, NTSG other)
8484
/// <param name="other">Input geometry 2</param>
8585
/// <returns>Is disjoints</returns>
8686
[Sql.Function("ST_Disjoint", ServerSideOnly = true)]
87-
public static bool STDisjoint(this NTSG geometry, NTSG other)
87+
public static bool? STDisjoint(this NTSG geometry, NTSG other)
8888
{
8989
throw new InvalidOperationException();
9090
}
@@ -100,7 +100,7 @@ public static bool STDisjoint(this NTSG geometry, NTSG other)
100100
/// <param name="distance">Distance in units defined by the spatial reference system</param>
101101
/// <returns>Is geometries are within distance</returns>
102102
[Sql.Function("ST_DWithin", ServerSideOnly = true)]
103-
public static bool STDWithin(this NTSG geometry, NTSG other, double distance)
103+
public static bool? STDWithin(this NTSG geometry, NTSG other, double distance)
104104
{
105105
throw new InvalidOperationException();
106106
}
@@ -115,7 +115,7 @@ public static bool STDWithin(this NTSG geometry, NTSG other, double distance)
115115
/// <param name="other">Input geometry 2</param>
116116
/// <returns>Are spatially equal</returns>
117117
[Sql.Function("ST_Equals", ServerSideOnly = true)]
118-
public static bool STEquals(this NTSG geometry, NTSG other)
118+
public static bool? STEquals(this NTSG geometry, NTSG other)
119119
{
120120
throw new InvalidOperationException();
121121
}
@@ -130,7 +130,7 @@ public static bool STEquals(this NTSG geometry, NTSG other)
130130
/// <param name="other">Input geometry 2</param>
131131
/// <returns>Is intersects</returns>
132132
[Sql.Function("ST_Intersects", ServerSideOnly = true)]
133-
public static bool STIntersects(this NTSG geometry, NTSG other)
133+
public static bool? STIntersects(this NTSG geometry, NTSG other)
134134
{
135135
throw new InvalidOperationException();
136136
}
@@ -145,7 +145,7 @@ public static bool STIntersects(this NTSG geometry, NTSG other)
145145
/// <param name="other">Input geometry 2</param>
146146
/// <returns>Is equal and coordinates are in the same order</returns>
147147
[Sql.Function("ST_OrderingEquals", ServerSideOnly = true)]
148-
public static bool STOrderingEquals(this NTSG geometry, NTSG other)
148+
public static bool? STOrderingEquals(this NTSG geometry, NTSG other)
149149
{
150150
throw new InvalidOperationException();
151151
}
@@ -160,7 +160,7 @@ public static bool STOrderingEquals(this NTSG geometry, NTSG other)
160160
/// <param name="other">Input geometry 2</param>
161161
/// <returns>Is spatially overlap</returns>
162162
[Sql.Function("ST_Overlaps", ServerSideOnly = true)]
163-
public static bool STOverlaps(this NTSG geometry, NTSG other)
163+
public static bool? STOverlaps(this NTSG geometry, NTSG other)
164164
{
165165
throw new InvalidOperationException();
166166
}
@@ -175,7 +175,7 @@ public static bool STOverlaps(this NTSG geometry, NTSG other)
175175
/// <param name="other">Input geometry 2</param>
176176
/// <returns>Is touches</returns>
177177
[Sql.Function("ST_Touches", ServerSideOnly = true)]
178-
public static bool STTouches(this NTSG geometry, NTSG other)
178+
public static bool? STTouches(this NTSG geometry, NTSG other)
179179
{
180180
throw new InvalidOperationException();
181181
}
@@ -190,7 +190,7 @@ public static bool STTouches(this NTSG geometry, NTSG other)
190190
/// <param name="other">Input geometry 2</param>
191191
/// <returns>Is within</returns>
192192
[Sql.Function("ST_Within", ServerSideOnly = true)]
193-
public static bool STWithin(this NTSG geometry, NTSG other)
193+
public static bool? STWithin(this NTSG geometry, NTSG other)
194194
{
195195
throw new InvalidOperationException();
196196
}

0 commit comments

Comments
 (0)