Ejemplo n.º 1
0
 public override void Dispose()
 {
     if (m_terrainTileService != null)
     {
         m_terrainTileService.Dispose();
         m_terrainTileService = null;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Terrain.TerrainDownloadRequest"/> class.
 /// </summary>
 /// <param name="tile"></param>
 /// <param name="owner"></param>
 /// <param name="row"></param>
 /// <param name="col"></param>
 /// <param name="targetLevel"></param>
 public TerrainDownloadRequest(TerrainTile tile, TerrainTileService owner, int row, int col, int targetLevel) : base(owner)
 {
     TerrainTile  = tile;
     download.Url = String.Format(CultureInfo.InvariantCulture,
                                  "{0}?T={1}&L={2}&X={3}&Y={4}",
                                  owner.ServerUrl,
                                  owner.DataSet,
                                  targetLevel, col, row);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Terrain.NltTerrainAccessor"/> class.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="west"></param>
 /// <param name="south"></param>
 /// <param name="east"></param>
 /// <param name="north"></param>
 /// <param name="terrainTileService"></param>
 /// <param name="higherResolutionSubsets"></param>
 public NltTerrainAccessor(string name, double west, double south, double east, double north,
                           TerrainTileService terrainTileService, TerrainAccessor[] higherResolutionSubsets)
 {
     m_name  = name;
     m_west  = west;
     m_south = south;
     m_east  = east;
     m_north = north;
     m_terrainTileService      = terrainTileService;
     m_higherResolutionSubsets = higherResolutionSubsets;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Get fast terrain elevation at specified location from already loaded data.
 /// Will not trigger any download or data loading from files in cache - just memory.
 /// </summary>
 /// <param name="latitude">Latitude in decimal degrees.</param>
 /// <param name="longitude">Longitude in decimal degrees.</param>
 /// <returns>Returns NaN if no tile is available in cache.</returns>
 public override float GetCachedElevationAt(double latitude, double longitude)
 {
     try
     {
         if (m_terrainTileService == null)
         {
             return(0);
         }
         // Use higher res subset if any
         if (m_higherResolutionSubsets != null)
         {
             foreach (TerrainAccessor higherResSub in m_higherResolutionSubsets)
             {
                 if (!higherResSub.IsOn)
                 {
                     continue;
                 }
                 if (latitude > higherResSub.South && latitude < higherResSub.North &&
                     longitude > higherResSub.West && longitude < higherResSub.East)
                 {
                     return(higherResSub.GetCachedElevationAt(latitude, longitude));
                 }
             }
         }
         // Look for a tile starting from higher res level, moving down the levels
         TerrainTileCacheEntry ttce = null;
         for (int targetLevel = m_terrainTileService.NumberLevels - 1; targetLevel >= 0; targetLevel--)
         {
             // File name and path for that level
             double tileSize            = m_terrainTileService.LevelZeroTileSizeDegrees * Math.Pow(0.5, targetLevel);
             int    row                 = TerrainTileService.GetRowFromLatitude(latitude, tileSize);
             int    col                 = TerrainTileService.GetColFromLongitude(longitude, tileSize);
             string terrainTileFilePath = string.Format(CultureInfo.InvariantCulture,
                                                        @"{0}\{4}\{1:D4}\{1:D4}_{2:D4}.{3}",
                                                        m_terrainTileService.TerrainTileDirectory, row, col, m_terrainTileService.FileExtension, targetLevel);
             // Look in cache
             ttce = (TerrainTileCacheEntry)m_tileCache[terrainTileFilePath];
             if (ttce != null)
             {
                 // Tile found, get elevation from it
                 ttce.LastAccess = DateTime.Now;
                 return(ttce.TerrainTile.GetElevationAt(latitude, longitude));
             }
         }
     }
     catch (Exception)
     {
     }
     // No tile found - sorry.
     return(float.NaN);
 }
Ejemplo n.º 5
0
 public TerrainTile(TerrainTileService owner)
 {
     m_owner = owner;
 }