Example #1
0
        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);
        }
Example #2
0
        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
        }
Example #3
0
 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));
 }
Example #4
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);
        }
Example #5
0
 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));
 }
Example #6
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;
 }
Example #7
0
 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);
 }
Example #8
0
 public static string GetTileUrlFromWorldPos(string mapName, int floor, int zoomLevel, Gw2Point worldPosition)
 {
     MapEntryBase map = GetMap(mapName);
     return GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition);
 }
Example #9
0
 public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom)
 {
     var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom));
     return point;
 }
Example #10
0
 public static Gw2Point WorldPosToTile(int mapId, Gw2Point worldPosition, int zoom)
 {
     return WorldPosToTile(GetMap(mapId), worldPosition, zoom);
 }
Example #11
0
 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
 }
Example #12
0
 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 );
 }
Example #13
0
        public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom)
        {
            var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom));

            return(point);
        }
Example #14
0
 public static Gw2Point WorldPosToTile(string mapName, Gw2Point worldPosition, int zoom)
 {
     return(WorldPosToTile(GetMap(mapName), worldPosition, zoom));
 }
Example #15
0
 public static Gw2Point WorldPosToTile(int mapId, Gw2Point worldPosition, int zoom)
 {
     return(WorldPosToTile(GetMap(mapId), worldPosition, zoom));
 }
Example #16
0
 public static Gw2Point PixelToWorldPos(string mapName, Gw2Point pixel, int zoom)
 {
     return(PixelToWorldPos(GetMap(mapName), pixel, zoom));
 }
Example #17
0
 public static Gw2Point PixelToWorldPos(string mapName, Gw2Point pixel, int zoom)
 {
     return PixelToWorldPos(GetMap(mapName), pixel, zoom);
 }
Example #18
0
 public static string GetTileUrlFromPixel(int continentId, int floor, int zoomLevel, Gw2Point pixelCoord, string errorTileUrl)
 {
     return(GetTileUrl(continentId, floor, zoomLevel, PixelToTile(pixelCoord), errorTileUrl));
 }
Example #19
0
 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);
 }
Example #20
0
        public static string GetTileUrlFromWorldPos(string mapName, int floor, int zoomLevel, Gw2Point worldPosition)
        {
            MapEntryBase map = GetMap(mapName);

            return(GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition));
        }
Example #21
0
 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;
 }
Example #22
0
        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));
        }
Example #23
0
 public static Gw2Point WorldPosToTile(string mapName, Gw2Point worldPosition, int zoom)
 {
     return WorldPosToTile(GetMap(mapName), worldPosition, zoom);
 }
Example #24
0
 /// <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);
 }
Example #25
0
 public static string GetTileUrlFromPixel(int continentId, int floor, int zoomLevel, Gw2Point pixelCoord, string errorTileUrl)
 {
     return GetTileUrl(continentId, floor, zoomLevel, PixelToTile(pixelCoord), errorTileUrl);
 }
Example #26
0
        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));
        }
Example #27
0
 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);
 }
Example #28
0
 public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord)
 {
     return(GetTileUrl(continentId, floor, zoomLevel, tileCoord, Constants.ContinentErrorTileUrl[continentId]));
 }
Example #29
0
 public static string GetTileUrl(int continentId, int floor, int zoomLevel, Gw2Point tileCoord)
 {
     return GetTileUrl(continentId, floor, zoomLevel, tileCoord, Constants.ContinentErrorTileUrl[continentId]);
 }
Example #30
0
 public static Gw2Point PixelToWorldPos(int mapId, Gw2Point pixel, int zoom)
 {
     return PixelToWorldPos(GetMap(mapId), pixel, zoom);
 }
Example #31
0
 /// <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;
 }
Example #32
0
 public static Gw2Point PixelToWorldPos(int mapId, Gw2Point pixel, int zoom)
 {
     return(PixelToWorldPos(GetMap(mapId), pixel, zoom));
 }