示例#1
0
        public void TestSTDimension()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string wkt1 = "GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))";
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(wkt1))
                .Insert();

                const string wkt2 = "POINT(0 0)";
                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(wkt2))
                .Insert();

                var dimension1 = db.TestGeometries
                                 .Where(g => g.Id == 1)
                                 .Select(g => g.Geometry.STDimension())
                                 .Single();
                Assert.AreEqual(1, dimension1);

                var dimension2 = db.TestGeometries
                                 .Where(g => g.Id == 2)
                                 .Select(g => g.Geometry.STDimension())
                                 .Single();
                Assert.AreEqual(0, dimension2);

                Assert.IsNull(db.Select(() => GeometryAccessors.STDimension((NTSG)null)));
                Assert.AreEqual(1, db.Select(() => GeometryAccessors.STDimension("GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))")));
            }
        }