Skip to content

Commit f794ac0

Browse files
committed
Code cleanup of GeometryEditors class
1 parent ab681e3 commit f794ac0

File tree

8 files changed

+938
-632
lines changed

8 files changed

+938
-632
lines changed

LinqToDBPostGisNetTopologySuite.Tests/GeometryEditorsTests.cs

Lines changed: 367 additions & 131 deletions
Large diffs are not rendered by default.

LinqToDBPostGisNetTopologySuite.Tests/GeometryInputTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public void TestSTGeomFromText()
9595
db.TestGeometries.Value(g => g.Id, 3).Value(p => p.Geometry, () => null).Insert();
9696
var srid3 = db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STSrId()).Single();
9797
Assert.IsNull(srid3);
98+
99+
// TODO: EMPTY geometry issue was fixed in NetTopologySuite >= 5.0.5
100+
////var pointEmpty = db.Select(() => GeometryInput.STGeomFromText("POINT EMPTY"));
101+
////var polygonEmpty = db.Select(() => GeometryInput.STGeomFromText("POLYGON EMPTY"));
98102
}
99103
}
100104

@@ -378,10 +382,10 @@ public void TestSTPointFromGeoHash()
378382
{
379383
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
380384
{
381-
const string Geohash = "9qqj7nmxncgyy4d0dbxqz0";
382-
db.TestGeometries.Value(g => g.Id, 1).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(Geohash)).Insert();
383-
db.TestGeometries.Value(g => g.Id, 2).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(Geohash, 4)).Insert();
384-
db.TestGeometries.Value(g => g.Id, 3).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(Geohash, 10)).Insert();
385+
const string GeoHash = "9qqj7nmxncgyy4d0dbxqz0";
386+
db.TestGeometries.Value(g => g.Id, 1).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(GeoHash)).Insert();
387+
db.TestGeometries.Value(g => g.Id, 2).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(GeoHash, 4)).Insert();
388+
db.TestGeometries.Value(g => g.Id, 3).Value(p => p.Geometry, () => GeometryInput.STPointFromGeoHash(GeoHash, 10)).Insert();
385389

386390
var point1 = db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry).Single() as NTSGS.Point;
387391
Assert.AreEqual(-115.172816, point1.X, 1.0E-6);

LinqToDBPostGisNetTopologySuite.Tests/GeometryProcessingTests.cs

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,6 @@ public void TestSTConvexHull()
8585
}
8686
}
8787

88-
[Test]
89-
public void TestSTCurveToLine()
90-
{
91-
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
92-
{
93-
const string wkt1 = "CIRCULARSTRING(0 0,100 -100,200 0)";
94-
db.TestGeometries
95-
.Value(g => g.Id, 1)
96-
.Value(p => p.Geometry, () => GeometryInput.STGeomFromText(wkt1))
97-
.Insert();
98-
99-
var result1 = db.TestGeometries
100-
.Where(g => g.Id == 1)
101-
.Select(g => g.Geometry.STCurveToLine(20, 1, 1))
102-
.Single() as NTSGS.LineString;
103-
104-
Assert.AreEqual(0, result1.Coordinates[0].X);
105-
Assert.AreEqual(0, result1.Coordinates[0].Y);
106-
Assert.AreEqual(50, result1.Coordinates[1].X, 1.0E-9);
107-
Assert.AreEqual(-86.6025403784438, result1.Coordinates[1].Y, 1.0E-9);
108-
Assert.AreEqual(150, result1.Coordinates[2].X, 1.0E-9);
109-
Assert.AreEqual(-86.6025403784439, result1.Coordinates[2].Y, 1.0E-9);
110-
Assert.AreEqual(200, result1.Coordinates[3].X, 1.0E-9);
111-
Assert.AreEqual(0, result1.Coordinates[3].Y, 1.0E-9);
112-
113-
Assert.IsNull(db.Select(() => GeometryProcessing.STCurveToLine(null, 20, 1, 1)));
114-
}
115-
}
116-
11788
[Test]
11889
public void TestSTDelaunayTriangles()
11990
{
@@ -146,20 +117,6 @@ public void TestSTDifference()
146117
}
147118
}
148119

149-
[Test]
150-
public void TestSTFlipCoordinates()
151-
{
152-
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
153-
{
154-
var geom1 = db.Select(() => GeometryInput.STGeomFromText("POINT(1 2)"));
155-
156-
var result1 = db.Select(() => GeometryProcessing.STFlipCoordinates(geom1).STAsText());
157-
Assert.AreEqual("POINT(2 1)", result1);
158-
159-
Assert.IsNull(db.Select(() => GeometryProcessing.STFlipCoordinates(null)));
160-
}
161-
}
162-
163120
[Test]
164121
public void TestSTGeneratePoints()
165122
{
@@ -206,28 +163,6 @@ public void TestSTGeometricMedian()
206163
}
207164
}
208165

