public void TestST3DShortestLine()
        {
            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 sline1 = db.Select(() => MeasurementFunctions.ST3DShortestLine(line, point)) as NTSGS.LineString;
                Assert.AreEqual(54.6993798867619, sline1.Coordinates[0].X, 1.0E-6);
                Assert.AreEqual(128.935022917228, sline1.Coordinates[0].Y, 1.0E-6);
                Assert.AreEqual(11.5475869506606, sline1.Coordinates[0].Z, 1.0E-9);
                Assert.AreEqual(100, sline1.Coordinates[1].X, 1.0E-6);
                Assert.AreEqual(100, sline1.Coordinates[1].Y, 1.0E-6);
                Assert.AreEqual(30, sline1.Coordinates[1].Z, 1.0E-9);

                var sline2 = db.Select(() => MeasurementFunctions.ST3DShortestLine(LineWkt, PointWkt)) as NTSGS.LineString;
                Assert.AreEqual(54.6993798867619, sline2.Coordinates[0].X, 1.0E-6);
                Assert.AreEqual(128.935022917228, sline2.Coordinates[0].Y, 1.0E-6);
                Assert.AreEqual(11.5475869506606, sline2.Coordinates[0].Z, 1.0E-9);
                Assert.AreEqual(100, sline2.Coordinates[1].X, 1.0E-6);
                Assert.AreEqual(100, sline2.Coordinates[1].Y, 1.0E-6);
                Assert.AreEqual(30, sline2.Coordinates[1].Z, 1.0E-9);

                Assert.IsNull(db.Select(() => MeasurementFunctions.ST3DShortestLine((NTSG)null, null)));
            }
        }
        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 TestSTMaxDistance()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                var pt   = db.Select(() => GeometryInput.STPointFromText("POINT(0 0)"));
                var line = db.Select(() => GeometryInput.STLineFromText("LINESTRING ( 2 2, 2 2 )"));

                var maxDistance1 = db.Select(() => MeasurementFunctions.STMaxDistance(pt, line));
                Assert.AreEqual(2.82842712474619, maxDistance1, 1.0E-9);
            }
        }
        public void TestST3DLongestLine()
        {
            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 lline1 = db.Select(() => MeasurementFunctions.ST3DLongestLine(line, pt).STAsEWKT());

                Assert.AreEqual("LINESTRING(50 75 1000,100 100 30)", lline1);
            }
        }
        public void TestST3DShortestLine()
        {
            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 sline1 = db.Select(() => MeasurementFunctions.ST3DShortestLine(line, pt).STAsEWKT());
                Assert.AreEqual("LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30)", sline1);

                Assert.IsNull(db.Select(() => MeasurementFunctions.ST3DShortestLine(null, null)));
            }
        }
        public void TestSTShortestLine()
        {
            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 sline1 = db.Select(() => MeasurementFunctions.STShortestLine(pt, line).STAsText());
                Assert.AreEqual("LINESTRING(100 100,73.0769230769231 115.384615384615)", sline1);

                Assert.IsNull(db.Select(() => MeasurementFunctions.STShortestLine(null, 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);
            }
        }
Exemplo n.º 9
0
        public void TestSTLineFromText()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string wkt1 = "LINESTRING (1 2, 3 4)";

                var g1 = db.Select(() => GeometryInput.STLineFromText(wkt1, SRID3857));

                Assert.AreEqual(wkt1, g1.AsText());
                Assert.AreEqual(SRID3857, g1.SRID);

                Assert.IsNull(db.Select(() => GeometryInput.STLineFromText("POINT(1 2)")));
                Assert.IsNull(db.Select(() => GeometryInput.STLineFromText(null)));
            }
        }
        public void TestST3DLongestLine()
        {
            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 lline1 = db.Select(() => MeasurementFunctions.ST3DLongestLine(line, point).STAsEWKT());

                Assert.AreEqual("LINESTRING(50 75 1000,100 100 30)", lline1);

                Assert.AreEqual(
                    "LINESTRING(50 75 1000,100 100 30)",
                    db.Select(() => MeasurementFunctions.ST3DLongestLine(LineWkt, PointWkt).STAsEWKT()));

                Assert.IsNull(db.Select(() => MeasurementFunctions.ST3DLongestLine((NTSG)null, (NTSG)null)));
            }
        }
        public void TestSTMaxDistance()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string PointWkt = "POINT(0 0)";
                const string LineWkt  = "LINESTRING (2 2, 2 2)";
                var          point    = db.Select(() => GeometryInput.STPointFromText(PointWkt));
                var          line     = db.Select(() => GeometryInput.STLineFromText(LineWkt));

                Assert.AreEqual(
                    2.82842712474619,
                    db.Select(() => MeasurementFunctions.STMaxDistance(point, line)).Value,
                    1.0E-9);

                Assert.AreEqual(
                    2.82842712474619,
                    db.Select(() => MeasurementFunctions.STMaxDistance(PointWkt, LineWkt)).Value,
                    1.0E-9);

                Assert.IsNull(db.Select(() => MeasurementFunctions.STMaxDistance((NTSG)null, (NTSG)null)));
            }
        }
        public void TestSTShortestLine()
        {
            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 sline1 = db.Select(() => MeasurementFunctions.STShortestLine(point, line)) as NTSGS.LineString;
                Assert.AreEqual(100, sline1.Coordinates[0].X, 1.0E-6);
                Assert.AreEqual(100, sline1.Coordinates[0].Y, 1.0E-6);
                Assert.AreEqual(73.0769230769231, sline1.Coordinates[1].X, 1.0E-9);
                Assert.AreEqual(115.384615384615, sline1.Coordinates[1].Y, 1.0E-9);

                var sline2 = db.Select(() => MeasurementFunctions.STShortestLine(PointWkt, LineWkt)) as NTSGS.LineString;
                Assert.AreEqual(100, sline2.Coordinates[0].X, 1.0E-6);
                Assert.AreEqual(100, sline2.Coordinates[0].Y, 1.0E-6);
                Assert.AreEqual(73.0769230769231, sline2.Coordinates[1].X, 1.0E-9);
                Assert.AreEqual(115.384615384615, sline2.Coordinates[1].Y, 1.0E-9);

                Assert.IsNull(db.Select(() => MeasurementFunctions.STShortestLine((NTSG)null, null)));
            }
        }
        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)));
            }
        }