Esempio n. 1
0
        public void GeoCompositeRegion_Empty()
        {
            // Verify that empty regions don't barf.

            var comp = new GeoCompositeRegion(new GeoRegion[0]);

            Assert.IsFalse(comp.Contains(0, 0));
            Assert.IsFalse(comp.Contains(10, 10));
        }
Esempio n. 2
0
        public void GeoCompositeRegion_Additive()
        {
            GeoCompositeRegion comp;

            // Create a composite region of two disjoint rectangles.

            comp = new GeoCompositeRegion(
                new GeoRegion[] {
                new GeoRectangle(30, 30, 0, 0),
                new GeoRectangle(30, -30, 0, -60)
            });

            Assert.IsTrue(comp.Contains(15, -45));
            Assert.IsTrue(comp.Contains(15, 15));

            Assert.IsFalse(comp.Contains(15, -15));
            Assert.IsFalse(comp.Contains(45, 15));
            Assert.IsFalse(comp.Contains(-15, -45));

            // Create a composite region of two overlapping rectangles.

            comp = new GeoCompositeRegion(
                new GeoRegion[] {
                new GeoRectangle(30, 30, 0, 0),
                new GeoRectangle(15, 15, -15, -15)
            });

            Assert.IsTrue(comp.Contains(15, 15));
            Assert.IsTrue(comp.Contains(0, 0));

            Assert.IsFalse(comp.Contains(20, -5));
            Assert.IsFalse(comp.Contains(-5, 20));
            Assert.IsFalse(comp.Contains(0, -20));

            // Create a composite region with an additive subregion that's also composite.

            comp = new GeoCompositeRegion(
                new GeoRegion[] {
                new GeoCircle(80, 80, 10, GeoHelper.EarthRadiusMiles),
                new GeoCompositeRegion(
                    new GeoRegion[] {
                    new GeoRectangle(30, 30, 0, 0),
                    new GeoRectangle(30, -30, 0, -60)
                })
            });

            Assert.IsTrue(comp.Contains(80, 80));
            Assert.IsTrue(comp.Contains(15, -45));
            Assert.IsTrue(comp.Contains(15, 15));

            Assert.IsFalse(comp.Contains(15, -15));
            Assert.IsFalse(comp.Contains(45, 15));
            Assert.IsFalse(comp.Contains(-15, -45));
        }
Esempio n. 3
0
        public void GeoCompositeRegion_Subtractive()
        {
            GeoCompositeRegion comp;

            // Create a composite region by making a rectangular hole in
            // the middle of a rectangle.

            comp = new GeoCompositeRegion(
                new GeoRegion[] {
                new GeoRectangle(30, 30, -30, -30)
            },
                new GeoRegion[] {
                new GeoRectangle(15, 15, -15, -15)
            });

            Assert.IsFalse(comp.Contains(0, 0));
            Assert.IsTrue(comp.Contains(20, 0));
            Assert.IsTrue(comp.Contains(0, 20));
            Assert.IsTrue(comp.Contains(-20, 0));
            Assert.IsTrue(comp.Contains(0, -20));
        }