コード例 #1
0
        public void ParseMultiLineString()
        {
            String          multiLinestring = "MULTILINESTRING ((10 10, 40 50), (20 20, 30 20), (20 20, 50 20, 50 60, 20 20))";
            MultiLineString geom            = Geometry.FromText(multiLinestring) as MultiLineString;

            Assert.IsNotNull(geom);
            Assert.AreEqual(3, geom.NumGeometries);
            Assert.AreEqual(180, geom.Length);
            Assert.AreEqual(120, geom[2].Length);
            Assert.IsFalse(geom[0].IsClosed, "[0].IsClosed");
            Assert.IsFalse(geom[1].IsClosed, "[1].IsClosed");
            Assert.IsTrue(geom[2].IsClosed, "[2].IsClosed");
            Assert.IsTrue(geom[0].IsSimple(), "[0].IsSimple");
            Assert.IsTrue(geom[1].IsSimple(), "[1].IsSimple");
            Assert.IsTrue(geom[2].IsSimple(), "[2].IsSimple");
            Assert.IsTrue(geom[2].IsRing, "Third line is a ring");
            Assert.AreEqual(multiLinestring, geom.AsText());
            Assert.IsTrue(Geometry.FromText("MULTILINESTRING EMPTY").IsEmpty());
            geom =
                Geometry.FromText(
                    "MULTILINESTRING ((10 10, 40 50), (20 20, 30 20), EMPTY, (20 20, 50 20, 50 60, 20 20))") as
                MultiLineString;
            Assert.IsNotNull(geom);
            Assert.IsTrue(geom[2].IsEmpty());
            Assert.AreEqual(4, geom.NumGeometries);
            Assert.AreEqual("MULTILINESTRING EMPTY", new MultiLineString().AsText());
        }