public MinimapTileReadyArgs(MapTileXY position, MapTileBounds bounds, string image, uint index) { Position = position; Bounds = bounds; Image = image; RunnerIndex = index; }
private void CleanUpTiles(int mapZoomLevel, MapTileBounds mapBounds) { // Remove tiles that are 3 levels higher than current zoom level int mapZoomLevelThreshold = mapZoomLevel - MaxZoomLevelDifference; for (int i = tilesList.Count - 1; i >= 0; i--) { var tileId = tilesList[i].Id; // Calculate the tile bounds in the map's zoom level float toMapZoom = Mathf.Pow(2, mapZoomLevel - tileId.Z); int tileWest = (int)(tileId.X * toMapZoom); int tileEast = (int)((tileId.X + 1) * toMapZoom); int tileNorth = (int)(tileId.Y * toMapZoom); int tileSouth = (int)((tileId.Y + 1) * toMapZoom); bool inFrustum = tileEast > mapBounds.West && tileWest <mapBounds.East && tileSouth> mapBounds.North && tileNorth < mapBounds.South; if (!inFrustum || tileId.Z < mapZoomLevelThreshold) { RemoveTile(tilesMap, tilesList, i); } else if (tileId.Z != mapZoomLevel) { if ((tileId.Z > mapZoomLevel && IsCoveredByLargerTile(mapZoomLevel, tileId.X, tileId.Y, tileId.Z)) || (tileId.Z < mapZoomLevel && IsCoveredBySmallerTiles(mapZoomLevel, tileId.X, tileId.Y, tileId.Z))) { RemoveTile(tilesMap, tilesList, i); } } } }
public override bool Equals(object obj) { if (!(obj is MapTileBounds)) { return(false); } MapTileBounds bounds = (MapTileBounds)obj; return(bounds.North == North && bounds.South == South && bounds.West == West && bounds.East == East); }
protected void CleanUpTiles() { int mapZoomLevel = map.ZoomLevel; MapTileBounds mapBounds = map.MapTileBounds; CleanUpTiles(mapZoomLevel, mapBounds); CleanUpOldTiles(mapZoomLevel, mapBounds); // Remove any requests that are not for this zoom level and bounds CancelRequests(mapZoomLevel, mapBounds); }
private void CleanUpOldTiles(int mapZoomLevel, MapTileBounds mapBounds) { // Remove tiles that are 3 levels higher than current zoom level int mapZoomLevelThreshold = mapZoomLevel - MaxZoomLevelDifference; MapTileId anchorId = map.Anchor; float anchorScale = map.TilesToUnits; Vector2 anchorOffset = map.AnchorOffsetInUnits; for (int i = oldTilesList.Count - 1; i >= 0; i--) { var tileId = oldTilesList[i].Id; if (tilesMap.ContainsKey(MapTileId.ToId(tileId.X, tileId.Y, tileId.Z, layerId))) { RemoveTile(oldTilesMap, oldTilesList, i); } else { // Calculate the tile bounds in the map's zoom level float toMapZoom = Mathf.Pow(2, mapZoomLevel - tileId.Z); int tileWest = (int)(tileId.X * toMapZoom); int tileEast = (int)((tileId.X + 1) * toMapZoom); int tileNorth = (int)(tileId.Y * toMapZoom); int tileSouth = (int)((tileId.Y + 1) * toMapZoom); bool inFrustum = tileEast > mapBounds.West && tileWest <mapBounds.East && tileSouth> mapBounds.North && tileNorth < mapBounds.South; if (!inFrustum || tileId.Z < mapZoomLevelThreshold) { RemoveTile(oldTilesMap, oldTilesList, i); } else if (tileId.Z != mapZoomLevel) { if ((tileId.Z > mapZoomLevel && IsCoveredByLargerTile(mapZoomLevel, tileId.X, tileId.Y, tileId.Z)) || (tileId.Z < mapZoomLevel && IsCoveredBySmallerTiles(mapZoomLevel, tileId.X, tileId.Y, tileId.Z))) { RemoveTile(oldTilesMap, oldTilesList, i); } else { MapTile tile = oldTilesList[i]; tile.UpdateTile(anchorId, anchorScale, anchorOffset, Mathf.Pow(2, map.zoom - tile.ZoomLevel), 0.0001f); } } else { MapTile tile = oldTilesList[i]; tile.UpdateTile(anchorId, anchorScale, anchorOffset, Mathf.Pow(2, map.zoom - tile.ZoomLevel), 0.0001f); } } } }
private void CancelRequests(int mapZoom, MapTileBounds bounds) { var node = requestHandler.PendingRequests.First; var tId = new MapTileId(); while (node != null) { var next = node.Next; var request = node.Value; tId.Set(request.id); if (tId.Z != mapZoom || tId.X < bounds.West || tId.X >= bounds.East || tId.Y < bounds.North || tId.Y >= bounds.South) { request.Cancel(); requestHandler.RemovePending(node); requestedTiles.Remove(request.id); } node = next; } }