Ejemplo n.º 1
0
        public void TestSTZmflag()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt1 = "LINESTRING(1 2, 3 4)";
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT(Wkt1)).Insert();

                const string Wkt2 = "LINESTRINGM(1 2 3, 3 4 3)";
                db.TestGeometries.Value(g => g.Id, 2).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT(Wkt2)).Insert();

                const string Wkt3 = "CIRCULARSTRING(1 2 3, 3 4 3, 5 6 3)";
                db.TestGeometries.Value(g => g.Id, 3).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT(Wkt3)).Insert();

                const string Wkt4 = "POINT(1 2 3 4)";
                db.TestGeometries.Value(g => g.Id, 4).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT(Wkt4)).Insert();
                db.TestGeometries.Value(g => g.Id, 5).Value(g => g.Geometry, () => null).Insert();

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

                Assert.AreEqual(0, db.Select(() => GeometryAccessors.STZmflag(Wkt1)));
                Assert.AreEqual(1, db.Select(() => GeometryAccessors.STZmflag(Wkt2)));
                Assert.AreEqual(2, db.Select(() => GeometryAccessors.STZmflag(Wkt3)));
                Assert.AreEqual(3, db.Select(() => GeometryAccessors.STZmflag(Wkt4)));
                Assert.IsNull(db.TestGeometries.Where(g => g.Id == 5).Select(g => g.Geometry.STZmflag()).Single());
            }
        }