예제 #1
0
        public void TestSTIsEmpty()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt1 = "GEOMETRYCOLLECTION EMPTY";
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt1)).Insert();

                const string Wkt2 = "POLYGON((1 2, 3 4, 5 6, 1 2))";
                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.STIsEmpty()).Single());
                Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIsEmpty()).Single());
                Assert.IsNull(db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STIsEmpty()).Single());

                // TODO: Need some research for reason of error:
                // function st_isempty(unknown) is not unique. Could not choose a best candidate function. You might need to add explicit type casts.
                var version = new Version(db.Select(() => VersionFunctions.PostGISLibVersion()));
                if (version > new Version("3.0.0"))
                {
                    Assert.IsNull(db.Select(() => GeometryAccessors.STIsEmpty((NTSG)null)));
                    Assert.IsTrue(db.Select(() => GeometryAccessors.STIsEmpty("CIRCULARSTRING EMPTY")));
                    Assert.IsFalse(db.Select(() => GeometryAccessors.STIsEmpty("POINT(0 0)")));
                }
            }
        }