209-
[Test]
210-
public void TestSTLineToCurve()
211-
{
212-
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
213-
{
214-
const string wkt = "POINT(1 3)";
215-
db.TestGeometries
216-
.Value(g => g.Id, 1)
217-
.Value(p => p.Geometry, () =>
218-
GeometryInput.STGeomFromText(wkt).STBuffer(3.0))
219-
.Insert();
220-
221-
// NTS error: 'Geometry type not recognized. GeometryCode: 10'
222-
var curvePolygon = db.TestGeometries
223-
.Where(g => g.Id == 1)
224-
.Select(g => g.Geometry.STLineToCurve().STAsText())
225-
.Single();
226-
227-
Assert.AreEqual("CURVEPOLYGON(CIRCULARSTRING(4 3,-2 2.99999999999999,4 3))", curvePolygon);
228-
}
229-
}
230-
231166
[Test]
232167
public void TestSTMakeValid()
233168
{
@@ -358,8 +293,8 @@ public void TestSTOffsetCurve()
358293
{
359294
const string wkt = @"LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
360295
44 16,24 16,20 16,18 16,17 17,
361-
16 18,16 20,16 40,16 60,16 80,16 100,
362-
16 120,16 140,16 160,16 180,16 195)";
296+
16 18,16 20,16 40,16 60,16 80,16 100,
297+
16 120,16 140,16 160,16 180,16 195)";
363298
db.TestGeometries
364299
.Value(g => g.Id, 1)
365300
.Value(p => p.Geometry, () => GeometryInput.STGeomFromText(wkt))
@@ -411,26 +346,6 @@ public void TestSTPointOnSurface()
411346
}
412347
}
413348

414-
[Test]
415-
public void TestSTRemoveRepeatedPoints()
416-
{
417-
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
418-
{
419-
const string wkt = "LINESTRING(0 5, 0 0, 0 0, 0 10)";
420-
db.TestGeometries
421-
.Value(g => g.Id, 1)
422-
.Value(p => p.Geometry, () => GeometryInput.STGeomFromText(wkt))
423-
.Insert();
424-
425-
var result = db.TestGeometries
426-
.Where(g => g.Id == 1)
427-
.Select(g => g.Geometry.STRemoveRepeatedPoints(1).AsText())
428-
.Single();
429-
430-
Assert.AreEqual("LINESTRING (0 5, 0 0, 0 10)", result);
431-
}
432-
}
433-
434349
[Test]
435350
public void TestSTSharedPaths()
436351
{
@@ -456,40 +371,6 @@ public void TestSTSharedPaths()
456371
}
457372
}
458373

459-
[Test]
460-
public void TestSTShiftLongitude()
461-
{
462-
using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
463-
{
464-
const string Ewkt1 = "SRID=4326;POINT(-118.58 38.38 10)";
465-
const string Ewkt2 = "SRID=4326;POINT(241.42 38.38 10)";
466-
db.TestGeometries
467-
.Value(g => g.Id, 1)
468-
.Value(p => p.Geometry, () => GeometryInput.STGeomFromEWKT(Ewkt1))
469-
.Insert();
470-
db.TestGeometries
471-
.Value(g => g.Id, 2)
472-
.Value(p => p.Geometry, () => GeometryInput.STGeomFromEWKT(Ewkt2))
473-
.Insert();
474-
475-
var result1 = db.TestGeometries
476-
.Where(g => g.Id == 1)
477-
.Select(g => g.Geometry.STShiftLongitude())
478-
.Single() as NTSGS.Point;
479-
480-
var result2 = db.TestGeometries
481-
.Where(g => g.Id == 2)
482-
.Select(g => g.Geometry.STShiftLongitude())
483-
.Single() as NTSGS.Point;
484-
485-
Assert.AreEqual(241.42, result1.X, 1.0E-2);
486-
Assert.AreEqual(38.38, result1.Y, 1.0E-2);
487-
488-
Assert.AreEqual(-118.58, result2.X, 1.0E-2);
489-
Assert.AreEqual(38.38, result2.Y, 1.0E-2);
490-
}
491-
}
492-
493374
[Test]
494375
public void TestSTSimplify()
495376
{

0 commit comments

Comments
 (0)