Ejemplo n.º 1
0
        public void TestSTInteriorRingN()
        {
            const string Wkt = "POLYGON((0 0 1,0 5 1,5 0 1,0 0 1),(1 1 1,3 1 1,1 3 1,1 1 1))";

            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries
                .Value(g => g.Id, 1)
                .Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt))
                .Insert();

                var result = db.TestGeometries
                             .Where(g => g.Id == 1)
                             .Select(g => g.Geometry.STInteriorRingN(1))
                             .Single() as NTSGS.LineString;

                var result2 = db.TestGeometries
                              .Where(g => g.Id == 1)
                              .Select(g => GeometryAccessors.STInteriorRingN(g.Geometry.STAsText(), 1))
                              .Single() as NTSGS.LineString;

                var emptyResult = db.TestGeometries
                                  .Where(g => g.Id == 1)
                                  .Select(g => g.Geometry.STInteriorRingN(2))
                                  .Single() as NTSGS.LineString;

                Assert.IsNotNull(result);
                Assert.IsNull(emptyResult);

                Assert.AreEqual(1, result.Coordinates[0].X);
                Assert.AreEqual(1, result.Coordinates[0].Y);
                Assert.AreEqual(1, result.Coordinates[0].Z);

                Assert.AreEqual(3, result.Coordinates[1].X);
                Assert.AreEqual(1, result.Coordinates[1].Y);
                Assert.AreEqual(1, result.Coordinates[1].Z);

                Assert.AreEqual(1, result.Coordinates[2].X);
                Assert.AreEqual(3, result.Coordinates[2].Y);
                Assert.AreEqual(1, result.Coordinates[2].Z);

                Assert.AreEqual(1, result.Coordinates[3].X);
                Assert.AreEqual(1, result.Coordinates[3].Y);
                Assert.AreEqual(1, result.Coordinates[3].Z);

                Assert.IsTrue(result2.CompareTo(result) == 0);

                Assert.IsNull(db.Select(() => GeometryAccessors.STInteriorRingN((NTSG)null, 1)));
            }
        }