internal void Initialize(IMapReadable map, UnwrappedTileId tileId, float scale, int zoom, Texture2D loadingTexture = null) { TileScale = scale; _unwrappedTileId = tileId; _loadingTexture = loadingTexture; // TODO geoAR: use boolean flag instead of direct type check if (map is SwissBasicMap) { // scale is constant, does not depend on latitude _relativeScale = scale; _rect = SwissConversions.TileBounds(tileId); // do not wrap around _canonicalTileId = new CanonicalTileId(tileId.Z, tileId.X, tileId.Y); } else { _relativeScale = 1 / Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x); _rect = Conversions.TileBounds(tileId); _canonicalTileId = tileId.Canonical; } float scaleFactor = 1.0f; if (_isInitialized == false) { _isInitialized = true; InitialZoom = zoom; } scaleFactor = Mathf.Pow(2, (map.InitialZoom - zoom)); gameObject.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor); gameObject.SetActive(true); }
public override void Initialize(Vector2d latLon, int zoom) { _worldHeightFixed = false; // Swiss grid meters, not lat/lag _centerLatitudeLongitude = SwissConversions.LatLonToMeters(latLon); _zoom = zoom; _initialZoom = zoom; var referenceTileRect = SwissConversions.TileBounds(SwissConversions.MetersToTileId(_centerLatitudeLongitude, AbsoluteZoom)); _centerMercator = referenceTileRect.Center; _worldRelativeScale = (float)(_unityTileSize / referenceTileRect.Size.x); _mapVisualizer.Initialize(this, _fileSource); _tileProvider.Initialize(this); // TODO geoAR: remove logging Debug.Log("Center lat/lon: " + _centerLatitudeLongitude); Debug.Log("Center Mercator: " + _centerMercator); Debug.Log("Reference tile: min=" + referenceTileRect.Min + ", max=" + referenceTileRect.Max + ", size=" + referenceTileRect.Size); Debug.Log("Relative scale: " + _worldRelativeScale); SendInitialized(); }