NASA World Wind

gov.nasa.worldwind.data
Class GDALDataRaster

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.data.AbstractDataRaster
          extended by gov.nasa.worldwind.data.GDALDataRaster
All Implemented Interfaces:
AVList, Cacheable, DataRaster, Disposable

public class GDALDataRaster
extends AbstractDataRaster
implements Cacheable


Field Summary
protected  GDAL.Area area
           
protected static int DEFAULT_MAX_RASTER_SIZE_LIMIT
           
protected  org.gdal.gdal.Dataset dsVRT
           
protected  File srcFile
           
protected  org.gdal.osr.SpatialReference srs
           
protected  Object usageLock
           
 
Fields inherited from class gov.nasa.worldwind.data.AbstractDataRaster
height, width
 
Constructor Summary
GDALDataRaster(org.gdal.gdal.Dataset ds)
           
GDALDataRaster(Object source)
          Opens a data raster
GDALDataRaster(Object source, boolean quickReadingMode)
          Opens a data raster
 
Method Summary
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  String composeExceptionReason(Throwable t)
           
protected static 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:

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

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.
 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, finalize, 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

area

protected GDAL.Area area

DEFAULT_MAX_RASTER_SIZE_LIMIT

protected static final int DEFAULT_MAX_RASTER_SIZE_LIMIT
See Also:
Constant Field Values

dsVRT

protected org.gdal.gdal.Dataset dsVRT

srcFile

protected File srcFile

srs

protected org.gdal.osr.SpatialReference srs

usageLock

protected final Object usageLock
Constructor Detail

GDALDataRaster

public GDALDataRaster(org.gdal.gdal.Dataset ds)
               throws IllegalArgumentException
Throws:
IllegalArgumentException

GDALDataRaster

public GDALDataRaster(Object source)
               throws IllegalArgumentException,
                      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:
IllegalArgumentException - if the source is null
FileNotFoundException - if the source (File) does not exist

GDALDataRaster

public GDALDataRaster(Object source,
                      boolean quickReadingMode)
               throws IllegalArgumentException,
                      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:
IllegalArgumentException - if the source is null
FileNotFoundException - if the source (File) does not exist
Method Detail

buildNonNorthUpDatasetFromOverview

protected org.gdal.gdal.Dataset buildNonNorthUpDatasetFromOverview(int bestOverviewIdx,
                                                                   int destWidth,
                                                                   int destHeight)

buildNorthUpDatasetFromOverview

protected org.gdal.gdal.Dataset buildNorthUpDatasetFromOverview(Sector reqSector,
                                                                int reqWidth,
                                                                int reqHeight,
                                                                int bestOverviewIdx,
                                                                int srcWidth,
                                                                int srcHeight)

composeExceptionReason

protected String composeExceptionReason(Throwable t)

convertAVListToString

protected static String convertAVListToString(AVList list)

createCompatibleDataset

protected org.gdal.gdal.Dataset createCompatibleDataset(int width,
                                                        int height,
                                                        Sector sector,
                                                        AVList destParams)

createMaskDataset

protected org.gdal.gdal.Dataset createMaskDataset(int width,
                                                  int height,
                                                  Sector sector)

dispose

public void dispose()
Description copied from interface: Disposable
Disposes of any internal resources allocated by the object.

Specified by:
dispose in interface Disposable

doDrawOnTo

protected void doDrawOnTo(DataRaster canvas)

doGetSubRaster

protected DataRaster doGetSubRaster(int roiWidth,
                                    int roiHeight,
                                    Sector roiSector,
                                    AVList roiParams)

drawOnTo

public void drawOnTo(DataRaster canvas)
Description copied from interface: DataRaster
Copies this raster into a specified raster.

Specified by:
drawOnTo in interface DataRaster
Parameters:
canvas - - the raster to copy into.

findAlphaBand

protected static org.gdal.gdal.Band findAlphaBand(org.gdal.gdal.Dataset ds)

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 area
reqHeight - height of the requested area
reqSector - sector of the requested area
Returns:
a dataset with the best suitable raster for the request

getMaxRasterSizeLimit

protected static int getMaxRasterSizeLimit()

getMetadata

public AVList getMetadata()

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 interface Cacheable
Returns:
this Cacheable object's size in bytes

getSubRaster

public DataRaster getSubRaster(AVList params)
Builds a writable data raster for the requested region of interest (ROI)

Specified by:
getSubRaster in interface DataRaster
Overrides:
getSubRaster in class AbstractDataRaster
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)

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 Dataset
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

intersects

protected boolean intersects(Sector reqSector)

readSpatialReference

protected org.gdal.osr.SpatialReference readSpatialReference(org.gdal.gdal.Dataset ds)

setSector

public void setSector(Sector sector)
               throws 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:
IllegalArgumentException - if the Sector is null

toString

public String toString()
Overrides:
toString in class Object

NASA World Wind