Package org.esa.snap.core.dataop.dem
Class BaseElevationModel
- java.lang.Object
-
- org.esa.snap.core.dataop.dem.BaseElevationModel
-
- All Implemented Interfaces:
ElevationModel
,Resampling.Raster
public abstract class BaseElevationModel extends Object implements ElevationModel, Resampling.Raster
-
-
Field Summary
Fields Modifier and Type Field Description protected int
DEGREE_RES
protected double
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X
protected double
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X_inv
protected double
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y
protected double
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y_inv
protected ElevationModelDescriptor
descriptor
protected ElevationFile[][]
elevationFiles
protected double
NO_DATA_VALUE
protected int
NUM_PIXELS_PER_TILE_X
protected double
NUM_PIXELS_PER_TILE_X_inv
protected int
NUM_PIXELS_PER_TILE_Y
protected double
NUM_PIXELS_PER_TILE_Y_inv
protected int
NUM_X_TILES
protected int
NUM_Y_TILES
protected int
RASTER_HEIGHT
protected int
RASTER_WIDTH
protected Resampling
resampling
protected Resampling.Raster
resamplingRaster
-
Constructor Summary
Constructors Constructor Description BaseElevationModel(ElevationModelDescriptor descriptor, Resampling resamplingMethod)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
createElevationFile(ElevationFile[][] elevationFiles, int x, int y, File demInstallDir)
void
dispose()
Releases all of the resources used by this object instance and all of its owned children.ElevationModelDescriptor
getDescriptor()
Gets the descriptor of this DEM.double
getElevation(GeoPos geoPos)
Gets the elevation at the geographical coordinate in meters.abstract GeoPos
getGeoPos(PixelPos pixelPos)
Gets the geographical coordinates for the input pixel coordinates in the DEM reference system.int
getHeight()
Gets the raster's height.PixelPos
getIndex(GeoPos geoPos)
Gets the pixel index in the DEM reference system at the geographical coordinate in meters.abstract double
getIndexX(GeoPos geoPos)
abstract double
getIndexY(GeoPos geoPos)
protected static ProductReaderPlugIn
getReaderPlugIn(String formatName)
Resampling
getResampling()
double
getSample(double pixelX, double pixelY)
Gets the elevation at the point defined by (x,y) coordinates in DEM reference system.boolean
getSamples(int[] xArray, int[] yArray, double[][] samples)
Gets the elevations at the points defined by (x,y) coordinates in DEM reference system.int
getWidth()
Gets the raster's width.protected void
setMaxCacheSize(int size)
void
updateCache(ElevationTile tile)
-
-
-
Field Detail
-
NUM_X_TILES
protected final int NUM_X_TILES
-
NUM_Y_TILES
protected final int NUM_Y_TILES
-
NUM_PIXELS_PER_TILE_X
protected int NUM_PIXELS_PER_TILE_X
-
NUM_PIXELS_PER_TILE_Y
protected int NUM_PIXELS_PER_TILE_Y
-
NUM_PIXELS_PER_TILE_X_inv
protected double NUM_PIXELS_PER_TILE_X_inv
-
NUM_PIXELS_PER_TILE_Y_inv
protected double NUM_PIXELS_PER_TILE_Y_inv
-
NO_DATA_VALUE
protected final double NO_DATA_VALUE
-
DEGREE_RES
protected int DEGREE_RES
-
RASTER_WIDTH
protected int RASTER_WIDTH
-
RASTER_HEIGHT
protected int RASTER_HEIGHT
-
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X
protected double DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X
-
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y
protected double DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y
-
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X_inv
protected double DEGREE_RES_BY_NUM_PIXELS_PER_TILE_X_inv
-
DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y_inv
protected double DEGREE_RES_BY_NUM_PIXELS_PER_TILE_Y_inv
-
descriptor
protected final ElevationModelDescriptor descriptor
-
elevationFiles
protected final ElevationFile[][] elevationFiles
-
resampling
protected final Resampling resampling
-
resamplingRaster
protected final Resampling.Raster resamplingRaster
-
-
Constructor Detail
-
BaseElevationModel
public BaseElevationModel(ElevationModelDescriptor descriptor, Resampling resamplingMethod)
-
-
Method Detail
-
getResampling
public Resampling getResampling()
- Specified by:
getResampling
in interfaceElevationModel
- Returns:
- The resampling method used.
-
getDescriptor
public ElevationModelDescriptor getDescriptor()
Description copied from interface:ElevationModel
Gets the descriptor of this DEM.- Specified by:
getDescriptor
in interfaceElevationModel
- Returns:
- the descriptor which is never null
-
setMaxCacheSize
protected void setMaxCacheSize(int size)
-
getElevation
public double getElevation(GeoPos geoPos) throws Exception
Description copied from interface:ElevationModel
Gets the elevation at the geographical coordinate in meters.- Specified by:
getElevation
in interfaceElevationModel
- Parameters:
geoPos
- the geographical coordinate- Returns:
- an elevation in meters, or the special value returned by
ElevationModelDescriptor.getNoDataValue()
if an elevation is not available - Throws:
Exception
- if a non-runtime error occurs, e.g I/O error
-
getIndexX
public abstract double getIndexX(GeoPos geoPos)
-
getIndexY
public abstract double getIndexY(GeoPos geoPos)
-
getGeoPos
public abstract GeoPos getGeoPos(PixelPos pixelPos)
Description copied from interface:ElevationModel
Gets the geographical coordinates for the input pixel coordinates in the DEM reference system.- Specified by:
getGeoPos
in interfaceElevationModel
- Parameters:
pixelPos
- the pixel (x,y) coordinate- Returns:
- (lat, lon) geographical coordinates in the reference system of a given DEM
-
getIndex
public PixelPos getIndex(GeoPos geoPos)
Description copied from interface:ElevationModel
Gets the pixel index in the DEM reference system at the geographical coordinate in meters.- Specified by:
getIndex
in interfaceElevationModel
- Parameters:
geoPos
- the geographical coordinate- Returns:
- (x, y) coordinates in the reference system of a given DEM
-
getWidth
public int getWidth()
Description copied from interface:Resampling.Raster
Gets the raster's width.- Specified by:
getWidth
in interfaceResampling.Raster
- Returns:
- the raster's width
-
getHeight
public int getHeight()
Description copied from interface:Resampling.Raster
Gets the raster's height.- Specified by:
getHeight
in interfaceResampling.Raster
- Returns:
- the raster's height
-
updateCache
public void updateCache(ElevationTile tile)
-
getSample
public final double getSample(double pixelX, double pixelY) throws Exception
Description copied from interface:ElevationModel
Gets the elevation at the point defined by (x,y) coordinates in DEM reference system. This method does not interpolated the elevation map!- Specified by:
getSample
in interfaceElevationModel
- Parameters:
pixelX
- coordinatepixelY
- coordinate- Returns:
- an elevation in meters, or the special value returned by
ElevationModelDescriptor.getNoDataValue()
if an elevation is not available - Throws:
Exception
- if a non-runtime error occurs, e.g I/O error
-
getSamples
public final boolean getSamples(int[] xArray, int[] yArray, double[][] samples) throws Exception
Description copied from interface:ElevationModel
Gets the elevations at the points defined by (x,y) coordinates in DEM reference system. This method does not interpolated the elevation map!- Specified by:
getSamples
in interfaceElevationModel
- Specified by:
getSamples
in interfaceResampling.Raster
- Parameters:
xArray
- coordinateyArray
- coordinatesamples
- output elevation in meters, or the special value returned byElevationModelDescriptor.getNoDataValue()
if an elevation is not available- Returns:
- false if all values are nodata value
- Throws:
Exception
- if a non-runtime error occurs, e.g I/O error
-
dispose
public void dispose()
Description copied from interface:ElevationModel
Releases all of the resources used by this object instance and all of its owned children. Its primary use is to allow the garbage collector to perform a vanilla job.This method should be called only if it is for sure that this object instance will never be used again. The results of referencing an instance of this class after a call to
dispose()
are undefined.Overrides of this method should always call
super.dispose();
after disposing this instance.- Specified by:
dispose
in interfaceElevationModel
-
createElevationFile
protected abstract void createElevationFile(ElevationFile[][] elevationFiles, int x, int y, File demInstallDir)
-
getReaderPlugIn
protected static ProductReaderPlugIn getReaderPlugIn(String formatName)
-
-