Package gov.nasa.worldwind.terrain
Class AbstractElevationModel
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.terrain.AbstractElevationModel
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,ElevationModel
,Restorable
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
BasicElevationModel
,BathymetryFilterElevationModel
,CompoundElevationModel
,LocalElevationModel
,ZeroElevationModel
public abstract class AbstractElevationModel extends WWObjectImpl implements ElevationModel
-
-
Field Summary
Fields Modifier and Type Field Description protected FileStore
dataFileStore
protected boolean
enabled
protected long
expiryTime
protected double
missingDataFlag
protected double
missingDataValue
protected boolean
networkRetrievalEnabled
-
Constructor Summary
Constructors Constructor Description AbstractElevationModel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
composeElevations(Sector sector, java.util.List<? extends LatLon> latlons, int tileWidth, double[] buffer)
Determines the elevations at specified locations within a specifiedSector
.static org.w3c.dom.Element
createElevationModelConfigElements(AVList params, org.w3c.dom.Element context)
Appends elevation model configuration parameters as elements to the specified context.void
dispose()
Disposes of any internal resources allocated by the object.double[]
getBestResolutions(Sector sector)
FileStore
getDataFileStore()
double
getDetailHint(Sector sector)
Returns the detail hint associated with the specified sector.double
getElevation(Angle latitude, Angle longitude)
Returns the elevation at a specified location.static AVList
getElevationModelConfigParams(org.w3c.dom.Element domElement, AVList params)
Parses elevation model configuration parameters from the specified DOM document.double[]
getElevations(Sector sector, java.util.List<? extends LatLon> latLons, double[] targetResolutions, double[] elevations)
Returns the elevations of a collection of locations.long
getExpiryTime()
Returns the current expiry time.double
getLocalDataAvailability(Sector sector, java.lang.Double targetResolution)
Returns the proportion of this elevation model's data that is local -- in the computer's data cache or installed data filestore -- for a specified sector and target resolution.double
getMissingDataReplacement()
Returns the elevation used for missing values in the elevation model.double
getMissingDataSignal()
Returns the current missing-data signal.java.lang.String
getName()
Returns the elevation model's name.java.lang.String
getRestorableState()
Returns an XML document string describing the object's state.double[]
getUnmappedElevations(Sector sector, java.util.List<? extends LatLon> latLons, double[] targetResolutions, double[] elevations)
Returns the elevations of a collection of locations.double
getUnmappedLocalSourceElevation(Angle latitude, Angle longitude)
Returns the elevation for this elevation model's highest level of detail if the source file for that level and the specified location exists in the local elevation cache on disk.static boolean
isElevationModelConfigDocument(org.w3c.dom.Element domElement)
Returns true if a specified DOM document is an ElevationModel configuration document, and false otherwise.boolean
isEnabled()
Indicates whether this elevation model is used or ignored.boolean
isNetworkRetrievalEnabled()
Indicates whether the elevation model is allowed to retrieve data from the network.protected boolean
isTransparentValue(java.lang.Double value)
void
restoreState(java.lang.String stateInXml)
Restores the object's state to what is described in the specified XML document string.void
setDataFileStore(FileStore dataFileStore)
void
setEnabled(boolean enabled)
Indicates whether this elevation model is used or ignored.void
setExpiryTime(long expiryTime)
Specifies the time of the elevation model's most recent dataset update.void
setMissingDataReplacement(double missingDataValue)
Specifies the elevation used for missing values in the elevation model.void
setMissingDataSignal(double missingDataFlag)
Specifies the value used to identify missing data in an elevation model.void
setName(java.lang.String name)
Set the elevation model's name.void
setNetworkRetrievalEnabled(boolean enabled)
Controls whether the elevation model is allowed to retrieve data from the network.java.lang.String
toString()
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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 gov.nasa.worldwind.globes.ElevationModel
contains, getBestResolution, getElevations, getExtremeElevations, getExtremeElevations, getMaxElevation, getMinElevation, getUnmappedElevation, getUnmappedElevations, intersects, isExtremesCachingEnabled, setExtremesCachingEnabled
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
dataFileStore
protected FileStore dataFileStore
-
missingDataFlag
protected double missingDataFlag
-
missingDataValue
protected double missingDataValue
-
networkRetrievalEnabled
protected boolean networkRetrievalEnabled
-
expiryTime
protected long expiryTime
-
enabled
protected boolean enabled
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:Disposable
Disposes of any internal resources allocated by the object.- Specified by:
dispose
in interfaceDisposable
-
getName
public java.lang.String getName()
Description copied from interface:ElevationModel
Returns the elevation model's name.- Specified by:
getName
in interfaceElevationModel
- Returns:
- the elevation model's name.
- See Also:
ElevationModel.setName(String)
-
setName
public void setName(java.lang.String name)
Description copied from interface:ElevationModel
Set the elevation model's name. The name is a convenience attribute typically used to identify the elevation model in user interfaces. By default, an elevation model has no name.- Specified by:
setName
in interfaceElevationModel
- Parameters:
name
- the name to give the elevation model.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isNetworkRetrievalEnabled
public boolean isNetworkRetrievalEnabled()
Description copied from interface:ElevationModel
Indicates whether the elevation model is allowed to retrieve data from the network. Some elevation models have no need to retrieve data from the network. This flag is meaningless for such elevation models.- Specified by:
isNetworkRetrievalEnabled
in interfaceElevationModel
- Returns:
true
if the elevation model is enabled to retrieve network data, elsefalse
.
-
setNetworkRetrievalEnabled
public void setNetworkRetrievalEnabled(boolean enabled)
Description copied from interface:ElevationModel
Controls whether the elevation model is allowed to retrieve data from the network. Some elevation models have no need for data from the network. This flag may be set but is meaningless for such elevation models.- Specified by:
setNetworkRetrievalEnabled
in interfaceElevationModel
- Parameters:
enabled
-true
if network retrieval is allowed, elsefalse
.
-
getExpiryTime
public long getExpiryTime()
Description copied from interface:ElevationModel
Returns the current expiry time.- Specified by:
getExpiryTime
in interfaceElevationModel
- Returns:
- the current expiry time.
- See Also:
ElevationModel.setExpiryTime(long)
-
setExpiryTime
public void setExpiryTime(long expiryTime)
Description copied from interface:ElevationModel
Specifies the time of the elevation model's most recent dataset update. If greater than zero, the model ignores and eliminates any previously cached data older than the time specified, and requests new information from the data source. If zero, the model uses any expiry times intrinsic to the model, typically initialized at model construction. The default expiry time is 0, thereby enabling a model's intrinsic expiration criteria.- Specified by:
setExpiryTime
in interfaceElevationModel
- Parameters:
expiryTime
- the expiry time of any cached data, expressed as a number of milliseconds beyond the epoch.- See Also:
for a description of milliseconds beyond the epoch.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:ElevationModel
Indicates whether this elevation model is used or ignored.- Specified by:
setEnabled
in interfaceElevationModel
- Parameters:
enabled
- true if this elevation model is used, otherwise false.
-
isEnabled
public boolean isEnabled()
Description copied from interface:ElevationModel
Indicates whether this elevation model is used or ignored.- Specified by:
isEnabled
in interfaceElevationModel
- Returns:
- true if this elevation model is used, otherwise false.
-
getMissingDataSignal
public double getMissingDataSignal()
Description copied from interface:ElevationModel
Returns the current missing-data signal.- Specified by:
getMissingDataSignal
in interfaceElevationModel
- Returns:
- the missing-data signal.
- See Also:
ElevationModel.getMissingDataReplacement()
-
setMissingDataSignal
public void setMissingDataSignal(double missingDataFlag)
Description copied from interface:ElevationModel
Specifies the value used to identify missing data in an elevation model. Locations with this elevation value are assigned the missing-data replacement value, specified byElevationModel.setMissingDataReplacement(double)
.The missing-data value is often specified by the metadata of the data set, in which case the elevation model automatically defines that value to be the missing-data signal. When the missing-data signal is not specified in the metadata, the application may specify it via this method.
- Specified by:
setMissingDataSignal
in interfaceElevationModel
- Parameters:
missingDataFlag
- the missing-data signal value. The default is -Double.MAX_VALUE
.- See Also:
ElevationModel.setMissingDataReplacement(double)
,ElevationModel.getMissingDataSignal()
-
getMissingDataReplacement
public double getMissingDataReplacement()
Description copied from interface:ElevationModel
Returns the elevation used for missing values in the elevation model.- Specified by:
getMissingDataReplacement
in interfaceElevationModel
- Returns:
- the value that indicates that no data is available at a location.
- See Also:
ElevationModel.setMissingDataSignal(double)
,ElevationModel.getMissingDataSignal()
-
setMissingDataReplacement
public void setMissingDataReplacement(double missingDataValue)
Description copied from interface:ElevationModel
Specifies the elevation used for missing values in the elevation model.- Specified by:
setMissingDataReplacement
in interfaceElevationModel
- Parameters:
missingDataValue
- the value that indicates that no data is available at a location.- See Also:
ElevationModel.setMissingDataSignal(double)
-
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 method returns zero.- Specified by:
getDetailHint
in interfaceElevationModel
- Parameters:
sector
- the sector in question.- Returns:
- The detail hint corresponding to the specified sector.
-
getDataFileStore
public FileStore getDataFileStore()
-
setDataFileStore
public void setDataFileStore(FileStore dataFileStore)
-
getElevation
public double getElevation(Angle latitude, Angle longitude)
Description copied from interface:ElevationModel
Returns the elevation at a specified location. If the elevation at the specified location is the elevation model's missing data signal, or if the location specified is outside the elevation model's coverage area, the elevation model's missing data replacement value is returned.The elevation returned from this method is the best available in memory. If no elevation is in memory, the elevation model's minimum extreme elevation at the location is returned. Local disk caches are not consulted.
- Specified by:
getElevation
in interfaceElevationModel
- Parameters:
latitude
- the latitude of the location in question.longitude
- the longitude of the location in question.- Returns:
- The elevation corresponding to the specified location, or the elevation model's missing-data replacement value if there is no elevation for the given location.
- See Also:
ElevationModel.setMissingDataSignal(double)
,ElevationModel.getUnmappedElevation(gov.nasa.worldwind.geom.Angle, gov.nasa.worldwind.geom.Angle)
-
getElevations
public double[] getElevations(Sector sector, java.util.List<? extends LatLon> latLons, double[] targetResolutions, double[] elevations)
Description copied from interface:ElevationModel
Returns the elevations of a collection of locations. Replaces any elevation values corresponding to the missing data signal with the elevation model's missing data replacement value. If a location within the elevation model's coverage area cannot currently be determined, the elevation model's minimum extreme elevation for that location is returned in the output buffer. If a location is outside the elevation model's coverage area, the output buffer for that location is not modified; it retains the buffer's original value.- Specified by:
getElevations
in interfaceElevationModel
- Parameters:
sector
- the sector in question.latLons
- the locations to return elevations for. If a location is null, the output buffer for that location is not modified.targetResolutions
- 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.) This is an array to enable specification of a target resolution per elevation model forCompoundElevationModel
. The entries must be in the same order as the elevations inCompoundElevationModel
.elevations
- 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 resolutions achieved, in radians, which will be
Double.MAX_VALUE
if individual elevations cannot be determined for all of the locations. The entries are in the same order as the elevations inCompoundElevationModel
. - See Also:
ElevationModel.setMissingDataSignal(double)
-
getUnmappedElevations
public double[] getUnmappedElevations(Sector sector, java.util.List<? extends LatLon> latLons, double[] targetResolutions, double[] elevations)
Description copied from interface:ElevationModel
Returns the elevations of a collection of locations. Does not replace any elevation values corresponding to the missing data signal with the elevation model's missing data replacement value. If a location within the elevation model's coverage area cannot currently be determined, the elevation model's minimum extreme elevation for that location is returned in the output buffer. If a location is outside the elevation model's coverage area, the output buffer for that location is not modified; it retains the buffer's original value.- Specified by:
getUnmappedElevations
in interfaceElevationModel
- Parameters:
sector
- the sector in question.latLons
- the locations to return elevations for. If a location is null, the output buffer for that location is not modified.targetResolutions
- 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.) This is an array to enable specification of a target resolution per elevation model forCompoundElevationModel
. The entries must be in the same order as the elevations inCompoundElevationModel
.elevations
- 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 resolutions achieved, in radians, which will be
Double.MAX_VALUE
if individual elevations cannot be determined for all of the locations. The entries are in the same order as the elevations inCompoundElevationModel
. - See Also:
ElevationModel.setMissingDataSignal(double)
-
getBestResolutions
public double[] getBestResolutions(Sector sector)
- Specified by:
getBestResolutions
in interfaceElevationModel
-
getRestorableState
public java.lang.String getRestorableState()
Description copied from interface:Restorable
Returns an XML document string describing the object's state. This state can be restored later by callingrestoreState
and passing the XML document.- Specified by:
getRestorableState
in interfaceRestorable
- Returns:
- an XML document string describing the object's state.
-
restoreState
public void restoreState(java.lang.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 interfaceRestorable
- Parameters:
stateInXml
- an XML document string describing an object's state.
-
composeElevations
public void composeElevations(Sector sector, java.util.List<? extends LatLon> latlons, int tileWidth, double[] buffer) throws java.lang.Exception
Description copied from interface:ElevationModel
Determines the elevations at specified locations within a specifiedSector
.- Specified by:
composeElevations
in interfaceElevationModel
- Parameters:
sector
- the sector containing the locations.latlons
- the locations for which to return elevations.tileWidth
- the number of locations that comprise one row in thelatlons
argument.buffer
- a buffer in which to put the elevations. The buffer must have at least as many elements as the number of specified locations.- Throws:
java.lang.Exception
- if the method fails. Different elevation models may fail for different reasons.java.lang.IllegalArgumentException
- if either the sector, list of locations or buffer is null, if the buffer size is not at least as large as the location list, or the tile width is greater than the locations list length or less than 1.
-
isTransparentValue
protected boolean isTransparentValue(java.lang.Double value)
-
isElevationModelConfigDocument
public static boolean isElevationModelConfigDocument(org.w3c.dom.Element domElement)
Returns true if a specified DOM document is an ElevationModel configuration document, and false otherwise.- Parameters:
domElement
- the DOM document in question.- Returns:
- true if the document is an ElevationModel configuration document; false otherwise.
- Throws:
java.lang.IllegalArgumentException
- if document is null.
-
createElevationModelConfigElements
public static org.w3c.dom.Element createElevationModelConfigElements(AVList params, org.w3c.dom.Element context)
Appends elevation model configuration parameters as elements to the specified context. This appends elements for the following parameters:Parameters Parameter Element Path Type AVKey.DISPLAY_NAME
DisplayName String AVKey.NETWORK_RETRIEVAL_ENABLED
NetworkRetrievalEnabled Boolean AVKey.MISSING_DATA_SIGNAL
MissingData/@signal Double AVKey.MISSING_DATA_REPLACEMENT
MissingData/@replacement Double AVKey.DETAIL_HINT
DataDetailHint Double - Parameters:
params
- the key-value pairs which define the elevation model configuration parameters.context
- the XML document root on which to append elevation model configuration elements.- Returns:
- a reference to context.
- Throws:
java.lang.IllegalArgumentException
- if either the parameters or the context are null.
-
getElevationModelConfigParams
public static AVList getElevationModelConfigParams(org.w3c.dom.Element domElement, AVList params)
Parses elevation model configuration parameters from the specified DOM document. This writes output as key-value pairs to params. If a parameter from the XML document already exists in params, that parameter is ignored. Supported parameters are:Parameters Parameter Element Path Type AVKey.DISPLAY_NAME
DisplayName String AVKey.NETWORK_RETRIEVAL_ENABLED
NetworkRetrievalEnabled Boolean AVKey.MISSING_DATA_SIGNAL
MissingData/@signal Double AVKey.MISSING_DATA_REPLACEMENT
MissingData/@replacement Double AVKey.DETAIL_HINT
DataDetailHint Double - Parameters:
domElement
- the XML document root to parse for elevation model configuration elements.params
- the output key-value pairs which recieve the elevation model configuration parameters. A null reference is permitted.- Returns:
- a reference to params, or a new AVList if params is null.
- Throws:
java.lang.IllegalArgumentException
- if the document is null.
-
getLocalDataAvailability
public double getLocalDataAvailability(Sector sector, java.lang.Double targetResolution)
Description copied from interface:ElevationModel
Returns the proportion of this elevation model's data that is local -- in the computer's data cache or installed data filestore -- for a specified sector and target resolution.- Specified by:
getLocalDataAvailability
in interfaceElevationModel
- Parameters:
sector
- the sector of interest.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.) Specify null to use this elevation model's best resolution.- Returns:
- the fraction of the data that is local. A value of 1.0 indicates that all the data is available.
-
getUnmappedLocalSourceElevation
public double getUnmappedLocalSourceElevation(Angle latitude, Angle longitude)
Description copied from interface:ElevationModel
Returns the elevation for this elevation model's highest level of detail if the source file for that level and the specified location exists in the local elevation cache on disk. This method is useful only when an elevation dataset has been pre-cached.- Specified by:
getUnmappedLocalSourceElevation
in interfaceElevationModel
- Parameters:
latitude
- The latitude of the location whose elevation is desired.longitude
- The longitude of the location whose elevation is desired.- Returns:
- The elevation at the specified location, if that location is contained in this elevation model and the
source file for the highest-resolution elevation at that location exists in the current disk cache. Otherwise
this elevation model's missing data signal is returned (see
ElevationModel.getMissingDataSignal()
).
-
-