Example #1
0
        public void TestSTEnvelope()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt = "LINESTRING(0 0, 1 3)";
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt))
                .Insert();

                var envelope = db.TestGeometries
                               .Where(g => g.Id == 1)
                               .Select(g => g.Geometry.STEnvelope().STAsText())
                               .Single();
                Assert.AreEqual("POLYGON((0 0,0 3,1 3,1 0,0 0))", envelope);

                // TODO: need explicit cast text to geometry
                if (this.CurrentVersion >= new Version("3.0.0"))
                {
                    Assert.AreEqual(
                        "POLYGON((0 0,0 3,1 3,1 0,0 0))",
                        db.Select(() => GeometryAccessors.STEnvelope(Wkt).STAsText()));

                    Assert.IsNull(db.Select(() => GeometryAccessors.STEnvelope((NTSG)null)));
                }
            }
        }