Exemplo n.º 1
0
        public void TestSTNRings()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt = "POLYGON((1 2, 3 4, 5 6, 1 2))";
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt))
                .Insert();

                db.TestGeometries
                .Value(g => g.Id, 2)
                .Value(g => g.Geometry, () => null)
                .Insert();

                Assert.AreEqual(1, db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STNRings()).Single());
                Assert.AreEqual(0, db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STNumInteriorRings()).Single());
                Assert.AreEqual(0, db.Select(() => GeometryAccessors.STNumInteriorRings(Wkt)));

                // STNumInteriorRing is synonym to STNumInteriorRings. See http://postgis.net/docs/manual-1.5/ST_NumInteriorRing.html
                Assert.AreEqual(0, db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STNumInteriorRing()).Single());
                Assert.IsNull(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STNRings()).Single());

                Assert.IsNull(db.Select(() => GeometryAccessors.STNRings((NTSG)null)));
                Assert.AreEqual(1, db.Select(() => GeometryAccessors.STNRings(Wkt)));
                Assert.AreEqual(0, db.Select(() => GeometryAccessors.STNumInteriorRing(Wkt)));
            }
        }