Exemplo n.º 1
0
        public InterseptResult LineContains(CoordinateRectangle line)
        {
            var iLeftTop     = PointContains(line.LeftTop) != InterseptResult.None;
            var iRightBottom = PointContains(line.RightBottom) != InterseptResult.None;

            if (iLeftTop && iRightBottom)
            {
                return(InterseptResult.Contains);
            }
            if (iLeftTop || iRightBottom)
            {
                return(InterseptResult.Intersepts);
            }
            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Left, Top, Right, Top), line))
            {
                return(InterseptResult.Intersepts);
            }
            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Right, Top, Right, Bottom), line))
            {
                return(InterseptResult.Intersepts);
            }
            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Left, Bottom, Right, Bottom), line))
            {
                return(InterseptResult.Intersepts);
            }
            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Left, Top, Left, Bottom), line))
            {
                return(InterseptResult.Intersepts);
            }
            return(InterseptResult.None);
        }
Exemplo n.º 2
0
        public InterseptResult RectangleContains(CoordinateRectangle rectangle)
        {
            var iLeftTop     = PointContains(rectangle.LeftTop) != InterseptResult.None;
            var iRightBottom = PointContains(rectangle.RightBottom) != InterseptResult.None;

            if (iLeftTop && iRightBottom)
            {
                return(InterseptResult.Contains);
            }
            if (iLeftTop || iRightBottom)
            {
                return(InterseptResult.Intersepts);
            }

            if (PointContains(rectangle.LeftBottom) != InterseptResult.None)
            {
                return(InterseptResult.Intersepts);
            }
            if (PointContains(rectangle.RightTop) != InterseptResult.None)
            {
                return(InterseptResult.Intersepts);
            }

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

            if (iLeftTop && iRightBottom)
            {
                return(InterseptResult.Supersets);
            }
            if (iLeftTop || iRightBottom)
            {
                return(InterseptResult.Intersepts);
            }

            if (rectangle.PointContains(LeftBottom) != InterseptResult.None)
            {
                return(InterseptResult.Intersepts);
            }
            if (rectangle.PointContains(RightTop) != InterseptResult.None)
            {
                return(InterseptResult.Intersepts);
            }

            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Left, Top, Left, Bottom),
                                                          new CoordinateRectangle(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Top)))
            {
                return(InterseptResult.Intersepts);
            }
            if (GoogleMapUtilities.CheckLinesInterseption(new CoordinateRectangle(Left, Top, Right, Top),
                                                          new CoordinateRectangle(rectangle.Left, rectangle.Top, rectangle.Left, rectangle.Bottom)))
            {
                return(InterseptResult.Intersepts);
            }

            return(InterseptResult.None);
        }
Exemplo n.º 3
0
        public bool Add(Coordinate 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 (GoogleMapUtilities.CheckLinesInterseption(this[i], line1) ||
                        GoogleMapUtilities.CheckLinesInterseption(this[i], line2))
                    {
                        return(false);
                    }
                }
            }

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