Ejemplo n.º 1
0
        public void TestSTNDims()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText("POINT(1 1)")).Insert();
                db.TestGeometries.Value(g => g.Id, 2).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("POINT(1 1 2)")).Insert();
                db.TestGeometries.Value(g => g.Id, 3).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("POINTM(1 1 0.5)")).Insert();
                db.TestGeometries.Value(g => g.Id, 4).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("POINTZM(1 2 3 4)")).Insert();
                db.TestGeometries.Value(g => g.Id, 5).Value(g => g.Geometry, () => null).Insert();

                Assert.AreEqual(2, db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STNDims()).Single());
                Assert.AreEqual(3, db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STNDims()).Single());
                Assert.AreEqual(3, db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STNDims()).Single());
                Assert.AreEqual(4, db.TestGeometries.Where(g => g.Id == 4).Select(g => g.Geometry.STNDims()).Single());

                Assert.IsNull(db.TestGeometries
                              .Where(g => g.Id == 5)
                              .Select(g => g.Geometry.STNDims())
                              .Single());

                Assert.AreEqual(4, db.Select(() => GeometryAccessors.STNDims("POINTZM(1 2 3 4)")));
            }
        }