Esempio n. 1
0
        public override void UpdateTileExtent()
        {
            if (!_initialized)
            {
                return;
            }

            _currentExtent.activeTiles.Clear();
            //_toRemove.Clear();
            _currentTile = TileCover.CoordinateToTileId(_map.WorldToGeoPosition(_rangeTileProviderOptions.targetTransform.localPosition), _map.AbsoluteZoom);

            if (!_currentTile.Equals(_cachedTile))
            {
                for (int x = _currentTile.X - _rangeTileProviderOptions.visibleBuffer; x <= (_currentTile.X + _rangeTileProviderOptions.visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _rangeTileProviderOptions.visibleBuffer; y <= (_currentTile.Y + _rangeTileProviderOptions.visibleBuffer); y++)
                    {
                        _currentExtent.activeTiles.Add(new UnwrappedTileId(_map.AbsoluteZoom, x, y));
                    }
                }

                _cachedTile = _currentTile;
                OnExtentChanged();
            }
        }
Esempio n. 2
0
        void Update()
        {
            if (!_shouldUpdate)
            {
                return;
            }

            _elapsedTime += Time.deltaTime;
            if (_elapsedTime >= _updateInterval)
            {
                _elapsedTime = 0f;
                _ray         = _camera.ViewportPointToRay(_viewportTarget);
                if (_groundPlane.Raycast(_ray, out _hitDistance))
                {
                    _currentLatitudeLongitude = _ray.GetPoint(_hitDistance).GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale);
                    _currentTile = TileCover.CoordinateToTileId(_currentLatitudeLongitude, _map.Zoom);

                    if (!_currentTile.Equals(_cachedTile))
                    {
                        // FIXME: this results in bugs at world boundaries! Does not cleanly wrap. Negative tileIds are bad.
                        for (int x = _currentTile.X - _visibleBuffer; x <= (_currentTile.X + _visibleBuffer); x++)
                        {
                            for (int y = _currentTile.Y - _visibleBuffer; y <= (_currentTile.Y + _visibleBuffer); y++)
                            {
                                AddTile(new UnwrappedTileId(_map.Zoom, x, y));
                            }
                        }
                        _cachedTile = _currentTile;
                        Cleanup(_currentTile);
                    }
                }
            }
        }
Esempio n. 3
0
        // updates tile rendering at regular intervals
        void Update()
        {
            _timeElapsed += Time.deltaTime;
            if (_timeElapsed >= _updateInterval)
            {
                _timeElapsed = 0; // reset time
                // what the camera is looking at, center of screen
                _ray = _camera.ViewportPointToRay(_viewportTarget);

                if (_groundPlane.Raycast(_ray, out _hitDistance))
                {
                    // geoegraphical coordinates that the camera is looking at
                    _currentLatitudeLongitude = _ray.GetPoint(_hitDistance).GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale);
                    // Debug.Log(_currentLatitudeLongitude);
                    // tile that the camera is looking at
                    _currentTile = TileCover.CoordinateToTileId(_currentLatitudeLongitude, _map.Zoom);

                    // camera has moved
                    if (!_currentTile.Equals(_cachedTile))
                    {
                        // FIXME: this results in bugs at world boundaries! Does not cleanly wrap. Negative tileIds are bad.
                        // I just make the screen go dark, not a great fix but shouldn't occur anyway
                        for (int x = Mathd.Max(_currentTile.X - _visibleBuffer, 0); x <= (_currentTile.X + _visibleBuffer); x++)
                        {
                            for (int y = Mathd.Max(_currentTile.Y - _visibleBuffer, 0); y <= (_currentTile.Y + _visibleBuffer); y++)
                            {
                                AddTile(new UnwrappedTileId(_map.Zoom, x, y));
                            }
                        }
                        _cachedTile = _currentTile;
                        Cleanup(_currentTile);
                    }
                }
            }
        }
