Class GDALDataRaster
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.data.AbstractDataRaster
-
- gov.nasa.worldwind.data.GDALDataRaster
-
- All Implemented Interfaces:
AVList
,Cacheable
,DataRaster
,Disposable
public class GDALDataRaster extends AbstractDataRaster implements Cacheable
-
-
Field Summary
Fields Modifier and Type Field Description protected GDAL.Area
area
protected static int
DEFAULT_MAX_RASTER_SIZE_LIMIT
protected org.gdal.gdal.Dataset
dsVRT
protected java.io.File
srcFile
protected org.gdal.osr.SpatialReference
srs
protected java.lang.Object
usageLock
-
Fields inherited from class gov.nasa.worldwind.data.AbstractDataRaster
height, width
-
-
Constructor Summary
Constructors Constructor Description GDALDataRaster(java.lang.Object source)
Opens a data rasterGDALDataRaster(java.lang.Object source, boolean quickReadingMode)
Opens a data rasterGDALDataRaster(org.gdal.gdal.Dataset ds)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.gdal.gdal.Dataset
buildNonNorthUpDatasetFromOverview(int bestOverviewIdx, int destWidth, int destHeight)
protected org.gdal.gdal.Dataset
buildNorthUpDatasetFromOverview(Sector reqSector, int reqWidth, int reqHeight, int bestOverviewIdx, int srcWidth, int srcHeight)
protected java.lang.String
composeExceptionReason(java.lang.Throwable t)
protected static java.lang.String
convertAVListToString(AVList list)
protected org.gdal.gdal.Dataset
createCompatibleDataset(int width, int height, Sector sector, AVList destParams)
protected org.gdal.gdal.Dataset
createMaskDataset(int width, int height, Sector sector)
void
dispose()
Disposes of any internal resources allocated by the object.protected void
doDrawOnTo(DataRaster canvas)
protected DataRaster
doGetSubRaster(int roiWidth, int roiHeight, Sector roiSector, AVList roiParams)
void
drawOnTo(DataRaster canvas)
Copies this raster into a specified raster.protected static org.gdal.gdal.Band
findAlphaBand(org.gdal.gdal.Dataset ds)
protected org.gdal.gdal.Dataset
getBestSuitedDataset(int reqWidth, int reqHeight, Sector reqSector)
The purpose of this method is to create the best suited dataset for the requested area.protected static int
getMaxRasterSizeLimit()
AVList
getMetadata()
long
getSizeInBytes()
Retrieves the approximate size of this object in bytes.DataRaster
getSubRaster(AVList params)
Builds a writable data raster for the requested region of interest (ROI)protected void
init(org.gdal.gdal.Dataset ds, boolean quickReadingMode)
Extracts metadata and sets next key/value pairs:protected boolean
intersects(Sector reqSector)
protected org.gdal.osr.SpatialReference
readSpatialReference(org.gdal.gdal.Dataset ds)
void
setSector(Sector sector)
Set a new extent to the data raster.java.lang.String
toString()
-
Methods inherited from class gov.nasa.worldwind.data.AbstractDataRaster
computeClipRect, computeGeographicToRasterTransform, computeSourceToDestTransform, getHeight, getSector, getSubRaster, getWidth, setValue
-
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, 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, setValues
-
-
-
-
Field Detail
-
dsVRT
protected org.gdal.gdal.Dataset dsVRT
-
srs
protected org.gdal.osr.SpatialReference srs
-
srcFile
protected java.io.File srcFile
-
area
protected GDAL.Area area
-
usageLock
protected final java.lang.Object usageLock
-
DEFAULT_MAX_RASTER_SIZE_LIMIT
protected static final int DEFAULT_MAX_RASTER_SIZE_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GDALDataRaster
public GDALDataRaster(java.lang.Object source) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException
Opens a data raster- Parameters:
source
- the location of the local file, expressed as either a String path, a File, or a file URL.- Throws:
java.lang.IllegalArgumentException
- if the source is nulljava.io.FileNotFoundException
- if the source (File) does not exist
-
GDALDataRaster
public GDALDataRaster(java.lang.Object source, boolean quickReadingMode) throws java.lang.IllegalArgumentException, java.io.FileNotFoundException
Opens a data raster- Parameters:
source
- the location of the local file, expressed as either a String path, a File, or a file URL.quickReadingMode
- if quick reading mode is enabled GDAL will not spend much time on heavy calculations, like for example calculating Min/Max for entire elevation raster- Throws:
java.lang.IllegalArgumentException
- if the source is nulljava.io.FileNotFoundException
- if the source (File) does not exist
-
GDALDataRaster
public GDALDataRaster(org.gdal.gdal.Dataset ds) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
-
Method Detail
-
getMaxRasterSizeLimit
protected static int getMaxRasterSizeLimit()
-
setSector
public void setSector(Sector sector) throws java.lang.IllegalArgumentException
Set a new extent to the data raster. This operation is mostly required for rasters that does not have a georeferenced information. A new geo-transform matrix will be created. The coordinate system is set to Geographic.- Parameters:
sector
- A valid sector instance- Throws:
java.lang.IllegalArgumentException
- if the Sector is null
-
readSpatialReference
protected org.gdal.osr.SpatialReference readSpatialReference(org.gdal.gdal.Dataset ds)
-
init
protected void init(org.gdal.gdal.Dataset ds, boolean quickReadingMode)
Extracts metadata and sets next key/value pairs:AVKey.WIDTH - the maximum width of the image
AVKey.HEIGHT - the maximum height of the image
AVKey.COORDINATE_SYSTEM - one of the next values: AVKey.COORDINATE_SYSTEM_SCREEN AVKey.COORDINATE_SYSTEM_GEOGRAPHIC AVKey.COORDINATE_SYSTEM_PROJECTED
AVKey.SECTOR - in case of Geographic CS, contains a regular Geographic Sector defined by lat/lon coordinates of corners in case of Projected CS, contains a bounding box of the area
- Parameters:
ds
- GDAL's DatasetquickReadingMode
- if quick reading mode is enabled GDAL will not spend much time on heavy calculations, like for example calculating Min/Max for entire elevation raster
-
getMetadata
public AVList getMetadata()
-
drawOnTo
public void drawOnTo(DataRaster canvas)
Description copied from interface:DataRaster
Copies this raster into a specified raster.- Specified by:
drawOnTo
in interfaceDataRaster
- Parameters:
canvas
- - the raster to copy into.
-
doDrawOnTo
protected void doDrawOnTo(DataRaster canvas)
-
composeExceptionReason
protected java.lang.String composeExceptionReason(java.lang.Throwable t)
-
dispose
public void dispose()
Description copied from interface:Disposable
Disposes of any internal resources allocated by the object.- Specified by:
dispose
in interfaceDisposable
-
createMaskDataset
protected org.gdal.gdal.Dataset createMaskDataset(int width, int height, Sector sector)
-
getBestSuitedDataset
protected org.gdal.gdal.Dataset getBestSuitedDataset(int reqWidth, int reqHeight, Sector reqSector)
The purpose of this method is to create the best suited dataset for the requested area. The dataset may contain overviews, so instead of retrieving raster from the highest resolution source, we will compose a temporary dataset from an overview, and/or we may clip only the requested area. This will accelerate reprojection (if needed), because the reporjection will be done on much smaller dataset.- Parameters:
reqWidth
- width of the requested areareqHeight
- height of the requested areareqSector
- sector of the requested area- Returns:
- a dataset with the best suitable raster for the request
-
buildNorthUpDatasetFromOverview
protected org.gdal.gdal.Dataset buildNorthUpDatasetFromOverview(Sector reqSector, int reqWidth, int reqHeight, int bestOverviewIdx, int srcWidth, int srcHeight)
-
buildNonNorthUpDatasetFromOverview
protected org.gdal.gdal.Dataset buildNonNorthUpDatasetFromOverview(int bestOverviewIdx, int destWidth, int destHeight)
-
createCompatibleDataset
protected org.gdal.gdal.Dataset createCompatibleDataset(int width, int height, Sector sector, AVList destParams)
-
getSubRaster
public DataRaster getSubRaster(AVList params)
Builds a writable data raster for the requested region of interest (ROI)- Specified by:
getSubRaster
in interfaceDataRaster
- Overrides:
getSubRaster
in classAbstractDataRaster
- Parameters:
params
- Required parameters are:AVKey.HEIGHT as Integer, specifies a height of the desired ROI
AVKey.WIDTH as Integer, specifies a width of the desired ROI
AVKey.SECTOR as Sector, specifies an extent of the desired ROI
Optional parameters are:
AVKey.BAND_ORDER as array of integers, examples: for RGBA image: new int[] { 0, 1, 2, 3 }, or for ARGB image: new int[] { 3, 0, 1, 2 } , or if you want only RGB bands of the RGBA image: new int[] {0, 1, 2 }, or only Intensity (4th) band of the specific aerial image: new int[] { 3 }
- Returns:
- A writable data raster: BufferedImageRaster (if the source dataset is imagery) or ByteBufferRaster (if the source dataset is elevations)
-
doGetSubRaster
protected DataRaster doGetSubRaster(int roiWidth, int roiHeight, Sector roiSector, AVList roiParams)
-
findAlphaBand
protected static org.gdal.gdal.Band findAlphaBand(org.gdal.gdal.Dataset ds)
-
convertAVListToString
protected static java.lang.String convertAVListToString(AVList list)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
intersects
protected boolean intersects(Sector reqSector)
-
getSizeInBytes
public long getSizeInBytes()
Description copied from interface:Cacheable
Retrieves the approximate size of this object in bytes. Implementors are encouraged to calculate the exact size for smaller objects, but use approximate values for objects that include such large components that the approximation would produce an error so small that the extra computation would be wasteful.- Specified by:
getSizeInBytes
in interfaceCacheable
- Returns:
- this
Cacheable
object's size in bytes
-
-