public void WorldPosToTileTest(int continent, int floor, int mapid, int zoom, double worldX, double worldY, int expTileX, int expTileY) { var mapEntry = GwApi.GetMapFloor(continent, floor); var region = mapEntry.Regions.Values.Single(r => r.Maps.Values.Count(m => m.Id == mapid) == 1); var map = region.Maps.Values.Single(m => m.Id == mapid); var tilePoint = GwMapsHelper.WorldPosToTile(map, new Gw2Point { X = worldX, Y = worldY }, zoom); Console.WriteLine(tilePoint); var expectedPoint = new Gw2Point { X = expTileX, Y = expTileY }; Assert.AreEqual(expectedPoint, tilePoint); }
public void PixelToWorldPosTest(int continent, int floor, int mapid, int zoom, double pixelX, double pixelY, double expWorldX, double expWorldY) { var mapEntry = GwApi.GetMapFloor(continent, floor); var region = mapEntry.Regions.Values.Single(r => r.Maps.Values.Count(m => m.Id == mapid) == 1); var map = region.Maps.Values.Single(m => m.Id == mapid); var worldPos = GwMapsHelper.PixelToWorldPos(map, new Gw2Point { X = pixelX, Y = pixelY }, zoom); Console.WriteLine(worldPos); var expectedPoint = new Gw2Point { X = expWorldX, Y = expWorldY }; Assert.AreEqual(expectedPoint, worldPos); }
void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { //_addMarkers3(); if (player == null) { player = Gw2PositionReaderApi.GetPlayerDataInstance(); } Vector3 pos = player.AvatarPosition.MetersToInches(); var gwpoint = new Gw2Point(pos.X, pos.Z); Debug.WriteLine("MapType: " + player.MapType); UpdatePosition((int)player.MapId, gwpoint, player); //Console.WriteLine("Map: {0}, Point:{1}", player.MapId, gwpoint); UpdateMarkerLocalPosition(marker); Status = string.Format("X:{0:0} Y:{1:0} Z:{2:0}", pos.X, pos.Y, pos.Z); } catch (Exception exception) { Console.WriteLine(exception); } }
public void UpdatePosition(int mapId, Gw2Point point, Player player) { Gw2Point pixel = GwMapsHelper.WorldPosToPixel(mapId, point, (int)Zoom); var latlng = MercatorProjection.Instance.FromPixelToLatLng((long)pixel.X, (long)pixel.Y, (int)Zoom); marker.ToolTipText = String.Format( "Point: {0}\n" + "Pixel: {1}\n" + "Lat/Long: {2}\n" + "Player Name: {3}\n" + "Profession: {4}\n" + "Team Color: {5}\n", point.ToString(), pixel.ToString(), latlng.ToString(), player.CharacterName, player.Profession, player.TeamColor ); Debug.WriteLine(marker.ToolTipText); UpdatePosition(latlng); }