Class Dataset2D
Wrapper that maps a two-dimensional (x, y) grid to an underlying set of data. This allows us to: - easily vary the underlying data we're storing (via subclassing), e.g. in DatasetCoverage we need to support both doubles and lists of doubles. - actually use a one-dimensional array underneath (for memory efficiency). - potentially calculate the underlying data on demand, e.g. for huge HDF5 datasets that we can't fit in memory in a single array.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Dataset2D
Combines multiple datasets together and returns a combined struct each time they are sampled.static Dataset2D
fromDoubles
(int width, int height, double[] data) Maps a simple one-dimensional array of doubles to a two-dimensional grid, with the dataset yielding the double at each grid position.long
protected int
getIndex
(long x, long y) abstract nz.org.riskscape.engine.types.Type
getType()
abstract Object
getValue
(long x, long y) long
getWidth()
boolean
isInBounds
(long x, long y)
-
Constructor Details
-
Dataset2D
public Dataset2D(long width, long height)
-
-
Method Details
-
fromDoubles
Maps a simple one-dimensional array of doubles to a two-dimensional grid, with the dataset yielding the double at each grid position.
Data should be organized in the data array to be
x, y
, that is the firstwidth
number of values are fory = 0
-
combine
public static Dataset2D combine(List<Dataset2D> datasets, nz.org.riskscape.engine.types.Struct combinedType) Combines multiple datasets together and returns a combined struct each time they are sampled.
-
getIndex
protected int getIndex(long x, long y) -
isInBounds
public boolean isInBounds(long x, long y) - Returns:
- whether the x, y co-ordinates fall within this dataset grid
-
getValue
- Returns:
- the data stored at the given x, y co-ordinates. Warning: you should verify the co-ordinates via isInBounds() first
-
getType
public abstract nz.org.riskscape.engine.types.Type getType()- Returns:
- the type of data stored by the dataset. Similar to TypedCoverage.getType()
-
getWidth
public long getWidth() -
getHeight
public long getHeight()
-