Example #1
0
        public void TestSTNumPoints()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt1 = "LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)";
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt1)).Insert();

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

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

                Assert.AreEqual(4, db.Select(() => GeometryAccessors.STNumPoints(Wkt1)));
                Assert.IsNull(db.Select(() => GeometryAccessors.STNumPoints(Wkt2)));
            }
        }