it.geosolutions.imageio.gdalframework
Class GDALUtilities

Object
  extended by GDALUtilities

public final class GDALUtilities
extends Object

Utility class providing a set of static utility methods

Author:
Daniele Romagnoli, GeoSolutions., Simone Giannecchini, GeoSolutions.

Nested Class Summary
static class GDALUtilities.DriverCreateCapabilities
          Simple placeholder for information about a driver's capabilities.
static class GDALUtilities.GDALMetadataDomain
          Simple placeholder for Strings representing GDAL metadata domains.
static class GDALUtilities.MetadataChoice
          An auxiliary simple class containing only contants which are used to handle text building and visualization
 
Field Summary
static Dimension DEFAULT_TILE_SIZE
          The default tile size.
static String GDALMEMORYRASTER_MAXSIZE_KEY
          System property name to customize the max supported size of a GDAL In Memory Raster Dataset to be created before using the createCopy method
static int MIN_TILE_SIZE
          The minimums tile size.
static String newLine
           
static String STANDARD_METADATA_NAME
           
 
Method Summary
static Dataset acquireDataSet(String name, int accessType)
          Acquires a Dataset and return it, given the name of the Dataset source and the desired access type
static ColorModel buildColorModel(SampleModel sampleModel)
          Builds a proper ColorModel for a specified SampleModel
static String buildCRSProperties(RenderedImage ri, int index)
           
static String buildMetadataText(RenderedImage ri, GDALUtilities.MetadataChoice metadataFields, int index)
           
static void closeDataSet(Dataset ds)
          Closes the given Dataset.
static GDALUtilities.DriverCreateCapabilities formatWritingCapabilities(String driverName)
          Tells us about the capabilities for a GDAL driver.
static int getCacheMax()
          Returns the maximum amount of memory available for GDAL caching mechanism.
static int getCacheUsed()
          Returns the amount of GDAL cache used.
static List<String> getGDALImageMetadata(String dataSetName)
          Returns any metadata related to the specified image.
static List getGDALStreamMetadata(String datasetName)
          Returns any metadata which is not related to a specific image.
static String getImageMetadata(GDALImageReader reader, int index)
           
static List getJDKImageReaderWriterSPI(ServiceRegistry registry, String formatName, boolean isReader)
           
static String getMetadataItem(List imageMetadata, String metadataName)
          Returns the value of a specific metadata item contained in the metadata given as first input parameter
static String getStreamMetadata(GDALImageReader reader)
           
static String getStreamMetadataItem(String metadataName, String datasetName)
          Returns the value of a specific metadata item related to the stream.
static boolean isDriverAvailable(String driverName)
          Returns true if a driver for the specific format is available.
static boolean isGDALAvailable()
          Returns true if the GDAL native library has been loaded.
static void loadGDAL()
          Forces loading of GDAL libs.
static int retrieveGDALDataBufferType(int dataBufferType)
          Simply provides to retrieve the corresponding GDALDataType for the specified dataBufferType
static void setCacheMax(int maxCacheSize)
          Sets the GDAL Max Cache Size.
static void setGdalCaching(boolean useCaching)
          Allows to enable/disable GDAL caching mechanism.
static void setGdalPAM(boolean usePAM)
          Allows to enable/disable GDAL Persistable Auxiliary Metadata.
static void setNodeAttribute(String name, Object val, IIOMetadataNode node, int attributeType)
          Set the value of a specific attribute of a specific IIOMetadataNode
static Dimension toTileSize(Dimension size)
          Suggests a tile size for the specified image size.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_METADATA_NAME

public static final String STANDARD_METADATA_NAME
See Also:
Constant Field Values

newLine

public static final String newLine

GDALMEMORYRASTER_MAXSIZE_KEY

public static final String GDALMEMORYRASTER_MAXSIZE_KEY
System property name to customize the max supported size of a GDAL In Memory Raster Dataset to be created before using the createCopy method

See Also:
Constant Field Values

DEFAULT_TILE_SIZE

public static final Dimension DEFAULT_TILE_SIZE
The default tile size. This default tile size can be overridden with a call to JAI.setDefaultTileSize(java.awt.Dimension).


MIN_TILE_SIZE

public static final int MIN_TILE_SIZE
The minimums tile size.

See Also:
Constant Field Values
Method Detail

retrieveGDALDataBufferType

public static int retrieveGDALDataBufferType(int dataBufferType)
Simply provides to retrieve the corresponding GDALDataType for the specified dataBufferType

Parameters:
dataBufferType - the DataBuffer type for which we need to retrieve the proper GDALDataType
Returns:
the proper GDALDataType

getCacheMax

public static int getCacheMax()
Returns the maximum amount of memory available for GDAL caching mechanism.

Returns:
the maximum amount in bytes of memory available.

getCacheUsed

public static int getCacheUsed()
Returns the amount of GDAL cache used.

Returns:
the amount (bytes) of memory currently in use by the GDAL memory caching mechanism.

getJDKImageReaderWriterSPI

