Exemplo n.º 1
0
        private void AssertNtsConsistentRelate(IShape shape)
        {
            IntersectionMatrix expectedM  = POLY_SHAPE.Geometry.Relate(((NtsSpatialContext)ctx).GetGeometryFrom(shape));
            SpatialRelation    expectedSR = NtsGeometry.IntersectionMatrixToSpatialRelation(expectedM);

            //NTS considers a point on a boundary INTERSECTS, not CONTAINS
            if (expectedSR == SpatialRelation.INTERSECTS && shape is Core.Shapes.IPoint)
            {
                expectedSR = SpatialRelation.CONTAINS;
            }
            AssertRelation(null, expectedSR, POLY_SHAPE, shape);

            if (ctx.IsGeo)
            {
                //shift shape, set to shape2
                IShape shape2;
                if (shape is IRectangle)
                {
                    IRectangle r = (IRectangle)shape;
                    shape2 = MakeNormRect(r.MinX + DL_SHIFT, r.MaxX + DL_SHIFT, r.MinY, r.MaxY);
                }
                else if (shape is Core.Shapes.IPoint)
                {
                    Core.Shapes.IPoint p = (Core.Shapes.IPoint)shape;
                    shape2 = ctx.MakePoint(base.NormX(p.X + DL_SHIFT), p.Y);
                }
                else
                {
                    throw new Exception("" + shape);
                }

                AssertRelation(null, expectedSR, POLY_SHAPE_DL, shape2);
            }
        }
Exemplo n.º 2
0
        private void assertJtsConsistentRelate(Shape shape)
        {
            IntersectionMatrix expectedM  = POLY_SHAPE.GetGeom().Relate(((NtsSpatialContext)ctx).GetGeometryFrom(shape));
            SpatialRelation    expectedSR = NtsGeometry.IntersectionMatrixToSpatialRelation(expectedM);

            //JTS considers a point on a boundary INTERSECTS, not CONTAINS
            if (expectedSR == SpatialRelation.INTERSECTS && shape is Point)
            {
                expectedSR = SpatialRelation.CONTAINS;
            }
            assertRelation(null, expectedSR, POLY_SHAPE, shape);

            if (TEST_DL_POLY && ctx.IsGeo())
            {
                //shift shape, set to shape2
                Shape shape2;
                if (shape is Rectangle)
                {
                    Rectangle r = (Rectangle)shape;
                    shape2 = makeNormRect(r.GetMinX() + DL_SHIFT, r.GetMaxX() + DL_SHIFT, r.GetMinY(), r.GetMaxY());
                    if (!TEST_DL_OTHER && shape2.GetBoundingBox().GetCrossesDateLine())
                    {
                        return;
                    }
                }
                else if (shape is Point)
                {
                    Point p = (Point)shape;
                    shape2 = ctx.MakePoint(normX(p.GetX() + DL_SHIFT), p.GetY());
                }
                else
                {
                    throw new Exception("" + shape);
                }

                assertRelation(null, expectedSR, POLY_SHAPE_DL, shape2);
            }
        }