Beispiel #1
0
        public IntersectResult LineContains(CoordinateRectangle line)
        {
            var iLeftTop     = PointContains(line.LeftTop) != IntersectResult.None;
            var iRightBottom = PointContains(line.RightBottom) != IntersectResult.None;

            if (iLeftTop && iRightBottom)
            {
                return(IntersectResult.Contains);
            }
            if (iLeftTop || iRightBottom)
            {
                return(IntersectResult.Intersects);
            }
            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Left, Top, Right, Top), line))
            {
                return(IntersectResult.Intersects);
            }
            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Right, Top, Right, Bottom), line))
            {
                return(IntersectResult.Intersects);
            }
            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Left, Bottom, Right, Bottom), line))
            {
                return(IntersectResult.Intersects);
            }
            if (MapUtilities.CheckLinesIntersection(new CoordinateRectangle(Left, Top, Left, Bottom), line))
            {
                return(IntersectResult.Intersects);
            }
            return(IntersectResult.None);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public bool Add(GeomCoordinate coordinate)
        {
            if (Count > 2)
            {
                var line1 = new CoordinateRectangle(First, coordinate);
                var line2 = new CoordinateRectangle(Last, coordinate);
                for (var i = 0; i < Count - 1; i++)
                {
                    if (MapUtilities.CheckLinesIntersection(this[i], line1) ||
                        MapUtilities.CheckLinesIntersection(this[i], line2))
                    {
                        return(false);
                    }
                }
            }

            Coordinates.Add(coordinate);
            return(true);
        }