public static Gw2Point WorldPosToTilePixel(MapEntryBase map, Gw2Point worldPosition, int zoom) { Gw2Point pixelAtZoom = WorldPosToPixel(map, worldPosition, zoom); Gw2Point tile = WorldPosToTile(map, worldPosition, zoom); Gw2Point tilePixel = pixelAtZoom - (tile * Constants.TileSize); return(tilePixel); }
public static Gw2Point PixelToTile(Gw2Point pixel) { // ReSharper disable PossibleLossOfFraction var point = new Gw2Point { X = (int)pixel.X / Constants.TileSize, Y = (int)pixel.Y / Constants.TileSize }; return(point); // ReSharper restore PossibleLossOfFraction }
public static Gw2Point WorldPosToPixel(MapEntryBase map, Gw2Point worldPosition, int zoom) { try { var continent = GetContinent(map); int zoomFromMax = continent.MaxZoom - zoom; int projection = 1 << zoomFromMax; var Xpn = map.ContinentRectangle[0][0] + (worldPosition.X - map.MapRectangle[0][0]) * Constants.WorldPosToPixelRatio; var Ypn = map.ContinentRectangle[0][1] + (map.MapRectangle[1][1] - worldPosition.Y) * Constants.WorldPosToPixelRatio; return(new Gw2Point { X = Xpn, Y = Ypn } / projection); } catch (Exception e) { Logger.Error(e); } return(new Gw2Point(0, 0)); }
public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord, string errorTileUrl) { var continents = Continents; var continent = continents[continentId]; if (continent.Floors.Contains(floor) == false) { throw new ArgumentException(string.Format("Floor value doesn't exist for the given Continent {0}", continent.Name, "floor")); } zoomLevel = zoomLevel.EnsureWithin(continent.MinZoom, continent.MaxZoom); var numTilesAtZoom = 1 << zoomLevel; return(tileCoord.X.IsBetweenInclusive(0, numTilesAtZoom) && tileCoord.Y.IsBetweenInclusive(0, numTilesAtZoom) ? string.Format(Constants.MapTileUrlFormat, continentId, floor, zoomLevel, ((int)tileCoord.X), ((int)tileCoord.Y)) : errorTileUrl); }
public static Gw2Point PixelToWorldPos(MapEntryBase map, Gw2Point pixel, int zoom) { try { var continent = GetContinent(map); int zoomFromMax = continent.MaxZoom - zoom; int projection = 1 << zoomFromMax; pixel *= projection; var Xwn = (pixel.X - map.ContinentRectangle[0][0]) * Constants.PixelToWorldPosRatio + map.MapRectangle[0][0]; var Ywn = map.MapRectangle[1][1] - (pixel.Y - map.ContinentRectangle[0][1]) * Constants.PixelToWorldPosRatio; return(new Gw2Point { X = Xwn, Y = Ywn }); } catch (Exception e) { Logger.Error(e); } return(new Gw2Point(0, 0)); }
public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord, string errorTileUrl) { var continents = Continents; var continent = continents[continentId]; if (continent.Floors.Contains(floor) == false) throw new ArgumentException(string.Format("Floor value doesn't exist for the given Continent {0}", continent.Name, "floor")); zoomLevel = zoomLevel.EnsureWithin(continent.MinZoom, continent.MaxZoom); var numTilesAtZoom = 1 << zoomLevel; return tileCoord.X.IsBetweenInclusive(0, numTilesAtZoom) && tileCoord.Y.IsBetweenInclusive(0, numTilesAtZoom) ? string.Format(Constants.MapTileUrlFormat, continentId, floor, zoomLevel, ((int)tileCoord.X), ((int)tileCoord.Y)) : errorTileUrl; }
public static string GetTileUrlFromWorldPos(MapEntryBase map, int floor, int zoomLevel, Gw2Point worldPosition, string errorTileUrl) { MapEntry mapEntry = map is MapEntry ? (map as MapEntry) : GwApi.GetMap()[map.Id]; int continentId = mapEntry.ContinentId; return GetTileUrl(continentId, floor, zoomLevel, WorldPosToTile(map, worldPosition, zoomLevel), errorTileUrl); }
public static string GetTileUrlFromWorldPos(string mapName, int floor, int zoomLevel, Gw2Point worldPosition) { MapEntryBase map = GetMap(mapName); return GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition); }
public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom) { var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom)); return point; }
public static Gw2Point WorldPosToTile(int mapId, Gw2Point worldPosition, int zoom) { return WorldPosToTile(GetMap(mapId), worldPosition, zoom); }
public static Gw2Point PixelToTile(Gw2Point pixel) { // ReSharper disable PossibleLossOfFraction var point = new Gw2Point { X = (int)pixel.X / Constants.TileSize, Y = (int)pixel.Y / Constants.TileSize }; return point; // ReSharper restore PossibleLossOfFraction }
public static Gw2Point PixelToWorldPos(MapEntryBase map, Gw2Point pixel, int zoom) { try { var continent = GetContinent(map); int zoomFromMax = continent.MaxZoom - zoom; int projection = 1 << zoomFromMax; pixel *= projection; var Xwn = (pixel.X - map.ContinentRectangle[0][0]) * Constants.PixelToWorldPosRatio + map.MapRectangle[0][0]; var Ywn = map.MapRectangle[1][1] - (pixel.Y - map.ContinentRectangle[0][1]) * Constants.PixelToWorldPosRatio; return new Gw2Point { X = Xwn, Y = Ywn }; } catch (Exception e) { Logger.Error(e); } return new Gw2Point( 0, 0 ); }
public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom) { var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom)); return(point); }
public static Gw2Point WorldPosToTile(string mapName, Gw2Point worldPosition, int zoom) { return(WorldPosToTile(GetMap(mapName), worldPosition, zoom)); }
public static Gw2Point WorldPosToTile(int mapId, Gw2Point worldPosition, int zoom) { return(WorldPosToTile(GetMap(mapId), worldPosition, zoom)); }
public static Gw2Point PixelToWorldPos(string mapName, Gw2Point pixel, int zoom) { return(PixelToWorldPos(GetMap(mapName), pixel, zoom)); }
public static Gw2Point PixelToWorldPos(string mapName, Gw2Point pixel, int zoom) { return PixelToWorldPos(GetMap(mapName), pixel, zoom); }
public static string GetTileUrlFromPixel(int continentId, int floor, int zoomLevel, Gw2Point pixelCoord, string errorTileUrl) { return(GetTileUrl(continentId, floor, zoomLevel, PixelToTile(pixelCoord), errorTileUrl)); }
public static Gw2Point WorldPosToPixel(MapEntryBase map, Gw2Point worldPosition, int zoom) { try { var continent = GetContinent(map); int zoomFromMax = continent.MaxZoom - zoom; int projection = 1 << zoomFromMax; var Xpn = map.ContinentRectangle[0][0] + (worldPosition.X - map.MapRectangle[0][0]) * Constants.WorldPosToPixelRatio; var Ypn = map.ContinentRectangle[0][1] + (map.MapRectangle[1][1] - worldPosition.Y) * Constants.WorldPosToPixelRatio; return new Gw2Point { X = Xpn, Y = Ypn } / projection; } catch (Exception e) { Logger.Error(e); } return new Gw2Point(0, 0); }
public static string GetTileUrlFromWorldPos(string mapName, int floor, int zoomLevel, Gw2Point worldPosition) { MapEntryBase map = GetMap(mapName); return(GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition)); }
public static Gw2Point WorldPosToTilePixel(MapEntryBase map, Gw2Point worldPosition, int zoom) { Gw2Point pixelAtZoom = WorldPosToPixel(map, worldPosition, zoom); Gw2Point tile = WorldPosToTile(map, worldPosition, zoom); Gw2Point tilePixel = pixelAtZoom - (tile*Constants.TileSize); return tilePixel; }
public static string GetTileUrlFromWorldPos(int mapId, int floor, int zoomLevel, Gw2Point worldPosition, string errorTileUrl) { MapEntryBase map = GetMap(mapId); return(GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition, errorTileUrl)); }
public static Gw2Point WorldPosToTile(string mapName, Gw2Point worldPosition, int zoom) { return WorldPosToTile(GetMap(mapName), worldPosition, zoom); }
/// <summary> /// Determines of given Gw2Point is equal to this point in values. /// </summary> /// <param name="other">point to compare to.</param> /// <returns>true if the X positions and Y positions are equal. Due to /// the X and Y values being double, an algorithm is used to determine equality. /// Currently the values would be considered equal at extremly high accuracy.</returns> public bool Equals(Gw2Point other) { return(other == this); }
public static string GetTileUrlFromPixel(int continentId, int floor, int zoomLevel, Gw2Point pixelCoord, string errorTileUrl) { return GetTileUrl(continentId, floor, zoomLevel, PixelToTile(pixelCoord), errorTileUrl); }
public static string GetTileUrlFromWorldPos(MapEntryBase map, int floor, int zoomLevel, Gw2Point worldPosition, string errorTileUrl) { MapEntry mapEntry = map is MapEntry ? (map as MapEntry) : GwApi.GetMap()[map.Id]; int continentId = mapEntry.ContinentId; return(GetTileUrl(continentId, floor, zoomLevel, WorldPosToTile(map, worldPosition, zoomLevel), errorTileUrl)); }
public static string GetTileUrlFromWorldPos(int mapId, int floor, int zoomLevel, Gw2Point worldPosition, string errorTileUrl) { MapEntryBase map = GetMap(mapId); return GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition, errorTileUrl); }
public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord) { return(GetTileUrl(continentId, floor, zoomLevel, tileCoord, Constants.ContinentErrorTileUrl[continentId])); }
public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord) { return GetTileUrl(continentId, floor, zoomLevel, tileCoord, Constants.ContinentErrorTileUrl[continentId]); }
public static Gw2Point PixelToWorldPos(int mapId, Gw2Point pixel, int zoom) { return PixelToWorldPos(GetMap(mapId), pixel, zoom); }
/// <summary> /// Determines of given Gw2Point is equal to this point in values. /// </summary> /// <param name="other">point to compare to.</param> /// <returns>true if the X positions and Y positions are equal. Due to /// the X and Y values being double, an algorithm is used to determine equality. /// Currently the values would be considered equal at extremly high accuracy.</returns> public bool Equals(Gw2Point other) { return other == this; }
public static Gw2Point PixelToWorldPos(int mapId, Gw2Point pixel, int zoom) { return(PixelToWorldPos(GetMap(mapId), pixel, zoom)); }