Пример #1
0
        public virtual void AddToDownloadQueue(CameraBase camera, GeoSpatialDownloadRequest newRequest)
        {
            QuadTile key = newRequest.QuadTile;

            key.WaitingForDownload = true;
            lock (m_downloadRequests.SyncRoot)
            {
                if (m_downloadRequests.Contains(key))
                {
                    return;
                }

                m_downloadRequests.Add(key, newRequest);

                if (m_downloadRequests.Count >= m_maxQueueSize)
                {
                    //remove spatially farthest request
                    GeoSpatialDownloadRequest farthestRequest = null;
                    Angle curDistance      = Angle.Zero;
                    Angle farthestDistance = Angle.Zero;
                    foreach (GeoSpatialDownloadRequest curRequest in m_downloadRequests.Values)
                    {
                        curDistance = MathEngine.SphericalDistance(
                            curRequest.QuadTile.CenterLatitude,
                            curRequest.QuadTile.CenterLongitude,
                            camera.Latitude,
                            camera.Longitude);

                        if (curDistance > farthestDistance)
                        {
                            farthestRequest  = curRequest;
                            farthestDistance = curDistance;
                        }
                    }

                    farthestRequest.Dispose();
                    farthestRequest.QuadTile.DownloadRequest = null;
                    m_downloadRequests.Remove(farthestRequest.QuadTile);
                }
            }

            ServiceDownloadQueue();
        }
Пример #2
0
        /// <summary>
        /// Updates this layer (background)
        /// </summary>
        public virtual void Update(DrawArgs drawArgs)
        {
            if (m_isResetingCache)
            {
                return;
            }

            try {
                double tileSize = North - South;

                if (!isInitialized)
                {
                    if (DrawArgs.Camera.ViewRange * 0.5f < Angle.FromDegrees(QuadTileSet.TileDrawDistance * tileSize) && MathEngine.SphericalDistance(CenterLatitude, CenterLongitude, DrawArgs.Camera.Latitude, DrawArgs.Camera.Longitude) < Angle.FromDegrees(QuadTileSet.TileDrawSpread * tileSize * 1.25f) &&
                        DrawArgs.Camera.ViewFrustum.Intersects(BoundingBox))
                    {
                        Initialize();
                    }
                }

                if (isInitialized && World.Settings.VerticalExaggeration != verticalExaggeration || m_CurrentOpacity != QuadTileSet.Opacity ||
                    QuadTileSet.RenderStruts != renderStruts)
                {
                    CreateTileMesh();
                }

                if (isInitialized)
                {
                    if (DrawArgs.Camera.ViewRange < Angle.FromDegrees(QuadTileSet.TileDrawDistance * tileSize) && MathEngine.SphericalDistance(CenterLatitude, CenterLongitude, DrawArgs.Camera.Latitude, DrawArgs.Camera.Longitude) < Angle.FromDegrees(QuadTileSet.TileDrawSpread * tileSize) &&
                        DrawArgs.Camera.ViewFrustum.Intersects(BoundingBox))
                    {
                        if (northEastChild == null || northWestChild == null || southEastChild == null ||
                            southWestChild == null)
                        {
                            ComputeChildren(drawArgs);
                        }

                        if (northEastChild != null)
                        {
                            northEastChild.Update(drawArgs);
                        }

                        if (northWestChild != null)
                        {
                            northWestChild.Update(drawArgs);
                        }

                        if (southEastChild != null)
                        {
                            southEastChild.Update(drawArgs);
                        }

                        if (southWestChild != null)
                        {
                            southWestChild.Update(drawArgs);
                        }
                    }
                    else
                    {
                        if (northWestChild != null)
                        {
                            northWestChild.Dispose();
                            northWestChild = null;
                        }

                        if (northEastChild != null)
                        {
                            northEastChild.Dispose();
                            northEastChild = null;
                        }

                        if (southEastChild != null)
                        {
                            southEastChild.Dispose();
                            southEastChild = null;
                        }

                        if (southWestChild != null)
                        {
                            southWestChild.Dispose();
                            southWestChild = null;
                        }
                    }
                }

                if (isInitialized)
                {
                    if (DrawArgs.Camera.ViewRange / 2 > Angle.FromDegrees(QuadTileSet.TileDrawDistance * tileSize * 1.5f) ||
                        MathEngine.SphericalDistance(CenterLatitude, CenterLongitude, DrawArgs.Camera.Latitude, DrawArgs.Camera.Longitude) > Angle.FromDegrees(QuadTileSet.TileDrawSpread * tileSize * 1.5f))
                    {
                        if (Level != 0 ||
                            (Level == 0 && !QuadTileSet.AlwaysRenderBaseTiles))
                        {
                            this.Dispose();
                        }
                    }
                }
            }
            catch {}
        }