NASA World Wind

gov.nasa.worldwind.terrain
Class BasicElevationModel

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.terrain.AbstractElevationModel
              extended by gov.nasa.worldwind.terrain.BasicElevationModel
All Implemented Interfaces:
AVList, ElevationModel, Restorable, Retrievable, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
WMSBasicElevationModel

public class BasicElevationModel
extends AbstractElevationModel
implements Retrievable


Nested Class Summary
protected static class BasicElevationModel.DownloadPostProcessor
           
protected static class BasicElevationModel.Elevations
           
protected static class BasicElevationModel.RequestTask
           
protected static class BasicElevationModel.Tile
           
 
Field Summary
 
Fields inherited from class gov.nasa.worldwind.terrain.AbstractElevationModel
missingDataFlag, missingDataValue
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
BasicElevationModel(AVList params)
           
BasicElevationModel(Document dom, AVList params)
           
BasicElevationModel(Element domElement, AVList params)
           
BasicElevationModel(String restorableStateInXml)
           
 
Method Summary
protected  void addTileToCache(BasicElevationModel.Tile tile, BufferWrapper elevations)
           
protected  boolean areElevationsInMemory(TileKey key)
           
 int computeLevelForResolution(Sector sector, double resolution)
           
 boolean contains(Angle latitude, Angle longitude)
          Indicates whether a specified location is within the elevation model's domain.
protected static ByteBuffer convertImageToElevations(ByteBuffer buffer, String contentType)
           
 int countTilesInSector(Sector sector, int levelNumber)
           
protected  MemoryCache createMemoryCache(String cacheName)
           
