Ejemplo n.º 1
0
        public void TestSTBoundary()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string wkt1 = "LINESTRING(100 150,50 60, 70 80, 160 170)";
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(wkt1))
                .Insert();

                const string wkt2 = "POLYGON ((10 130, 50 190, 110 190, 140 150, 150 80, 100 10, 20 40, 10 130), (70 40, 100 50, 120 80, 80 110, 50 90, 70 40))";
                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(wkt2))
                .Insert();

                const string wkt3 = "MULTILINESTRING((1 1 1,0 0 0.5, -1 1 1),(1 1 0.5,0 0 0.5, -1 1 0.5, 1 1 0.5) )";
                db.TestGeometries
                .Value(g => g.Id, 3)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(wkt3))
                .Insert();

                Assert.AreEqual(
                    "MULTIPOINT(100 150,160 170)",
                    db.TestGeometries
                    .Where(g => g.Id == 1)
                    .Select(g => g.Geometry.STBoundary().STAsText())
                    .Single());

                Assert.AreEqual(
                    "MULTILINESTRING((10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130),(70 40,100 50,120 80,80 110,50 90,70 40))",
                    db.TestGeometries
                    .Where(g => g.Id == 2)
                    .Select(g => g.Geometry.STBoundary().STAsText())
                    .Single());

                Assert.AreEqual(
                    "MULTIPOINT Z (-1 1 1,1 1 0.75)",
                    db.TestGeometries
                    .Where(g => g.Id == 3)
                    .Select(g => g.Geometry.STBoundary().STAsText())
                    .Single());

                Assert.IsNull(db.Select(() => GeometryAccessors.STBoundary((NTSG)null)));
                Assert.AreEqual("MULTIPOINT(100 150,160 170)", db.Select(() => GeometryAccessors.STBoundary(wkt1).STAsText()));
            }
        }