Ejemplo n.º 1
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()
            ;
        }
Ejemplo n.º 2
0
        void InitializeTile(string TileNum, int tx, int ty, int zoom)
        {
            TileCount++;
            Console.WriteLine("Tile:" + TileCount + " Initialize " + tx + "," + ty);

            MTerrainTile tile = new MTerrainTile(tx, ty, ZoomLevel, CurrentBody.Radius.X);

            tile.SetShader(TerrainShader);
            Tiles.Add(TileNum, tile);
            MScene.Background.Add(Tiles[TileNum]);
            MTerrainBoundary tb             = CurrentBody.GetTileBoundaryLonLat(tx, ty, ZoomLevel);
            double           metersperpixel = CurrentBody.GroundResolution(tb.LonLatTL.Y, ZoomLevel);

            //Tiles[TileNum].transform.Scale = new Vector3d(256*metersperpixel, 1, 256 *metersperpixel);
            //Vector3d ll = CurrentBody.TileToLonLat(tx, ty, zoom);
            Vector3d ll = tb.LonLatTL;
            //Vector3d pos = CurrentBody.LonLatToUniPosition(ll.X, ll.Y, 0);
            Vector3d pos = MGISTools.LonLatMercatorToPosition(ll.X, ll.Y, CurrentBody.Radius.X) + CurrentBody.Position;

            Tiles[TileNum].transform.Position = pos;
            Tiles[TileNum].SetBoundary(tb);
            Tiles[TileNum].Setup(CurrentBody);
        }