コード例 #1
0
        public IntersectResult RectangleContains(CoordinateRectangle rectangle)
        {
            var iLeftTop     = PointContains(rectangle.LeftTop) != IntersectResult.None;
            var iRightBottom = PointContains(rectangle.RightBottom) != IntersectResult.None;

            if (iLeftTop && iRightBottom)
            {
                return(IntersectResult.Contains);
            }
            if (iLeftTop || iRightBottom)
            {
                return(IntersectResult.Intersects);
            }

            if (PointContains(rectangle.LeftBottom) != IntersectResult.None)
            {
                return(IntersectResult.Intersects);
            }
            if (PointContains(rectangle.RightTop) != IntersectResult.None)
            {
                return(IntersectResult.Intersects);
            }

            iLeftTop     = rectangle.PointContains(LeftTop) != IntersectResult.None;
            iRightBottom = rectangle.PointContains(RightBottom) != IntersectResult.None;

            if (iLeftTop && iRightBottom)
            {
                return(IntersectResult.Supersets);
            }
            if (iLeftTop || iRightBottom)
            {
                return(IntersectResult.Intersects);
            }

            if (rectangle.PointContains(LeftBottom) != IntersectResult.None)
            {
                return(IntersectResult.Intersects);
            }
            if (rectangle.PointContains(RightTop) != IntersectResult.None)
            {
                return(IntersectResult.Intersects);
            }

            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Left, Top, Left, Bottom),
                                                    new CoordinateRectangle(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Top)))
            {
                return(IntersectResult.Intersects);
            }
            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Left, Top, Right, Top),
                                                    new CoordinateRectangle(rectangle.Left, rectangle.Top, rectangle.Left, rectangle.Bottom)))
            {
                return(IntersectResult.Intersects);
            }

            return(IntersectResult.None);
        }
コード例 #2
0
 public bool IncludeTo(CoordinateRectangle rect)
 {
     for (var i = 0; i < Coordinates.Count; i++)
     {
         if (rect.PointContains(Coordinates[i]) != IntersectResult.Contains)
         {
             return(false);
         }
     }
     return(true);
 }