Exemplo n.º 1
0
 private GoogleCoordinate GetLeftTopGoogle(int screenWidth, int screenHeight, int level)
 {
     return(new GoogleCoordinate(
                GoogleMapUtilities.GetGoogleX(this, level) - ((screenWidth + 1) / 2 - 1),
                GoogleMapUtilities.GetGoogleY(this, level) - ((screenHeight + 1) / 2 - 1),
                level));
 }
Exemplo n.º 2
0
 private GoogleCoordinate GetRightBottomGoogle(int screenWidth, int screenHeight, int level)
 {
     return(new GoogleCoordinate(
                GoogleMapUtilities.GetGoogleX(this, level) + ((screenWidth - 1) / 2 + 1),
                GoogleMapUtilities.GetGoogleY(this, level) + ((screenHeight - 1) / 2 + 1),
                level));
 }
Exemplo n.º 3
0
        public static Bitmap DownloadImageFromGoogle(GoogleBlock block, bool getBitmap)
        {
            try
            {
                var oRequest  = GoogleMapUtilities.CreateGoogleWebRequest(block);
                var oResponse = (HttpWebResponse)oRequest.GetResponse();

                var bmpStream = new MemoryStream();
                var oStream   = oResponse.GetResponseStream();
                if (oStream != null)
                {
                    oStream.CopyTo(bmpStream);
                }
                oResponse.Close();
                if (bmpStream.Length > 0)
                {
                    WriteImageToFile(block, bmpStream);
                    return(getBitmap ? (Bitmap)Image.FromStream(bmpStream) : null);
                }
            }
            catch (Exception ex)
            {
                //do nothing
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return(null);
        }
Exemplo n.º 4
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.º 5
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.º 6
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);
        }
Exemplo n.º 7
0
 private int GoogleNumLevel(int level)
 {
     return((int)GoogleMapUtilities.NumLevel((int)Sheets.Power(level)));
 }