NASA World Wind

gov.nasa.worldwind.layers
Class BasicTiledImageLayerBulkDownloader

java.lang.Object
  extended by java.lang.Thread
      extended by gov.nasa.worldwind.retrieve.BulkRetrievalThread
          extended by gov.nasa.worldwind.layers.BasicTiledImageLayerBulkDownloader
All Implemented Interfaces:
Runnable

public class BasicTiledImageLayerBulkDownloader
extends BulkRetrievalThread

Downloads imagery not currently available in the World Wind file cache or a specified file store. The class derives from Thread and is meant to operate in its own thread.

The sector and resolution associated with the downloader are specified during construction and are final.


Nested Class Summary
protected  class BasicTiledImageLayerBulkDownloader.BulkDownloadPostProcessor
           
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected static long DEFAULT_AVERAGE_FILE_SIZE
           
protected  BasicTiledImageLayer layer
           
protected  int level
           
protected static int MAX_TILE_COUNT_PER_REGION
           
protected  ArrayList<TextureTile> missingTiles
           
 
Fields inherited from class gov.nasa.worldwind.retrieve.BulkRetrievalThread
fileStore, progress, resolution, retrievable, RETRIEVAL_SERVICE_POLL_DELAY, retrievalListeners, sector
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BasicTiledImageLayerBulkDownloader(BasicTiledImageLayer layer, Sector sector, double resolution, BulkRetrievalListener listener)
          Constructs a downloader to retrieve imagery not currently available in the World Wind file cache.
BasicTiledImageLayerBulkDownloader(BasicTiledImageLayer layer, Sector sector, double resolution, FileStore fileStore, BulkRetrievalListener listener)
          Constructs a downloader to retrieve imagery not currently available in a specified file store.
 
Method Summary
protected  void callRetrievalListeners(Retriever retriever, TextureTile tile)
           
protected  long computeAverageTileSize(File dir)
           
protected  Sector[] computeRandomRegions(Sector sector, int div, int numRegions)
           
protected  int computeRegionDivisions(Sector sector, int levelNumber, int maxCount)
           
protected  BasicTiledImageLayer.DownloadPostProcessor createBulkDownloadPostProcessor(TextureTile tile)
           
protected  long estimateAverageTileSize()
           
protected  long estimateMissingTilesCount(int numSamples)
           
protected  long getEstimatedMissingDataSize()
          Get the estimated size in byte of the missing imagery for the object's Sector, resolution and file store.
protected  ArrayList<TextureTile> getMissingTilesInSector(Sector sector, int levelNumber)
           
protected  Iterator<Sector> getRegionIterator(Sector sector, int div)
           
protected  boolean isTileLocalOrAbsent(TextureTile tile)
           
protected  void normalizeProgress()
           
protected  void removeAbsentTile(TextureTile tile)
           
protected  void removeRetrievedTile(TextureTile tile)
           
 void run()
           
protected  void submitMissingTilesRequests()
           
 
Methods inherited from class gov.nasa.worldwind.retrieve.BulkRetrievalThread
addRetrievalListener, callRetrievalListeners, getFileStore, getProgress, getResolution, getRetrievable, getSector, hasRetrievalListeners, removeRetrievalListener
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_AVERAGE_FILE_SIZE

protected static final long DEFAULT_AVERAGE_FILE_SIZE
See Also:
Constant Field Values

layer

protected final BasicTiledImageLayer layer

level

protected final int level

MAX_TILE_COUNT_PER_REGION

protected static final int MAX_TILE_COUNT_PER_REGION
See Also:
Constant Field Values

missingTiles

protected ArrayList<TextureTile> missingTiles
Constructor Detail

BasicTiledImageLayerBulkDownloader

public BasicTiledImageLayerBulkDownloader(BasicTiledImageLayer layer,
                                          Sector sector,
                                          double resolution,
                                          BulkRetrievalListener listener)
Constructs a downloader to retrieve imagery not currently available in the World Wind file cache.

The thread returned is not started during construction, the caller must start the thread.

Parameters:
layer - the layer for which to download imagery.
sector - the sector to download data for. This value is final.
resolution - the target resolution, provided in radians of latitude per texel. This value is final.
listener - an optional retrieval listener. May be null.
Throws:
IllegalArgumentException - if either the layer or sector are null, or the resolution is less than zero.

BasicTiledImageLayerBulkDownloader

public BasicTiledImageLayerBulkDownloader(BasicTiledImageLayer layer,
                                          Sector sector,
                                          double resolution,
                                          FileStore fileStore,
                                          BulkRetrievalListener listener)
Constructs a downloader to retrieve imagery not currently available in a specified file store.

The thread returned is not started during construction, the caller must start the thread.

Parameters:
layer - the layer for which to download imagery.
sector - the sector to download data for. This value is final.
resolution - the target resolution, provided in radians of latitude per texel. This value is final.
fileStore - the file store in which to place the downloaded elevations.
listener - an optional retrieval listener. May be null.
Throws:
IllegalArgumentException - if either the layer, the sector or file store are null, or the resolution is less than zero.
Method Detail

callRetrievalListeners

protected void callRetrievalListeners(Retriever retriever,
                                      TextureTile tile)

computeAverageTileSize

protected long computeAverageTileSize(File dir)

computeRandomRegions

protected Sector[] computeRandomRegions(Sector sector,
                                        int div,
                                        int numRegions)

computeRegionDivisions

protected int computeRegionDivisions(Sector sector,
                                     int levelNumber,
                                     int maxCount)

createBulkDownloadPostProcessor

protected BasicTiledImageLayer.DownloadPostProcessor createBulkDownloadPostProcessor(TextureTile tile)

estimateAverageTileSize

protected long estimateAverageTileSize()

estimateMissingTilesCount

protected long estimateMissingTilesCount(int numSamples)

getEstimatedMissingDataSize

protected long getEstimatedMissingDataSize()
Get the estimated size in byte of the missing imagery for the object's Sector, resolution and file store. Note that the target resolution must be provided in radian latitude per texel - which is the resolution in meter divided by the globe radius.

Returns:
the estimated size in byte of the missing imagery.

getMissingTilesInSector

protected ArrayList<TextureTile> getMissingTilesInSector(Sector sector,
                                                         int levelNumber)
                                                  throws InterruptedException
Throws:
InterruptedException

getRegionIterator

protected Iterator<Sector> getRegionIterator(Sector sector,
                                             int div)

isTileLocalOrAbsent

protected boolean isTileLocalOrAbsent(TextureTile tile)

normalizeProgress

protected void normalizeProgress()

removeAbsentTile

protected void removeAbsentTile(TextureTile tile)

removeRetrievedTile

protected void removeRetrievedTile(TextureTile tile)

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in class BulkRetrievalThread

submitMissingTilesRequests

protected void submitMissingTilesRequests()
                                   throws InterruptedException
Throws:
InterruptedException

NASA World Wind