Пример #1
0
        public void CanDetermineContainsXY()
        {
            var ring1 = new List <Pnt3D>();

            ring1.Add(new Pnt3D(0, 0, 10));
            ring1.Add(new Pnt3D(0, 100, 20));
            ring1.Add(new Pnt3D(100, 100, 10));
            ring1.Add(new Pnt3D(50, 50, 10));
            ring1.Add(new Pnt3D(25, 75, 10));
            ring1.Add(new Pnt3D(0, 0, 10));

            Linestring l = new Linestring(ring1);

            Assert.IsFalse(GeomRelationUtils.PolycurveContainsXY(l, new Pnt3D(70, 50, 2), 0.001));
            Assert.IsFalse(GeomRelationUtils.PolycurveContainsXY(l, new Pnt3D(40, 50, 2), 0.001));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, new Pnt3D(50, 50, 2), 0.001));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, new Pnt3D(100, 100, 2), 0.001));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, new Pnt3D(0, 50, 2), 0.001));
        }
Пример #2
0
        public void CanGetContainsXY()
        {
            var ring1 = new List <Pnt3D>();

            ring1.Add(new Pnt3D(0, 0, 10));
            ring1.Add(new Pnt3D(0, 100, 20));
            ring1.Add(new Pnt3D(100, 100, 10));
            ring1.Add(new Pnt3D(50, 50, 10));
            ring1.Add(new Pnt3D(25, 75, 10));
            ring1.Add(new Pnt3D(0, 0, 10));

            Linestring l = new Linestring(ring1);

            double tolerance = 0.001;

            var pointOutsideRightOfCape = new Pnt3D(70, 50, 2);

            Assert.IsFalse(
                GeomRelationUtils.AreBoundsDisjoint(l, pointOutsideRightOfCape, tolerance));
            Assert.IsFalse(GeomRelationUtils.LinesContainXY(l, pointOutsideRightOfCape, tolerance));
            Assert.IsFalse(
                GeomRelationUtils.PolycurveContainsXY(l, pointOutsideRightOfCape, tolerance));

            Assert.AreEqual(
                false, GeomRelationUtils.AreaContainsXY(l, pointOutsideRightOfCape, tolerance));
            Assert.AreEqual(
                false,
                GeomRelationUtils.AreaContainsXY(l, pointOutsideRightOfCape, tolerance, true));

            var pointOutsideLeftOfCape = new Pnt3D(40, 50, 2);

            Assert.IsFalse(
                GeomRelationUtils.AreBoundsDisjoint(l, pointOutsideLeftOfCape, tolerance));
            Assert.IsFalse(GeomRelationUtils.LinesContainXY(l, pointOutsideLeftOfCape, tolerance));
            Assert.IsFalse(
                GeomRelationUtils.PolycurveContainsXY(l, pointOutsideLeftOfCape, tolerance));

            Assert.AreEqual(
                false, GeomRelationUtils.AreaContainsXY(l, pointOutsideLeftOfCape, tolerance));
            Assert.AreEqual(
                false,
                GeomRelationUtils.AreaContainsXY(l, pointOutsideLeftOfCape, tolerance, true));

            var pointInside = new Pnt3D(10, 90, 123);

            Assert.IsFalse(GeomRelationUtils.AreBoundsDisjoint(l, pointInside, tolerance));
            Assert.IsFalse(GeomRelationUtils.LinesContainXY(l, pointInside, tolerance));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, pointInside, tolerance));

            Assert.AreEqual(true, GeomRelationUtils.AreaContainsXY(l, pointInside, tolerance));
            Assert.AreEqual(
                true, GeomRelationUtils.AreaContainsXY(l, pointInside, tolerance, true));

            var pointOnTopRightCorner = new Pnt3D(100, 100, 2);

            Assert.IsFalse(
                GeomRelationUtils.AreBoundsDisjoint(l, pointOnTopRightCorner, tolerance));
            Assert.IsTrue(GeomRelationUtils.LinesContainXY(l, pointOnTopRightCorner, tolerance));
            Assert.IsTrue(
                GeomRelationUtils.PolycurveContainsXY(l, pointOnTopRightCorner, tolerance));
            Assert.AreEqual(
                null, GeomRelationUtils.AreaContainsXY(l, pointOnTopRightCorner, tolerance));
            Assert.AreEqual(
                null, GeomRelationUtils.AreaContainsXY(l, pointOnTopRightCorner, tolerance, true));

            var pointOnCape = new Pnt3D(50, 50, 321);

            Assert.IsFalse(GeomRelationUtils.AreBoundsDisjoint(l, pointOnCape, tolerance));
            Assert.IsTrue(GeomRelationUtils.LinesContainXY(l, pointOnCape, tolerance));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, pointOnCape, tolerance));
            Assert.AreEqual(null, GeomRelationUtils.AreaContainsXY(l, pointOnCape, tolerance));
            Assert.AreEqual(
                null, GeomRelationUtils.AreaContainsXY(l, pointOnCape, tolerance, true));

            var pointOnLeftEdge = new Pnt3D(0, 50, 2);

            Assert.IsFalse(GeomRelationUtils.AreBoundsDisjoint(l, pointOnLeftEdge, tolerance));
            Assert.IsTrue(GeomRelationUtils.LinesContainXY(l, pointOnLeftEdge, tolerance));
            Assert.IsTrue(GeomRelationUtils.PolycurveContainsXY(l, pointOnLeftEdge, tolerance));
            Assert.AreEqual(null, GeomRelationUtils.AreaContainsXY(l, pointOnLeftEdge, tolerance));
            Assert.AreEqual(
                null, GeomRelationUtils.AreaContainsXY(l, pointOnLeftEdge, tolerance, true));
        }