コード例 #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);
        }
コード例 #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
        }
コード例 #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));
 }
コード例 #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);
        }
コード例 #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));
 }
コード例 #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;
 }
コード例 #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);
 }
コード例 #8
0
 public static string GetTileUrlFromWorldPos(string mapName, int floor, int zoomLevel, Gw2Point worldPosition)
 {
     MapEntryBase map = GetMap(mapName);
     return GetTileUrlFromWorldPos(map, floor, zoomLevel, worldPosition);
 }
コード例 #9
0
 public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom)
 {
     var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom));
     return point;
 }
コード例 #10
0
 public static Gw2Point WorldPosToTile(int mapId, Gw2Point worldPosition, int zoom)
 {
     return WorldPosToTile(GetMap(mapId), worldPosition, zoom);
 }
コード例 #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
 }
コード例 #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 );
 }
コード例 #13
0
        public static Gw2Point WorldPosToTile(MapEntryBase map, Gw2Point worldPosition, int zoom)
        {
            var point = PixelToTile(WorldPosToPixel(map, worldPosition, zoom));

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

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