Example #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();
        }
Example #2
0
 public virtual void Dispose()
 {
     try {
         isInitialized = false;
         if (texture != null &&
             !texture.Disposed)
         {
             texture.Dispose();
             texture = null;
         }
         if (northWestChild != null)
         {
             northWestChild.Dispose();
             northWestChild = null;
         }
         if (southWestChild != null)
         {
             southWestChild.Dispose();
             southWestChild = null;
         }
         if (northEastChild != null)
         {
             northEastChild.Dispose();
             northEastChild = null;
         }
         if (southEastChild != null)
         {
             southEastChild.Dispose();
             southEastChild = null;
         }
         if (DownloadRequest != null)
         {
             QuadTileSet.RemoveFromDownloadQueue(DownloadRequest);
             DownloadRequest.Dispose();
             DownloadRequest = null;
         }
     }
     catch {}
 }