コード例 #1
0
        public void TestSimplifyBadPoly()
        {
            var geom = new WKTReader().Read("POLYGON ((1 1, 1 1, 1 1, 1 1, 1 1))");

            var geom2 = new Polygon(new LinearRing(new Coordinate[]
            {
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1),
                new Coordinate(1, 1)
            }));

            Debug.WriteLine("Bad polygon: " + geom);
            var simple = DouglasPeuckerSimplifier.Simplify(geom, 0.1);

            Debug.WriteLine("Simple bad polygon: " + simple);
            Assert.AreEqual(geom.GetType(), simple.GetType());
            Assert.AreNotEqual(geom, simple, "Simplify didn't do anything to this invalid polygon.");
            // This happens with JTS 1.9.0, 1.8.0 still returns GeometryCollection.Empty
            Assert.AreEqual(geom.GetType(), Polygon.Empty);
        }