Exemple #1
0
        public void TestSTIsSimple()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt1 = "POLYGON((1 1, 2 1, 2 2, 1 1))";
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt1)).Insert();

                const string Wkt2 = "LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)";
                db.TestGeometries.Value(g => g.Id, 2).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt2)).Insert();
                db.TestGeometries.Value(g => g.Id, 3).Value(g => g.Geometry, () => null).Insert();

                Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STIsSimple()).Single());
                Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIsSimple()).Single());
                Assert.IsNull(db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STIsSimple()).Single());

                Assert.IsNull(db.Select(() => GeometryAccessors.STIsSimple((NTSG)null)));
                Assert.IsTrue(db.Select(() => GeometryAccessors.STIsSimple(Wkt1)));
                Assert.IsFalse(db.Select(() => GeometryAccessors.STIsSimple(Wkt2)));
            }
        }