Exemple #1
0
        public void TestSTGeneratePoints()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                var version = new Version(db.Select(() => VersionFunctions.PostGISLibVersion()));
                if (version >= new Version("3.0.0"))
                {
                    // TODO: Test for 2.3.0

                    var geom1 = db.Select(() => GeometryInput.STGeomFromText("POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))"));

                    var result1  = db.Select(() => GeometryProcessing.STGeneratePoints(geom1, 5, 1)) as NTSGS.MultiPoint;
                    var expected = new double[][]
                    {
                        new[] { 139.29283354478, 118.602516148805 },
                        new[] { 131.832615216622, 108.222468996999 },
                        new[] { 114.403606086077, 103.400350731553 },
                        new[] { 61.1688280123262, 67.8262881638229 },
                        new[] { 136.491955979797, 111.749696268158 },
                    };

                    Assert.AreEqual(expected.Length, result1.Coordinates.Length);
                    for (var i = 0; i < expected.Length; i++)
                    {
                        Assert.AreEqual(expected[i][0], result1.Coordinates[i].X, 1.0E-9);
                        Assert.AreEqual(expected[i][1], result1.Coordinates[i].Y, 1.0E-9);
                    }

                    Assert.IsNull(db.Select(() => GeometryProcessing.STGeneratePoints(null, 1)));
                }
            }
        }
        public void TestSTGeneratePoints()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                var geom1 = db.Select(() => GeometryInput.STGeomFromText("POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))"));

                var result1 = db.Select(() => GeometryProcessing.STGeneratePoints(geom1, 5, 1).STAsText());
                Assert.AreEqual("MULTIPOINT(139.29283354478 118.602516148805,131.832615216622 108.222468996999,114.403606086077 103.400350731553,61.1688280123262 67.8262881638229,136.491955979797 111.749696268158)", result1);

                Assert.IsNull(db.Select(() => GeometryProcessing.STGeneratePoints(null, 1)));
            }
        }