public static List getJDKImageReaderWriterSPI(ServiceRegistry registry,
                                              String formatName,
                                              boolean isReader)

setCacheMax

public static void setCacheMax(int maxCacheSize)
Sets the GDAL Max Cache Size. You can do this only if caching is enabled.

Parameters:
maxCacheSize -

setGdalCaching

public static void setGdalCaching(boolean useCaching)
Allows to enable/disable GDAL caching mechanism.

Parameters:
useCaching - true to enable GDAL caching. false to disable GDAL caching.

setGdalPAM

public static void setGdalPAM(boolean usePAM)
Allows to enable/disable GDAL Persistable Auxiliary Metadata.

Parameters:
usePAM - true to enable GDAL PAM. false to disable GDAL PAM.

acquireDataSet

public static Dataset acquireDataSet(String name,
                                     int accessType)
Acquires a Dataset and return it, given the name of the Dataset source and the desired access type

Parameters:
name - of the dataset source to be accessed (usually, a File name).
accessType -
Returns:
the acquired Dataset

getGDALImageMetadata

public static List<String> getGDALImageMetadata(String dataSetName)
Returns any metadata related to the specified image. The SUBDATASETS domain is not returned since it is related to the whole stream instead of a single image.

Parameters:
dataSetName - the name of the dataset for which we need to retrieve imageMetadata
Returns:
a List containing any metadata found.

closeDataSet

public static void closeDataSet(Dataset ds)
Closes the given Dataset.

Parameters:
ds - Dataset to close.

isDriverAvailable

public static boolean isDriverAvailable(String driverName)
Returns true if a driver for the specific format is available. false otherwise.
It is worth to point out that a successful loading of the native library is not sufficient to grant the support for a specific format. We should also check if the proper driver is available.

Returns:
true if a driver for the specific format is available. false otherwise.

formatWritingCapabilities

public static GDALUtilities.DriverCreateCapabilities formatWritingCapabilities(String driverName)
Tells us about the capabilities for a GDAL driver.

Parameters:
driverName - name of the Driver we want to get info about.
Returns:
GDALUtilities.DriverCreateCapabilities.CREATE in case the driver supports creation of dataset, GDALUtilities.DriverCreateCapabilities.CREATE_COPY in case the driver supports only create copy and eventually GDALUtilities.DriverCreateCapabilities.READ_ONLY for read-only drivers.
Throws:
IllegalArgumentException - in case the specified driver name is null or a Driver for the specified name is unavailable.

getStreamMetadataItem

public static String getStreamMetadataItem(String metadataName,
                                           String datasetName)
Returns the value of a specific metadata item related to the stream. As an instance, it may be used to find the name or the description of a specific subdataset.

Parameters:
metadataName - the name of the specified metadata item.
datasetName -
Returns:
the value of the required metadata item.

getMetadataItem

public static String getMetadataItem(List imageMetadata,
                                     String metadataName)
Returns the value of a specific metadata item contained in the metadata given as first input parameter

Parameters:
gdalImageMetadata - the required metadata List (gdalStreamMetadata or gdalImageMetadata)
metadataName - the name of the specified metadata item
Returns:
the value of the specified metadata item

getGDALStreamMetadata

public static List getGDALStreamMetadata(String datasetName)
Returns any metadata which is not related to a specific image. The actual implementation provide to return only the SUBDATASETS domain metadata but it may be changed in future.

Parameters:
datasetName -
Returns:
a List containing metadata related to the stream.

setNodeAttribute

public static void setNodeAttribute(String name,
                                    Object val,
                                    IIOMetadataNode node,
                                    int attributeType)
Set the value of a specific attribute of a specific IIOMetadataNode

Parameters:
name - The name of the attribute which need to be set
val - The value we want to set
node - The IIOMetadataNode having the attribute we are going to set
attributeType - The type of the attribute we are going to set

toTileSize

public static Dimension toTileSize(Dimension size)
Suggests a tile size for the specified image size. On input, size is the image's size. On output, it is the tile size. This method write the result directly in the supplied object and returns size for convenience.


isGDALAvailable

public static boolean isGDALAvailable()
Returns true if the GDAL native library has been loaded. false otherwise.

Returns:
true only if the GDAL native library has been loaded.

loadGDAL

public static void loadGDAL()
Forces loading of GDAL libs.


buildColorModel

public static ColorModel buildColorModel(SampleModel sampleModel)
Builds a proper ColorModel for a specified SampleModel

Parameters:
sampleModel - the sampleModel to be used as reference.
Returns:
a proper ColorModel for the input SampleModel

buildCRSProperties

public static String buildCRSProperties(RenderedImage ri,
                                        int index)

buildMetadataText

public static String buildMetadataText(RenderedImage ri,
                                       GDALUtilities.MetadataChoice metadataFields,
                                       int index)

getImageMetadata

public static String getImageMetadata(GDALImageReader reader,
                                      int index)

getStreamMetadata

public static String getStreamMetadata(GDALImageReader reader)
                                throws IOException
Throws:
IOException


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.