protected  BasicElevationModel.Tile createTile(TileKey key)
           
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void doGetRestorableStateForAVPair(String key, Object value, RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  void doRestoreStateForObject(RestorableSupport rs, RestorableSupport.StateObject so)
           
protected  void downloadElevations(BasicElevationModel.Tile tile)
           
protected  void downloadElevations(BasicElevationModel.Tile tile, BasicElevationModel.DownloadPostProcessor postProcessor)
           
 ByteBuffer generateExtremeElevations(int levelNumber)
           
 double getBestResolution(Sector sector)
          Indicates the best resolution attainable for a specified sector.
 double getDetailHint(Sector sector)
          Returns the detail hint associated with the specified sector.
 String getElevationDataByteOrder()
           
 String getElevationDataPixelType()
           
protected  BasicElevationModel.Elevations getElevations(Sector sector, LevelSet levelSet, int targetLevelNumber)
           
 double getElevations(Sector sector, List<? extends LatLon> latlons, double targetResolution, double[] buffer)
          Returns the elevations of a collection of locations.
 long getEstimatedMissingDataSize(Sector sector, double resolution)
          Get the estimated size in byte of the missing elevation data for the given Sector and resolution.
 double[] getExtremeElevations(Angle latitude, Angle longitude)
          Returns the minimum and maximum elevations at a specified location.
 double[] getExtremeElevations(Sector sector)
          Returns the minimum and maximum elevations within a specified sector of the elevation model.
protected  BufferWrapper getExtremes()
           
protected  int getExtremesLevel()
           
 LevelSet getLevels()
           
protected  Map<TileKey,BasicElevationModel.Tile> getLevelZeroTiles()
           
 double getMaxElevation()
          Returns the maximum elevation contained in the elevevation model.
protected  MemoryCache getMemoryCache()
           
 double getMinElevation()
          Returns the minimum elevation contained in the elevevation model.
protected static AVList getParamsFromDocument(Element domElement, AVList params)
           
 String getRestorableState()
          Returns an XML document string describing the object’s state.
protected  Level getTargetLevel(Sector sector, double targetSize)
           
protected  BasicElevationModel.Tile getTileFromMemory(TileKey tileKey)
           
 BasicElevationModel.Tile[][] getTilesInSector(Sector sector, int levelNumber)
           
 double getUnmappedElevation(Angle latitude, Angle longitude)
          Returns the elevation at a specified location, but without mapping missing data to the elevation model's missing data replacement value.
 int intersects(Sector sector)
          Indicates whether the elevation model corresponds to a specified sector.
protected  boolean loadElevations(BasicElevationModel.Tile tile, URL url)
           
 void loadExtremeElevations(String extremesFileName)
           
protected  double lookupElevation(double latRadians, double lonRadians, BasicElevationModel.Tile tile)
           
 BulkDownloadThread makeLocal(Sector sector, double resolution)
          Start a new BulkDownloadThread that will try to download all elevation tiles for a given Sector and resolution.
protected  BufferWrapper readElevations(URL url)
           
protected  void requestTile(TileKey key)
           
protected static AVList restorableStateToParams(String stateInXml)
           
 void restoreState(String stateInXml)
          Restores the object’s state to what is described in the specified XML document string.
protected static void restoreStateForParams(RestorableSupport rs, RestorableSupport.StateObject context, AVList params)
           
 void setByteOrder(String byteOrder)
           
 void setDetailHint(double hint)
           
protected static void setFallbacks(AVList params)
           
 void setPixelType(String pixelType)
           
 
Methods inherited from class gov.nasa.worldwind.terrain.AbstractElevationModel
getElevation, getMissingDataReplacement, getMissingDataSignal, getName, isNetworkRetrievalEnabled, setMissingDataReplacement, setMissingDataSignal, setName, setNetworkRetrievalEnabled, toString
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.retrieve.Retrievable
getName
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 

Constructor Detail

BasicElevationModel

public BasicElevationModel(AVList params)

BasicElevationModel

public BasicElevationModel(Document dom,
                           AVList params)

BasicElevationModel

public BasicElevationModel(Element domElement,
                           AVList params)

BasicElevationModel

public BasicElevationModel(String restorableStateInXml)
Method Detail

addTileToCache

protected void addTileToCache(BasicElevationModel.Tile tile,
                              BufferWrapper elevations)

areElevationsInMemory

protected boolean areElevationsInMemory(TileKey key)

computeLevelForResolution

public int computeLevelForResolution(Sector sector,
                                     double resolution)

contains

public boolean contains(Angle latitude,
                        Angle longitude)
Description copied from interface: ElevationModel
Indicates whether a specified location is within the elevation model's domain.

Specified by:
contains in interface ElevationModel
Parameters:
latitude - the latitude of the location in question.
longitude - the longitude of the location in question.
Returns:
true if the location is within the elevation model's domain, otherwise false.

convertImageToElevations

protected static ByteBuffer convertImageToElevations(ByteBuffer buffer,
                                                     String contentType)
                                              throws IOException
Throws:
IOException

countTilesInSector

public int countTilesInSector(Sector sector,
                              int levelNumber)

createMemoryCache

protected MemoryCache createMemoryCache(String cacheName)

createTile

protected BasicElevationModel.Tile createTile(TileKey key)

doGetRestorableState

protected void doGetRestorableState(RestorableSupport rs,
                                    RestorableSupport.StateObject context)

doGetRestorableStateForAVPair

protected void doGetRestorableStateForAVPair(String key,
                                             Object value,
                                             RestorableSupport rs,
                                             RestorableSupport.StateObject context)

doRestoreState

protected void doRestoreState(RestorableSupport rs,
                              RestorableSupport.StateObject context)

doRestoreStateForObject

protected void doRestoreStateForObject(RestorableSupport rs,
                                       RestorableSupport.StateObject so)

downloadElevations

protected void downloadElevations(BasicElevationModel.Tile tile)

downloadElevations

protected void downloadElevations(BasicElevationModel.Tile tile,
                                  BasicElevationModel.DownloadPostProcessor postProcessor)

generateExtremeElevations

public ByteBuffer generateExtremeElevations(int levelNumber)

getBestResolution

public double getBestResolution(Sector sector)
Description copied from interface: ElevationModel
Indicates the best resolution attainable for a specified sector.

Specified by:
getBestResolution in interface ElevationModel
Parameters:
sector - the sector in question. If null, the elevation model's best overall resolution is returned. This is the best attainable at some locations but not necessarily at all locations.
Returns:
the best resolution attainable for the specified sector, in radians, or Double.MAX_VALUE if the sector does not intersect the elevation model.

getDetailHint

public double getDetailHint(Sector sector)
Description copied from interface: ElevationModel
Returns the detail hint associated with the specified sector. If the elevation model does not have any detail hint for the sector, this will return zero.

Specified by:
getDetailHint in interface ElevationModel
Overrides:
getDetailHint in class AbstractElevationModel
Parameters:
sector - the sector in question.
Returns:
The detail hint corresponding to the specified sector.

getElevationDataByteOrder

public String getElevationDataByteOrder()

getElevationDataPixelType

public String getElevationDataPixelType()

getElevations

protected BasicElevationModel.Elevations getElevations(Sector sector,
                                                       LevelSet levelSet,
                                                       int targetLevelNumber)

getElevations

public double getElevations(Sector sector,
                            List<? extends LatLon> latlons,
                            double targetResolution,
                            double[] buffer)
Description copied from interface: ElevationModel
Returns the elevations of a collection of locations.

The missing-data sentinel value, if previously specified, is returned for locations at which an elevation cannot be determined. if a missing-data value has not been specified, an elevation-model specific value, typically zero, is returned.

Specified by:
getElevations in interface ElevationModel
Parameters:
sector - the sector in question.
latlons - the locations to return elevations for. A value of zero is returned if a location is null.
targetResolution - the desired horizontal resolution, in radians, of the raster or other elevation sample from which elevations are drawn. (To compute radians from a distance, divide the distance by the radius of the globe, ensuring that both the distance and the radius are in the same units.)
buffer - an array in which to place the returned elevations. The array must be pre-allocated and contain at least as many elements as the list of locations.
Returns:
the resolution achieved, in radians, or Double.MAX_VALUE if individual elevations cannot be determined for any of the locations.
See Also:
#setMissingValueSentinel(Double)

getEstimatedMissingDataSize

public long getEstimatedMissingDataSize(Sector sector,
                                        double resolution)
Get the estimated size in byte of the missing elevation data for the given Sector and resolution. Note that the target resolution must be provided in radian latitude per data sample - which is the resolution in meter divided by the globe radius.

Specified by:
getEstimatedMissingDataSize in interface Retrievable
Parameters:
sector - the Sector to estimate.
resolution - the target resolution provided in radian latitude per texel.
Returns:
the estimated size in byte of the missing imagery.

getExtremeElevations

public double[] getExtremeElevations(Angle latitude,
                                     Angle longitude)
Description copied from interface: ElevationModel
Returns the minimum and maximum elevations at a specified location.

Specified by:
getExtremeElevations in interface ElevationModel
Parameters:
latitude - the latitude of the location in question.
longitude - the longitude of the location in question.
Returns:
A two-element double array indicating the minimum and maximum elevations at the specified location, respectively. These values are the global minimum and maximum if the local minimum and maximum values are currently unknown.

getExtremeElevations

public double[] getExtremeElevations(Sector sector)
Description copied from interface: ElevationModel
Returns the minimum and maximum elevations within a specified sector of the elevation model.

Specified by:
getExtremeElevations in interface ElevationModel
Parameters:
sector - the sector in question.
Returns:
A two-element double array indicating the sector's minimum and maximum elevations, respectively. These elements are the global minimum and maximum if the local minimum and maximum values are currently unknown.

getExtremes

protected BufferWrapper getExtremes()

getExtremesLevel

protected int getExtremesLevel()

getLevels

public LevelSet getLevels()

getLevelZeroTiles

protected Map<TileKey,BasicElevationModel.Tile> getLevelZeroTiles()

getMaxElevation

public double getMaxElevation()
Description copied from interface: ElevationModel
Returns the maximum elevation contained in the elevevation model. When the elevation model is associated with a globe, this value is the elevation of the highest point on the globe.

Specified by:
getMaxElevation in interface ElevationModel
Returns:
The maximum elevation of the elevation model.

getMemoryCache

protected MemoryCache getMemoryCache()

getMinElevation

public double getMinElevation()
Description copied from interface: ElevationModel
Returns the minimum elevation contained in the elevevation model. When associated with a globe, this value is the elevation of the lowest point on the globe. It may be negative, indicating a value below mean surface level. (Sea level in the case of Earth.)

Specified by:
getMinElevation in interface ElevationModel
Returns:
The minimum elevation of the model.

getParamsFromDocument

protected static AVList getParamsFromDocument(Element domElement,
                                              AVList params)

getRestorableState

public String getRestorableState()
Description copied from interface: Restorable
Returns an XML document string describing the object’s state. This state can be restored later by calling restoreState and passing the XML document.

Specified by:
getRestorableState in interface Restorable
Overrides:
getRestorableState in class AbstractElevationModel
Returns:
an XML document string describing the object's state.

getTargetLevel

protected Level getTargetLevel(Sector sector,
                               double targetSize)

getTileFromMemory

protected BasicElevationModel.Tile getTileFromMemory(TileKey tileKey)

getTilesInSector

public BasicElevationModel.Tile[][] getTilesInSector(Sector sector,
                                                     int levelNumber)

getUnmappedElevation

public double getUnmappedElevation(Angle latitude,
                                   Angle longitude)
Description copied from interface: ElevationModel
Returns the elevation at a specified location, but without mapping missing data to the elevation model's missing data replacement value. In the case of missing data values, the missing data signal is returned rather than the missing data replacement value. *

Specified by:
getUnmappedElevation in interface ElevationModel
Parameters:
latitude - the latitude of the location for which to return the elevation.
longitude - the longitude of the location for which to return the elevation.
Returns:
the elevation at the specified location, or the elevation model's missing data signal. If no data is currently available for the location, the elevation model's global minimum elevation at that location is returned.

intersects

public int intersects(Sector sector)
Description copied from interface: ElevationModel
Indicates whether the elevation model corresponds to a specified sector.

Specified by:
intersects in interface ElevationModel
Parameters:
sector - the sector in question.
Returns:
0 if the elevation model fully contains the sector, 1 if the elevation model intersects the sector but does not fully contain it, or -1 if the elevation does not intersect the elevation model.

loadElevations

protected boolean loadElevations(BasicElevationModel.Tile tile,
                                 URL url)
                          throws IOException
Throws:
IOException

loadExtremeElevations

public void loadExtremeElevations(String extremesFileName)

lookupElevation

protected double lookupElevation(double latRadians,
                                 double lonRadians,
                                 BasicElevationModel.Tile tile)

makeLocal

public BulkDownloadThread makeLocal(Sector sector,
                                    double resolution)
Start a new BulkDownloadThread that will try to download all elevation tiles for a given Sector and resolution. Note that the target resolution must be provided in radian latitude per texel - which is the resolution in meter divided by the globe radius.

Specified by:
makeLocal in interface Retrievable
Parameters:
sector - the Sector to download tiles for.
resolution - the target resolution provided in radian latitude per texel.
Returns:
the BulkDownloadThread that executes the retrieval.

readElevations

protected BufferWrapper readElevations(URL url)
                                throws IOException
Throws:
IOException

requestTile

protected void requestTile(TileKey key)

restorableStateToParams

protected static AVList restorableStateToParams(String stateInXml)

restoreState

public void restoreState(String stateInXml)
Description copied from interface: Restorable
Restores the object’s state to what is described in the specified XML document string.

Specified by:
restoreState in interface Restorable
Overrides:
restoreState in class AbstractElevationModel
Parameters:
stateInXml - an XML document string describing an object's state.

restoreStateForParams

protected static void restoreStateForParams(RestorableSupport rs,
                                            RestorableSupport.StateObject context,
                                            AVList params)

setByteOrder

public void setByteOrder(String byteOrder)

setDetailHint

public void setDetailHint(double hint)

setFallbacks

protected static void setFallbacks(AVList params)

setPixelType

public void setPixelType(String pixelType)

NASA World Wind