public class HighResolutionTerrain extends WWObjectImpl implements Terrain
Modifier and Type | Class and Description |
---|---|
static interface |
HighResolutionTerrain.IntersectionCallback
Defines an interface for returning computed intersections.
|
protected static class |
HighResolutionTerrain.RectTile
Defines an internal terrain tile.
|
protected static class |
HighResolutionTerrain.RenderInfo
Holds a tile's geometry.
|
Modifier and Type | Field and Description |
---|---|
protected static long |
DEFAULT_CACHE_CAPACITY |
protected static int |
DEFAULT_DENSITY |
protected int |
density |
protected MemoryCache |
geometryCache |
protected Globe |
globe |
protected double |
latTileSize |
protected double |
lonTileSize |
protected int |
numCols |
protected int |
numRows |
protected Sector |
sector |
protected java.lang.ThreadLocal<java.lang.Long> |
startTime |
protected double |
targetResolution |
protected java.lang.Long |
timeout |
protected boolean |
useCachedElevationsOnly
Indicates whether cached elevations are used exclusively.
|
protected double |
verticalExaggeration |
Constructor and Description |
---|
HighResolutionTerrain(Globe globe,
java.lang.Double targetResolution)
Constructs a terrain object for a specified globe.
|
HighResolutionTerrain(Globe globe,
Sector sector,
java.lang.Double targetResolution,
java.lang.Double verticalExaggeration)
Constructs a terrain object for a specified sector of a specified globe.
|
Modifier and Type | Method and Description |
---|---|
protected Vec4 |
applyOffset(Vec4 point,
double metersOffset)
Applies a specified vertical offset to a surface point.
|
protected HighResolutionTerrain.RenderInfo |
buildVerts(HighResolutionTerrain.RectTile tile)
Computes a terrain tile's vertices.
|
void |
cacheIntersectingTiles(Position pA,
Position pB)
Cause the tiles used by subsequent intersection calculations to be cached so that they are available immediately
to those subsequent calculations.
|
void |
cacheIntersectingTiles(Sector sector)
Cause the tiles used by subsequent intersection calculations to be cached so that they are available immediately
to those subsequent calculations.
|
protected int |
computeColumn(Sector range,
Angle longitude)
Computes the column index corresponding to a specified latitude.
|
protected void |
computeDimensions()
Computes the row and column dimensions of the tile array.
|
protected java.util.ArrayList<LatLon> |
computeLocations(HighResolutionTerrain.RectTile tile)
Computes the tile's cell locations, determined by the tile's density and sector.
|
protected int |
computeRow(Sector range,
Angle latitude)
Computes the row index corresponding to a specified latitude.
|
protected void |
convertPointsToPositions(java.util.List<Vec4[]> points,
java.util.List<Position[]> positions) |
protected static double |
createPosition(int start,
double decimal,
int density) |
protected HighResolutionTerrain.RectTile |
createTile(int row,
int col)
Creates a tile for a specified row and column of the tile array.
|
protected HighResolutionTerrain.RectTile |
createTile(Sector tileSector)
Creates the tile for a specified sector.
|
protected void |
doGetIntersectingTiles(int r0,
int c0,
int r1,
int c1,
Line line,
java.util.List<HighResolutionTerrain.RectTile> tiles) |
protected Intersection[] |
doIntersect(Position pA,
Position pB)
Computes intersections of a line with the terrain.
|
protected java.util.List<HighResolutionTerrain.RectTile> |
eliminateLowAltitudeTiles(java.util.List<HighResolutionTerrain.RectTile> tiles,
double minAltitude) |
long |
getCacheCapacity()
Indicates the current cache capacity.
|
protected void |
getCachedElevations(java.util.List<LatLon> latlons,
double[] elevations) |
double |
getCacheUsage()
Indicates the proportion of the cache currently used.
|
protected HighResolutionTerrain.RectTile |
getContainingTile(Angle latitude,
Angle longitude)
Determines the tile that contains a specified location.
|
int |
getDensity() |
java.lang.Double |
getElevation(LatLon location)
Computes the elevation at a specified location.
|
protected void |
getElevations(Sector sector,
java.util.List<LatLon> latlons,
double[] targetResolution,
double[] elevations) |
Position[] |
getExtremeElevations(LatLon center,
double width,
double height)
Determines the minimum and maximum elevations and their locations within a specified geographic quadrilateral.
|
Position[] |
getExtremeElevations(Sector sector)
Determines the minimum and maximum elevations and their locations within a specified
Sector . |
Globe |
getGlobe()
Returns the object's globe.
|
protected java.util.List<HighResolutionTerrain.RectTile> |
getIntersectingTiles(Position pA,
Position pB,
Line line)
Determines and creates the terrain tiles intersected by a specified line.
|
protected java.util.List<HighResolutionTerrain.RectTile> |
getIntersectingTiles(Sector sector) |
java.util.List<Sector> |
getIntersectionTiles(Position pA,
Position pB) |
int |
getNumCacheEntries()
Returns the number of entries currently in the cache.
|
Sector |
getSector()
Returns the object's sector.
|
Vec4 |
getSurfacePoint(Angle latitude,
Angle longitude,
double metersOffset)
Computes the Cartesian, model-coordinate point of a location on the terrain.
|
protected Vec4 |
getSurfacePoint(HighResolutionTerrain.RectTile tile,
Angle latitude,
Angle longitude)
Computes the Cartesian, model-coordinate point of a location within a terrain tile.
|
protected Vec4 |
getSurfacePoint(HighResolutionTerrain.RectTile tile,
Angle latitude,
Angle longitude,
double metersOffset)
Computes the Cartesian, model-coordinate point of a location within a terrain tile.
|
Vec4 |
getSurfacePoint(Position position)
Computes the Cartesian, model-coordinate point of a position on the terrain.
|
double |
getTargetResolution() |
java.lang.Long |
getTimeout()
Indicates the current timeout for operations requiring terrain data retrieval.
|
double |
getVerticalExaggeration()
Indicates the vertical exaggeration used when performing terrain operations.
|
protected static Vec4 |
interpolate(int row,
int column,
double xDec,
double yDec,
HighResolutionTerrain.RenderInfo ri) |
protected static Vec4 |
interpolate(Vec4 bL,
Vec4 bR,
Vec4 tR,
Vec4 tL,
double xDec,
double yDec) |
protected Intersection[] |
intersect(HighResolutionTerrain.RectTile tile,
Line line)
Computes the intersections of a line with a tile.
|
protected java.util.List<Vec4[]> |
intersect(HighResolutionTerrain.RectTile tile,
Vec4[] triangle)
Computes the intersection of a triangle with a terrain tile.
|
void |
intersect(java.util.List<Position> positions,
HighResolutionTerrain.IntersectionCallback callback)
Intersects a specified list of geographic two-position lines with the terrain.
|
Intersection[] |
intersect(Position pA,
Position pB)
Computes the intersections of a line with the terrain.
|
Intersection[] |
intersect(Position pA,
Position pB,
int altitudeMode)
Computes the intersections of a line with the terrain.
|
void |
intersectTriangle(Vec4[] triangleCoordinates,
Position[] trianglePositions,
java.util.List<Position[]> intersectPositionsOut)
Intersects a specified triangle with the terrain.
|
boolean |
isUseCachedElevationsOnly()
Indicates whether cached elevations are used exclusively.
|
protected Line |
makeLineFromPositions(Position pA,
Position pB) |
protected void |
makeVerts(HighResolutionTerrain.RectTile tile)
Computes a terrain tile's vertices of draws them from the cache.
|
protected boolean |
resolutionsMeetCriteria(double[] actualResolution,
double[] targetResolution) |
void |
setCacheCapacity(long size)
Specifies the cache capacity.
|
void |
setDensity(int density)
Specifies the number of intervals within a single terrain tile.
|
void |
setTimeout(java.lang.Long timeout)
Specifies the maximum amount of time allowed for retrieval of all terrain data necessary to satisfy an operation.
|
void |
setUseCachedElevationsOnly(boolean tf)
Indicates whether cached elevations are used exclusively.
|
onMessage, propertyChange
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
protected static final long DEFAULT_CACHE_CAPACITY
protected static final int DEFAULT_DENSITY
protected int density
protected MemoryCache geometryCache
protected Globe globe
protected double latTileSize
protected double lonTileSize
protected int numCols
protected int numRows
protected Sector sector
protected java.lang.ThreadLocal<java.lang.Long> startTime
protected double targetResolution
protected java.lang.Long timeout
protected boolean useCachedElevationsOnly
ElevationModel.getUnmappedLocalSourceElevation(Angle, Angle)
to retrieve elevations.
This assumes that the highest-resolution elevations for the elevation model are cached locally.protected double verticalExaggeration
public HighResolutionTerrain(Globe globe, java.lang.Double targetResolution)
globe
- the terrain's globe.targetResolution
- the target terrain resolution, in meters, or null to use the globe's highest resolution.java.lang.IllegalArgumentException
- if the globe is null.public HighResolutionTerrain(Globe globe, Sector sector, java.lang.Double targetResolution, java.lang.Double verticalExaggeration)
globe
- the terrain's globe.sector
- the desired range for the terrain. Only locations within this sector may be used in
operations. If null, the sector spans the entire globe.targetResolution
- the target terrain resolution, in meters, or null to use the globe's highest
resolution.verticalExaggeration
- the vertical exaggeration to apply to terrain elevations. Null indicates no
exaggeration.java.lang.IllegalArgumentException
- if the globe is null.protected Vec4 applyOffset(Vec4 point, double metersOffset)
point
- the surface point.metersOffset
- the vertical offset to add to the point.protected HighResolutionTerrain.RenderInfo buildVerts(HighResolutionTerrain.RectTile tile) throws java.lang.InterruptedException
tile
- the tile to compute vertices forjava.lang.InterruptedException
- if the operation is interrupted.WWTimeoutException
- if terrain data retrieval exceeds the current timeout.public void cacheIntersectingTiles(Position pA, Position pB) throws java.lang.InterruptedException
pA
- the line's first position.pB
- the line's second position.java.lang.IllegalArgumentException
- if either position is null.java.lang.InterruptedException
- if the operation is interrupted. if the current timeout is exceeded while
retrieving terrain data.public void cacheIntersectingTiles(Sector sector) throws java.lang.InterruptedException
sector
- the sector for which to cache elevation data.java.lang.IllegalArgumentException
- if the specified sector is null.java.lang.InterruptedException
- if the operation is interrupted. if the current timeout is exceeded while
retrieving terrain data.protected int computeColumn(Sector range, Angle longitude)
range
- the reference sector, typically that of this terrain instance.longitude
- the latitude in question.protected void computeDimensions()
protected java.util.ArrayList<LatLon> computeLocations(HighResolutionTerrain.RectTile tile)
tile
- the tile to compute locations for.protected int computeRow(Sector range, Angle latitude)
range
- the reference sector, typically that of this terrain instance.latitude
- the latitude in question.protected void convertPointsToPositions(java.util.List<Vec4[]> points, java.util.List<Position[]> positions)
protected static double createPosition(int start, double decimal, int density)
protected HighResolutionTerrain.RectTile createTile(int row, int col)
row
- the tile's 0-origin row index.col
- the tile's 0-origin column index.protected HighResolutionTerrain.RectTile createTile(Sector tileSector)
tileSector
- the sector for which to create the tile.protected void doGetIntersectingTiles(int r0, int c0, int r1, int c1, Line line, java.util.List<HighResolutionTerrain.RectTile> tiles)
protected Intersection[] doIntersect(Position pA, Position pB) throws java.lang.InterruptedException
pA
- the line's first position.pB
- the line's second position.java.lang.InterruptedException
- if the operation is interrupted.protected java.util.List<HighResolutionTerrain.RectTile> eliminateLowAltitudeTiles(java.util.List<HighResolutionTerrain.RectTile> tiles, double minAltitude) throws java.lang.InterruptedException
java.lang.InterruptedException
public long getCacheCapacity()
protected void getCachedElevations(java.util.List<LatLon> latlons, double[] elevations)
public double getCacheUsage()
protected HighResolutionTerrain.RectTile getContainingTile(Angle latitude, Angle longitude)
latitude
- the location's latitude.longitude
- the location's longitude.public int getDensity()
public java.lang.Double getElevation(LatLon location)
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.getElevation
in interface Terrain
location
- the location at which to compute the elevation.protected void getElevations(Sector sector, java.util.List<LatLon> latlons, double[] targetResolution, double[] elevations) throws java.lang.InterruptedException
java.lang.InterruptedException
public Position[] getExtremeElevations(LatLon center, double width, double height) throws java.lang.InterruptedException
center
- The quadrilateral's center.width
- The quadrilateral's longitudinal width, in meters.height
- The quadrilateral's latitudinal height, in meters.java.lang.InterruptedException
- if the operation is interrupted before it completes.public Position[] getExtremeElevations(Sector sector) throws java.lang.InterruptedException
Sector
.sector
- The sector in question.java.lang.InterruptedException
- if the operation is interrupted before it completes.public Globe getGlobe()
protected java.util.List<HighResolutionTerrain.RectTile> getIntersectingTiles(Position pA, Position pB, Line line)
pA
- the line's first position.pB
- the line's second position.line
- the line to intersectprotected java.util.List<HighResolutionTerrain.RectTile> getIntersectingTiles(Sector sector)
public java.util.List<Sector> getIntersectionTiles(Position pA, Position pB) throws java.lang.InterruptedException
java.lang.InterruptedException
public int getNumCacheEntries()
public Sector getSector()
public Vec4 getSurfacePoint(Angle latitude, Angle longitude, double metersOffset)
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.getSurfacePoint
in interface Terrain
latitude
- the location's latitude.longitude
- the location's longitude.metersOffset
- the location's distance above the terrain.protected Vec4 getSurfacePoint(HighResolutionTerrain.RectTile tile, Angle latitude, Angle longitude) throws java.lang.InterruptedException
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.tile
- the terrain tile.latitude
- the location's latitude.longitude
- the location's longitude.java.lang.IllegalArgumentException
- if the latitude or longitude are null.WWTimeoutException
- if the current timeout is exceeded while retrieving
terrain data.java.lang.InterruptedException
- if the operation is interrupted.setTimeout(Long)
protected Vec4 getSurfacePoint(HighResolutionTerrain.RectTile tile, Angle latitude, Angle longitude, double metersOffset) throws java.lang.InterruptedException
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.tile
- the terrain tile.latitude
- the location's latitude.longitude
- the location's longitude.metersOffset
- the location's distance above the terrain.java.lang.IllegalArgumentException
- if the latitude or longitude are null.WWTimeoutException
- if the current timeout is exceeded while retrieving
terrain data.java.lang.InterruptedException
- if the operation is interrupted.setTimeout(Long)
public Vec4 getSurfacePoint(Position position)
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.getSurfacePoint
in interface Terrain
position
- the position.public double getTargetResolution()
public java.lang.Long getTimeout()
setTimeout(Long)
public double getVerticalExaggeration()
getVerticalExaggeration
in interface Terrain
protected static Vec4 interpolate(int row, int column, double xDec, double yDec, HighResolutionTerrain.RenderInfo ri)
protected static Vec4 interpolate(Vec4 bL, Vec4 bR, Vec4 tR, Vec4 tL, double xDec, double yDec)
protected Intersection[] intersect(HighResolutionTerrain.RectTile tile, Line line) throws java.lang.InterruptedException
tile
- the tile.line
- the line.java.lang.InterruptedException
- if the operation is interrupted.protected java.util.List<Vec4[]> intersect(HighResolutionTerrain.RectTile tile, Vec4[] triangle) throws java.lang.InterruptedException
tile
- the terrain tiletriangle
- the Cartesian coordinates of the triangle.java.lang.InterruptedException
- if the operation is interrupted before it completes.public void intersect(java.util.List<Position> positions, HighResolutionTerrain.IntersectionCallback callback) throws java.lang.InterruptedException
positions
- The positions to intersect, with the line segments formed by each pair of positions, e.g. the
first line in formed by positions[0] and positions[1], the second by positions[2] and
positions[3], etc.callback
- An object to call in order to return the computed intersections.java.lang.InterruptedException
public Intersection[] intersect(Position pA, Position pB)
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.public Intersection[] intersect(Position pA, Position pB, int altitudeMode)
WWTimeoutException
if a timeout has been
specified and it is exceeded during the operation.intersect
in interface Terrain
pA
- the line's first position.pB
- the line's second position.altitudeMode
- the altitude mode indicating the reference for the altitudes in the specified positions.public void intersectTriangle(Vec4[] triangleCoordinates, Position[] trianglePositions, java.util.List<Position[]> intersectPositionsOut) throws java.lang.InterruptedException
triangleCoordinates
- The Cartesian coordinates of the triangle.trianglePositions
- The geographic coordinates of the triangle.intersectPositionsOut
- A list in which to place the intersection positions. May not be null.java.lang.InterruptedException
- if the operation is interrupted before it completes.public boolean isUseCachedElevationsOnly()
ElevationModel.getUnmappedLocalSourceElevation(Angle, Angle)
to retrieve elevations.
This assumes that the highest-resolution elevations for the elevation model are cached locally.protected Line makeLineFromPositions(Position pA, Position pB) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void makeVerts(HighResolutionTerrain.RectTile tile) throws java.lang.InterruptedException
tile
- the tile to compute vertices forjava.lang.InterruptedException
- if the operation is interrupted.WWTimeoutException
- if terrain data retrieval exceeds the current timeout.protected boolean resolutionsMeetCriteria(double[] actualResolution, double[] targetResolution)
public void setCacheCapacity(long size)
size
- the cache capacity, in bytes. Values less than 1 MB are clamped to 1 MB.public void setDensity(int density)
density
- the number of intervals used to form a terrain tile.public void setTimeout(java.lang.Long timeout)
WWTimeoutException
if the specified
timeout is exceeded.timeout
- the number of milliseconds to wait. May be null, to indicate that operations have unlimited amount
of time to operate.public void setUseCachedElevationsOnly(boolean tf)
ElevationModel.getUnmappedLocalSourceElevation(Angle, Angle)
to retrieve elevations.
This assumes that the highest-resolution elevations for the elevation model are cached locally.tf
- true to force caching, otherwise false. The default is false.