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

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

                Assert.AreEqual(
                    "POINT(0 1)",
                    db.TestGeometries
                    .Where(g => g.Id == 1)
                    .Select(g => g.Geometry.STStartPoint().STAsText())
                    .Single());

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

                Assert.AreEqual("POINT(0 1)", db.Select(() => GeometryAccessors.STStartPoint(Wkt1).STAsText()));
                Assert.IsNull(db.Select(() => GeometryAccessors.STStartPoint(Wkt2)));
                Assert.IsNull(db.Select(() => GeometryAccessors.STStartPoint((NTSG)null)));
            }
        }