Exemplo n.º 1
0
        public void OutOfMemoryPolygon()
        {
            var wpfGeom = Geometry.Parse("M0,5 L0,15 10,15 10,5 0,5 M0,0 L15,15 M5,0 L5,10 15,10 15,0 5,0");

            WpfGeometryToImage(wpfGeom, "OutOfMemory.png");
            var reader = new WpfGeometryReader(Geometries.Geometry.DefaultFactory, true);

            IGeometry ntsGeom = null;

            Assert.DoesNotThrow(() => ntsGeom = reader.Read(wpfGeom));
            Debug.WriteLine(ntsGeom.AsText());
            var isValidOp = new Operation.Valid.IsValidOp(ntsGeom);

            if (!isValidOp.IsValid)
            {
                Assert.IsTrue(false, isValidOp.ValidationError.ToString());
            }

            Assert.AreEqual(wpfGeom.GetArea(), ntsGeom.Area, 1e-5);
        }
Exemplo n.º 2
0
        public void InvalidPolygon()
        {
            var wpfGeom = Geometry.Parse("M12.6206216812134, 50.9294242858887L11.5450315475464, 49.8538360595703 10.4694414138794, 50.9294242858887 11.5450315475464, 52.0050163269043 12.6206216812134, 50.9294242858887z M11.5870275497437, 55.99609375L10.0783662796021, 54.487434387207 8.56970500946045, 55.99609375 10.0783662796021, 57.5047569274902 11.5870275497437, 55.99609375z M5.77836227416992, 54.9871711730957L3.80277156829834, 56.962760925293 5.77836227416992, 58.9383506774902 7.7539529800415, 56.962760925293 5.77836227416992, 54.9871711730957z M5.51891326904297, 51.7981262207031L5.5027756690979, 51.99609375 6.71169662475586, 53.2050170898438 7.92061805725098, 51.99609375 6.74462604522705, 50.7876129150391 6.88728761672974, 50.0960960388184 5.14503145217896, 48.3538398742676 3.40277552604675, 50.0960960388184 5.14503145217896, 51.8383522033691 5.51891326904297, 51.7981262207031z M8.37836647033691, 45.7541007995605L6.53637409210205, 47.5960960388184 8.37836647033691, 49.4380874633789 10.2203578948975, 47.5960960388184 8.37836647033691, 45.7541007995605z M1.5868661403656, 45.6459007263184L1.5868661403656, 76.6044692993164 37.3742637634277, 76.6044692993164 37.3742637634277, 45.6459007263184 1.5868661403656, 45.6459007263184z");

            WpfGeometryToImage(wpfGeom, "InvalidPolygon.png");
            var reader = new WpfGeometryReader(Geometries.Geometry.DefaultFactory, true);

            IGeometry ntsGeom = null;

            Assert.DoesNotThrow(() => ntsGeom = reader.Read(wpfGeom));
            Debug.WriteLine(ntsGeom.AsText());
            var isValidOp = new Operation.Valid.IsValidOp(ntsGeom);

            if (!isValidOp.IsValid)
            {
                Assert.IsTrue(false, isValidOp.ValidationError.ToString());
            }

            Assert.AreEqual(wpfGeom.GetArea(), ntsGeom.Area, 1e-5);
        }