public void TestST3DClosestPoint() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { const string PointWkt = "POINT(100 100 30)"; const string LineWkt = "LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)"; var point = db.Select(() => GeometryInput.STPointFromText(PointWkt)); var line = db.Select(() => GeometryInput.STLineFromText(LineWkt)); var point1 = db.Select(() => MeasurementFunctions.ST3DClosestPoint(line, point)) as NTSGS.Point; var point2 = db.Select(() => MeasurementFunctions.STClosestPoint(line, point)) as NTSGS.Point; Assert.AreEqual(54.6993798867619, point1.X, 1.0E-9); Assert.AreEqual(128.935022917228, point1.Y, 1.0E-9); Assert.AreEqual(11.5475869506606, point1.Z, 1.0E-9); Assert.AreEqual(73.0769230769231, point2.X, 1.0E-9); Assert.AreEqual(115.384615384615, point2.Y, 1.0E-9); Assert.AreEqual( 54.6993798867619, db.Select(() => MeasurementFunctions.ST3DClosestPoint(LineWkt, PointWkt).STX()).Value, 1.0E-9); Assert.IsNull(db.Select(() => MeasurementFunctions.ST3DClosestPoint((NTSG)null, (NTSG)null))); } }
public void TestST3DClosestPoint() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var pt = db.Select(() => GeometryInput.STPointFromText("POINT(100 100 30)")); var line = db.Select(() => GeometryInput.STLineFromText("LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)")); var p1 = db.Select(() => MeasurementFunctions.ST3DClosestPoint(line, pt).STAsEWKT()); var p2 = db.Select(() => MeasurementFunctions.STClosestPoint(line, pt).STAsEWKT()); Assert.AreEqual("POINT(54.6993798867619 128.935022917228 11.5475869506606)", p1); Assert.AreEqual("POINT(73.0769230769231 115.384615384615)", p2); } }
public void TestSTClosestPoint() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var pt = db.Select(() => GeometryInput.STPointFromText("POINT(100 100)")); var line = db.Select(() => GeometryInput.STLineFromText("LINESTRING (20 80, 98 190, 110 180, 50 75)")); var p1 = db.Select(() => MeasurementFunctions.STClosestPoint(pt, line).STAsText()); var p2 = db.Select(() => MeasurementFunctions.STClosestPoint(line, pt).STAsText()); Assert.AreEqual("POINT(100 100)", p1); Assert.AreEqual("POINT(73.0769230769231 115.384615384615)", p2); } }
public void TestSTClosestPoint() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { const string PointWkt = "POINT(100 100)"; const string LineWkt = "LINESTRING (20 80, 98 190, 110 180, 50 75)"; var point = db.Select(() => GeometryInput.STPointFromText(PointWkt)); var line = db.Select(() => GeometryInput.STLineFromText(LineWkt)); var p1 = db.Select(() => MeasurementFunctions.STClosestPoint(point, line).STAsText()); var p2 = db.Select(() => MeasurementFunctions.STClosestPoint(line, point)) as NTSGS.Point; Assert.AreEqual("POINT(100 100)", p1); Assert.AreEqual(73.0769230769231, p2.X, 1.0E-9); Assert.AreEqual(115.384615384615, p2.Y, 1.0E-9); Assert.AreEqual( "POINT(100 100)", db.Select(() => MeasurementFunctions.STClosestPoint(PointWkt, LineWkt).STAsText())); Assert.IsNull(db.Select(() => MeasurementFunctions.STClosestPoint((NTSG)null, (NTSG)null))); } }