Esempio n. 4
0
    private void Update()
    {
        if (!_initialized)
        {
            return;
        }

        _elapsedTime += Time.deltaTime;
        if (_elapsedTime >= _updateInterval)
        {
            _elapsedTime   = 0f;
            _currentLatLng = locationMarker.position.GetGeoPosition(map.CenterMercator, map.WorldRelativeScale);

            _currentTile = TileCover.CoordinateToTileId(_currentLatLng, map.Zoom);

            if (!_currentTile.Equals(_cachedTile))
            {
                for (int x = _currentTile.X - _visibleBuffer; x <= (_currentTile.X + _visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _visibleBuffer; y <= (_currentTile.Y + _visibleBuffer); y++)
                    {
                        AddTile(new UnwrappedTileId(map.Zoom, x, y));
                    }
                }
                _cachedTile = _currentTile;
                // Cleanup(_currentTile);
            }
        }
    }
        private void Update()
        {
            if (!_initialized)
            {
                // Debug.Log("Return");
                return;
            }

            _currentTile = TileCover.CoordinateToTileId(_targetTransform.localPosition.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale), _map.Zoom);

            Debug.Log(_targetTransform.localPosition);
            Debug.Log(_targetTransform.localPosition.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale));
            Debug.Log("Current Tile");
            Debug.Log(_currentTile);
            //Debug.Log("Position");
            //Debug.Log(_targetTransform.localPosition.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale).x);

            //Debug.Log(_targetTransform.localPosition.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale).y);

            if (!_currentTile.Equals(_cachedTile))
            {
                //Debug.Log("here");
                // Debug.Log("Different Tile");
                for (int x = _currentTile.X - _visibleBuffer; x <= (_currentTile.X + _visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _visibleBuffer; y <= (_currentTile.Y + _visibleBuffer); y++)
                    {
                        AddTile(new UnwrappedTileId(_map.Zoom, x, y));
                    }
                }
                _cachedTile = _currentTile;
                //Cleanup(_currentTile);
            }
            // Debug.Log("End");
        }
        IEnumerator UpdateCo()
        {
            while (true)
            {
                if (!_shouldUpdate)
                {
                    yield return(null);
                }
                _ray = _camera.ViewportPointToRay(_viewportTarget);

                if (_groundPlane.Raycast(_ray, out _hitDistance))
                {
                    //_currentLatitudeLongitude = zoompan.CenterLatitudeLongitude;
                    _currentLatitudeLongitude = _ray.GetPoint(_hitDistance).GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale);
                    // Debug.Log(_currentLatitudeLongitude);
                    // _currentLatitudeLongitude = _camera.ScreenToWorldPoint(new Vector3(512, 384, 0)).GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale);
                    // Debug.Log(_camera.ScreenPointToRay(Input.mousePosition).GetPoint(60).GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale) + " " + _currentLatitudeLongitude);

                    if (shouldMove)
                    {
                        zoompan.SetCenter(_currentLatitudeLongitude);
                        shouldMove = false;
                    }
                    _currentTile = TileCover.CoordinateToTileId(_currentLatitudeLongitude, _map.Zoom);

                    if (!_currentTile.Equals(_cachedTile))
                    {
                        // FIXME: this results in bugs at world boundaries! Does not cleanly wrap. Negative tileIds are bad.
                        for (int x = Mathd.Max(_currentTile.X - _visibleBuffer, 0); x <= (_currentTile.X + _visibleBuffer); x++)
                        {
                            for (int y = Mathd.Max(_currentTile.Y - _visibleBuffer, 0); y <= (_currentTile.Y + _visibleBuffer); y++)
                            {
                                AddTile(new UnwrappedTileId(_map.Zoom, x, y));
                            }
                        }
                        _cachedTile = _currentTile;
                        Cleanup(_currentTile);
                    }
                }
                yield return(new WaitForSeconds(_updateInterval));
            }
        }
Esempio n. 7
0
        private void Update()
        {
            if (!_initialized)
            {
                return;
            }

            var activeTiles = _activeTiles.Keys.ToList();

            List <UnwrappedTileId> tilesToRequest = new List <UnwrappedTileId>();

            _currentTile = TileCover.CoordinateToTileId(_map.WorldToGeoPosition(_rangeTileProviderOptions.targetTransform.localPosition), _map.AbsoluteZoom);

            if (!_currentTile.Equals(_cachedTile))
            {
                for (int x = _currentTile.X - _rangeTileProviderOptions.visibleBuffer; x <= (_currentTile.X + _rangeTileProviderOptions.visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _rangeTileProviderOptions.visibleBuffer; y <= (_currentTile.Y + _rangeTileProviderOptions.visibleBuffer); y++)
                    {
                        tilesToRequest.Add(new UnwrappedTileId(_map.AbsoluteZoom, x, y));
                    }
                }
                _cachedTile = _currentTile;
                Cleanup(_currentTile);

                var finalTilesNeeded = tilesToRequest.Except(activeTiles);

                foreach (var tile in activeTiles)
                {
                    // Reposition tiles in case we panned.
                    RepositionTile(tile);
                }

                foreach (var tile in finalTilesNeeded)
                {
                    AddTile(tile);
                }
            }
        }
        private void Update()
        {
            if (!_initialized)
            {
                return;
            }

            _currentTile = TileCover.CoordinateToTileId(_targetTransform.localPosition.GetGeoPosition(_map.CenterMercator, _map.WorldRelativeScale), _map.AbsoluteZoom);

            if (!_currentTile.Equals(_cachedTile))
            {
                for (int x = _currentTile.X - _visibleBuffer; x <= (_currentTile.X + _visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _visibleBuffer; y <= (_currentTile.Y + _visibleBuffer); y++)
                    {
                        AddTile(new UnwrappedTileId(_map.AbsoluteZoom, x, y));
                    }
                }
                _cachedTile = _currentTile;
                Cleanup(_currentTile);
            }
        }
Esempio n. 9
0
        private void Update()
        {
            if (!_initialized)
            {
                return;
            }

            _currentTile = TileCover.CoordinateToTileId(_basicMap.WorldToGeoPosition(_targetTransform.position), (int)_map.Zoom);

            if (!_currentTile.Equals(_cachedTile))
            {
                for (int x = _currentTile.X - _visibleBuffer; x <= (_currentTile.X + _visibleBuffer); x++)
                {
                    for (int y = _currentTile.Y - _visibleBuffer; y <= (_currentTile.Y + _visibleBuffer); y++)
                    {
                        AddTile(new UnwrappedTileId((int)_map.Zoom, x, y));
                    }
                }
                _cachedTile = _currentTile;
                Cleanup(_currentTile);
            }
        }