Esempio n. 1
0
        //
        public MTerrainBoundary GetTileBoundaryLonLat(int TileX, int TileY, int Zoom)
        {
            MTerrainBoundary tb = new MTerrainBoundary();

            tb.LonLatTL = PixelXYToLonLat(TileX * 256, TileY * 256, Zoom);
            tb.LonLatTR = PixelXYToLonLat((TileX + 1) * 256, TileY * 256, Zoom);
            tb.LonLatBL = PixelXYToLonLat((TileX) * 256, (TileY + 1) * 256, Zoom);
            tb.LonLatBR = PixelXYToLonLat((TileX + 1) * 256, (TileY + 1) * 256, Zoom);

            tb.TL = MGISTools.LonLatMercatorToPosition(tb.LonLatTL.X, tb.LonLatTL.Y, Radius.X) + Position;
            tb.TR = MGISTools.LonLatMercatorToPosition(tb.LonLatTR.X, tb.LonLatTR.Y, Radius.X) + Position;
            tb.BL = MGISTools.LonLatMercatorToPosition(tb.LonLatBL.X, tb.LonLatBL.Y, Radius.X) + Position;
            tb.BR = MGISTools.LonLatMercatorToPosition(tb.LonLatBR.X, tb.LonLatBR.Y, Radius.X) + Position;

            return(tb);
        }
Esempio n. 2
0
        private void MapBox_MouseClick(object sender, MouseEventArgs e)
        {
            WorldLocationPoint = MapTo3D(e.X, e.Y);
            ClickPoint         = e.Location;
            MMessageBus.Navigate(this, WorldLocationPoint);

            Console.WriteLine("Validate");
            if (bmp == null)
            {
                return;
            }
            Bitmap bmp2   = new Bitmap(bmp);
            Pen    RedPen = new Pen(Color.Red);

            RedPen.Width = 2;
            Graphics  g    = Graphics.FromImage(bmp2);
            float     posx = (float)ClickPoint.X / (float)MapBox.Width * (float)bmp.Width;
            float     posy = (float)ClickPoint.Y / (float)MapBox.Height * (float)bmp.Height;
            Rectangle rec  = new Rectangle((int)posx - 7, (int)posy - 7, 15, 15);

            g.DrawRectangle(RedPen, rec);
            RedPen.Dispose();
            g.Dispose();
            MapBox.BackgroundImage = bmp2;
            Invalidate(new Rectangle(ClickPoint.X - 2, ClickPoint.Y - 2, 5, 5));

            Vector3d Pos3d  = MapTo3D(e.X, MapBox.Height - e.Y);
            Vector3d uv     = CurrentBody.GetUVPointOnSphere(Pos3d);
            Vector3d lonlat = CurrentBody.GetLonLatOnShere(Pos3d);
            Vector3d tile   = CurrentBody.GetTileFromPoint(Pos3d);

            WorldLocationPoint = CurrentBody.LonLatToUniPosition(lonlat.X, lonlat.Y, 0);
            MTerrainBoundary tb = CurrentBody.GetTileBoundaryLonLat((int)tile.X, (int)tile.Y, (int)tile.Z);

            WorldLocationPoint = Pos3d;
            WorldCoords.Text   =
                " pos:" + Pos3d.ToString() + "\r\n"
                //     + " uv:" + uv.ToString() + "\r\n"
                + " lonlat:" + lonlat.ToString() + "\r\n"
                + " Tile: " + tile.ToString() + "\r\n"
                // + " Bounds: " + tb.ToString() + "\r\n"
//       + " Round Trip: " + WorldLocationPoint.ToString()
            ;
        }