public class TerrainPostsIntMinimum extends TerrainPosts
RasterTerrainProvider
where each
post is stored as either an short
or an int
.
The smallest data type that can represent the post data is chosen.
This class is helpful for use with terrain providers where the possible range of heights is substantially
larger than the common range of heights. For example, the UsgsDigitalElevationModel
terrain
format specifies that heights are 32-bit integers. However, for all practical purposes, the heights don't
exceed the bounds of a 16-bit integer. Using this type to store the posts for the UsgsDigitalElevationModel
terrain provider allows us to get the space and performance advantages of storing posts as 16-bit integers, while
still supporting the rare terrain file that actually requires 32-bit integers.
Constructor and Description |
---|
TerrainPostsIntMinimum(RasterTerrainProvider provider,
RasterTerrainIndexExtent indexExtent,
int voidValue)
Initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
int |
get(int longitudeIndex,
int latitudeIndex)
Gets the post height at a particular set of indices.
|
void |
getFourPostHeights(int west,
int south,
int east,
int north,
double[] southWest,
double[] southEast,
double[] northEast,
double[] northWest)
Gets the heights of four posts, specified by index.
|
double |
getPostHeight(int longitudeIndex,
int latitudeIndex)
Gets the height at a post.
|
long |
getSize()
Gets the size of the post data, in bytes.
|
int |
getVoidValue()
Gets the integer value that indicates a void (or post with unknown height).
|
void |
set(int longitudeIndex,
int latitudeIndex,
int value)
Sets the post height at a particular set of indices.
|
getBoundingExtent, getFourSurroundingPosts, getIndexExtent, getTerrainProvider, indexToLatitude, indexToLongitude, latitudeToIndex, longitudeToIndex
public TerrainPostsIntMinimum(RasterTerrainProvider provider, @Nonnull RasterTerrainIndexExtent indexExtent, int voidValue)
provider
- The terrain provider that provided this collection of posts.indexExtent
- The extent of indices of this instance in the overall terrain provider.voidValue
- The value that indicates a void (or post with unknown height).public void getFourPostHeights(int west, int south, int east, int north, @Nonnull double[] southWest, @Nonnull double[] southEast, @Nonnull double[] northEast, @Nonnull double[] northWest)
getFourPostHeights
in class TerrainPosts
west
- The index of the two western posts. 0 refers to western-most post stored by this instance.south
- The index of the two southern posts. 0 refers to southern-most post stored by this instance.east
- The index of the two eastern posts. 0 refers to western-most post stored by this instance.north
- The index of the two northern posts. 0 refers to southern-most post stored by this instance.southWest
- On input, an array with one element. On return, the array is populated with
the height of the southwest post, in the native units of the terrain provider.southEast
- On input, an array with one element. On return, the array is populated with
the height of the southeast post, in the native units of the terrain provider.northEast
- On input, an array with one element. On return, the array is populated with
the height of the northeast post, in the native units of the terrain provider.northWest
- On input, an array with one element. On return, the array is populated with
the height of the northwest post, in the native units of the terrain provider.IndexOutOfBoundsException
- Thrown when an index is outside the extent of this collection of posts.public final int get(int longitudeIndex, int latitudeIndex)
longitudeIndex
- The longitude index of the post. 0 refers to the western-most post stored by this instance.latitudeIndex
- The latitude index of the post. 0 refers to the southern-most post stored by this instance.public final void set(int longitudeIndex, int latitudeIndex, int value)
longitudeIndex
- The longitude index of the post. 0 refers to the western-most post stored by this instance.latitudeIndex
- The latitude index of the post. 0 refers to the southern-most post stored by this instance.public final int getVoidValue()
public long getSize()
getSize
in class TerrainPosts
public double getPostHeight(int longitudeIndex, int latitudeIndex)
In performance critical code, consider using TerrainPostsIntMinimum.getFourPostHeights(int, int, int, int, double[], double[], double[], double[])
instead of calling this method four times.
Doing so will avoid unnecessary function call overhead.
getPostHeight
in class TerrainPosts
longitudeIndex
- The longitude index of the post. 0 refers to the western-most post stored by this instance.latitudeIndex
- The latitude index of the post. 0 refers to the southern-most post stored by this instance.IndexOutOfBoundsException
- Thrown when longitudeIndex
or latitudeIndex
is outside the extent
of this collection of posts.