示例#1
0
            protected override /*ShapeCollection*/ IShape GenerateRandomShape(IPoint nearP)
            {
                //testLog.log("Break on nearP.toString(): {}", nearP);
                List <IShape> shapes = new List <IShape>();
                int           count  = random.Next(1, 4 + 1);

                for (int i = 0; i < count; i++)
                {
                    //1st 2 are near nearP, the others are anywhere
                    shapes.Add(RandomRectangle(i < 2 ? nearP : null));
                }
                ShapeCollection shapeCollection = new ShapeCollection/*<Rectangle>*/ (shapes, ctx);

                //test shapeCollection.getBoundingBox();
                IRectangle msBbox = shapeCollection.BoundingBox;

                if (shapes.Count == 1)
                {
                    Assert.Equal(shapes[0], msBbox.BoundingBox);
                }
                else
                {
                    foreach (IRectangle shape in shapes)
                    {
                        AssertRelation("bbox contains shape", SpatialRelation.CONTAINS, msBbox, shape);
                    }
                }
                return(shapeCollection);
            }
示例#2
0
        private void ValidateWorld(double r1MinX, double r1MaxX, double r2MinX, double r2MaxX)
        {
            ctx = SpatialContext.GEO;
            IRectangle r1 = ctx.MakeRectangle(r1MinX, r1MaxX, -10, 10);
            IRectangle r2 = ctx.MakeRectangle(r2MinX, r2MaxX, -10, 10);

            ShapeCollection /*<Rectangle>*/ s = new ShapeCollection/*<Rectangle>*/ (new IShape[] { r1, r2 }, ctx);

            Assert.Equal(Range.LongitudeRange.WORLD_180E180W, new Range.LongitudeRange(s.BoundingBox));

            //flip r1, r2 order
            s = new ShapeCollection/*<Rectangle>*/ (new IShape[] { r2, r1 }, ctx);
            Assert.Equal(Range.LongitudeRange.WORLD_180E180W, new Range.LongitudeRange(s.BoundingBox));
        }