public class GDALUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static long |
ALPHA_MASK |
protected static byte |
ALPHA_OPAQUE |
protected static byte |
ALPHA_TRANSPARENT |
protected static java.util.concurrent.CopyOnWriteArraySet<java.lang.String> |
failedLibraries |
protected static java.lang.String |
GDAL_DATA_PATH |
protected static java.lang.String |
GDAL_DRIVER_PATH |
protected static java.lang.String |
gdalalljni |
protected static java.util.concurrent.atomic.AtomicBoolean |
gdalIsAvailable |
protected static java.lang.String |
JAVA_LIBRARY_PATH |
protected static java.util.concurrent.CopyOnWriteArraySet<java.lang.String> |
loadedLibraries |
protected static java.lang.String |
OGR_DRIVER_PATH |
| Constructor and Description |
|---|
GDALUtils() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
alterJavaLibraryPath(java.lang.String newJavaLibraryPath) |
protected static void |
applyImageMask(byte[] alphaBand,
java.nio.IntBuffer maskBand) |
protected static void |
applyImageMask(int[] alphaBand,
java.nio.IntBuffer maskBand) |
protected static void |
applyImageMask(short[] alphaBand,
java.nio.IntBuffer maskBand) |
protected static java.lang.String |
buildPathString(java.lang.String[] folders,
boolean addDefaultValues) |
static double[] |
calcGetGeoTransform(Sector sector,
int width,
int height)
Calculates geo-transform matrix for a north-up raster
|
static boolean |
canOpen(java.lang.Object source)
Checks if a data raster can is readable
|
static DataRaster |
composeDataRaster(org.gdal.gdal.Dataset ds,
AVList params) |
protected static DataRaster |
composeImageDataRaster(org.gdal.gdal.Dataset ds,
AVList params)
Opens image or elevation file, returns as a BufferedImage (even for elevations)
|
protected static DataRaster |
composeNonImageDataRaster(org.gdal.gdal.Dataset ds,
AVList params)
The "composeDataRaster" method creates a ByteBufferRaster from an elevation (or non-image) Dataset.
|
protected static java.lang.Double |
convertStringToDouble(java.lang.String s) |
static org.gdal.osr.SpatialReference |
createGeographicSRS() |
protected static java.awt.image.BufferedImage |
detectVoidsAndMakeThemTransparent(java.awt.image.BufferedImage sourceImage)
Attempts to detect if there are any black|white|gray voids (also called black skirts) i n the image raster caused
by inaccurate clipping.
|
static int[] |
extractBandOrder(org.gdal.gdal.Dataset ds,
AVList params) |
protected static java.nio.IntBuffer |
extractImageMask(AVList params) |
protected static void |
extractMinMaxSampleValues(org.gdal.gdal.Dataset ds,
org.gdal.gdal.Band band,
AVList params) |
static AVList |
extractRasterParameters(org.gdal.gdal.Dataset ds) |
static AVList |
extractRasterParameters(org.gdal.gdal.Dataset ds,
AVList params,
boolean quickReadingMode)
Extracts raster parameters to an AVList
|
protected static java.lang.String |
findGdalDataFolder() |
protected static java.lang.String[] |
findGdalFolders() |
protected static boolean |
gdalPreLoadNativeLibrary(boolean allowLogErrors) |
protected static java.lang.String |
getCurrentDirectory() |
static java.lang.String |
getErrorMessage() |
protected static LatLon |
getLatLonForRasterPoint(double[] gt,
int x,
int y,
org.gdal.osr.CoordinateTransformation ct) |
protected static void |
initialize() |
protected static boolean |
is32bitArchitecture() |
protected static void |
listAllRegisteredDrivers() |
static org.gdal.gdal.Dataset |
open(java.lang.Object source)
Opens image or elevation file, returns a DataSet object
|
static org.gdal.gdal.Dataset |
open(java.lang.Object source,
boolean isSilentMode)
Opens image or elevation file, returns a DataSet object
|
protected static void |
replaceLibraryLoader() |
protected static void |
restoreJavaLibraryPath() |
protected static void |
scanFill(java.awt.image.BufferedImage sourceImage) |
protected static boolean |
setNoDataValue(org.gdal.gdal.Band band,
java.lang.Double nodata) |
protected static java.awt.image.BufferedImage |
verticalFlip(java.awt.image.BufferedImage img)
Flips image raster vertically
|
public static long ALPHA_MASK
protected static byte ALPHA_OPAQUE
protected static byte ALPHA_TRANSPARENT
protected static final java.util.concurrent.CopyOnWriteArraySet<java.lang.String> failedLibraries
protected static final java.lang.String GDAL_DATA_PATH
protected static final java.lang.String GDAL_DRIVER_PATH
protected static final java.lang.String gdalalljni
protected static final java.util.concurrent.atomic.AtomicBoolean gdalIsAvailable
protected static final java.lang.String JAVA_LIBRARY_PATH
protected static final java.util.concurrent.CopyOnWriteArraySet<java.lang.String> loadedLibraries
protected static final java.lang.String OGR_DRIVER_PATH
protected static void alterJavaLibraryPath(java.lang.String newJavaLibraryPath)
throws java.lang.IllegalAccessException,
java.lang.NoSuchFieldException
java.lang.IllegalAccessExceptionjava.lang.NoSuchFieldExceptionprotected static void applyImageMask(byte[] alphaBand,
java.nio.IntBuffer maskBand)
protected static void applyImageMask(int[] alphaBand,
java.nio.IntBuffer maskBand)
protected static void applyImageMask(short[] alphaBand,
java.nio.IntBuffer maskBand)
protected static java.lang.String buildPathString(java.lang.String[] folders,
boolean addDefaultValues)
public static double[] calcGetGeoTransform(Sector sector, int width, int height) throws java.lang.IllegalArgumentException
sector - Geographic area, a Sectorwidth - none-zero width of a rasterheight - none-zero height of a rasterjava.lang.IllegalArgumentException - if sector is null, or raster size is zeropublic static boolean canOpen(java.lang.Object source)
source - the location of the local file, expressed as either a String path, a File, or a file URL.public static DataRaster composeDataRaster(org.gdal.gdal.Dataset ds, AVList params) throws java.lang.IllegalArgumentException, WWRuntimeException
java.lang.IllegalArgumentExceptionWWRuntimeExceptionprotected static DataRaster composeImageDataRaster(org.gdal.gdal.Dataset ds, AVList params) throws java.lang.IllegalArgumentException, java.lang.SecurityException, WWRuntimeException
ds - GDAL's Dataset objectparams - AVList of parametersjava.lang.IllegalArgumentException - if file is nulljava.lang.SecurityException - if file could not be readWWRuntimeException - if GDAL library was not initializedprotected static DataRaster composeNonImageDataRaster(org.gdal.gdal.Dataset ds, AVList params) throws java.lang.IllegalArgumentException, WWRuntimeException
ds - The GDAL dataset with data raster (expected only elevation raster); f or imagery rasters use
composeImageDataRaster() methodparams - , The AVList with properties (usually used to force projection info or sector)java.lang.IllegalArgumentException - if raster parameters (height, width, sector, etc) are invalidWWRuntimeException - when invalid raster detected (like attempt to use the method for imagery
raster)protected static java.lang.Double convertStringToDouble(java.lang.String s)
public static org.gdal.osr.SpatialReference createGeographicSRS()
throws WWRuntimeException
WWRuntimeExceptionprotected static java.awt.image.BufferedImage detectVoidsAndMakeThemTransparent(java.awt.image.BufferedImage sourceImage)
http://en.wikipedia.org/wiki/Flood_fill#Scanline_fillsourceImage - a source image rasterpublic static int[] extractBandOrder(org.gdal.gdal.Dataset ds,
AVList params)
throws java.lang.IllegalArgumentException,
WWRuntimeException
java.lang.IllegalArgumentExceptionWWRuntimeExceptionprotected static java.nio.IntBuffer extractImageMask(AVList params)
protected static void extractMinMaxSampleValues(org.gdal.gdal.Dataset ds,
org.gdal.gdal.Band band,
AVList params)
public static AVList extractRasterParameters(org.gdal.gdal.Dataset ds) throws java.lang.IllegalArgumentException, WWRuntimeException
java.lang.IllegalArgumentExceptionWWRuntimeExceptionpublic static AVList extractRasterParameters(org.gdal.gdal.Dataset ds, AVList params, boolean quickReadingMode) throws java.lang.IllegalArgumentException, WWRuntimeException
ds - A GDAL datasetparams - AVList to hold retrieved metadata, if null, a new instance will be created and returned
as a return valuequickReadingMode - if quick reading mode is enabled GDAL will not spend much time on heavy calculations,
like for example calculating Min/Max for entire elevation rasterjava.lang.IllegalArgumentException - when the passed dataset is null pr emtpy, or any of the dimension is 0WWRuntimeException - if GDAL is not available, or a dataset contains no bands
The extractRasterParameters() 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
AVKey.COORDINATE_SYSTEM_NAME
AVKey.PIXEL_WIDTH (Double) pixel size, UTM images usually specify 1 (1 meter);
if missing and Geographic Coordinate System is specified will be calculated as
LongitudeDelta/WIDTH
AVKey.PIXEL_HEIGHT (Double) pixel size, UTM images usually specify 1 (1 meter);
if missing and Geographic Coordinate System is specified will be calculated as
LatitudeDelta/HEIGHT
AVKey.ORIGIN (LatLon) specifies coordinate of the image's origin (one of the
corners, or center) If missing, upper left corner will be set as origin
AVKey.DATE_TIME (0 terminated String, length == 20) if missing, current date &
time will be used
AVKey.PIXEL_FORMAT required (valid values: AVKey.ELEVATION | AVKey.IMAGE }
specifies weather it is a digital elevation model or image
AVKey.IMAGE_COLOR_FORMAT required if AVKey.PIXEL_FORMAT is AVKey.IMAGE (valid
values: AVKey.COLOR and AVKey.MONOCHROME)
AVKey.DATA_TYPE required ( valid values: AVKey.INT16, and AVKey.FLOAT32 )
AVKey.VERSION optional, if missing a default will be used "NASA WorldWind"
AVKey.DISPLAY_NAME, (String) optional, specifies a name of the document/image
AVKey.DESCRIPTION (String) optional, for any kind of descriptions
AVKey.MISSING_DATA_SIGNAL optional, set the AVKey.MISSING_DATA_SIGNAL ONLY if
you know for sure that the specified value actually represents void (NODATA)
areas. Elevation data usually has "-32767" (like DTED), or "-32768" like SRTM,
but some has "0" (mostly images) and "-9999" like NED. Note! Setting "-9999" is
very ambiguos because -9999 for elevation is valid value;
AVKey.MISSING_DATA_REPLACEMENT (String type forced by spec) Most images have
"NODATA" as "0", elevations have as "-9999", or "-32768" (sometimes "-32767")
AVKey.COORDINATE_SYSTEM required, valid values AVKey.COORDINATE_SYSTEM_GEOGRAPHIC
or AVKey.COORDINATE_SYSTEM_PROJECTED
AVKey.COORDINATE_SYSTEM_NAME Optional, A name of the Coordinates System as a
String
AVKey.PROJECTION_EPSG_CODE Required; Integer; EPSG code or Projection Code If CS
is Geodetic and EPSG code is not specified, a default WGS84 (4326) will be used
AVKey.PROJECTION_DATUM Optional, AVKey.PROJECTION_DESC Optional,
AVKey.PROJECTION_NAME Optional, AVKey.PROJECTION_UNITS Optional,
AVKey.ELEVATION_UNIT Required, if AVKey.PIXEL_FORMAT = AVKey.ELEVATION, value:
AVKey.UNIT_FOOT or AVKey.UNIT_METER (default, if not specified)
AVKey.RASTER_PIXEL, optional, values: AVKey.RASTER_PIXEL_IS_AREA or
AVKey.RASTER_PIXEL_IS_POINT if not specified, default for images is
RASTER_PIXEL_IS_AREA, and AVKey.RASTER_PIXEL_IS_POINT for elevationsprotected static java.lang.String findGdalDataFolder()
protected static java.lang.String[] findGdalFolders()
protected static boolean gdalPreLoadNativeLibrary(boolean allowLogErrors)
protected static java.lang.String getCurrentDirectory()
public static java.lang.String getErrorMessage()
protected static LatLon getLatLonForRasterPoint(double[] gt, int x, int y, org.gdal.osr.CoordinateTransformation ct)
protected static void initialize()
protected static boolean is32bitArchitecture()
protected static void listAllRegisteredDrivers()
public static org.gdal.gdal.Dataset open(java.lang.Object source)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
WWRuntimeException
source - the location of the local file, expressed as either a String path, a File, or a file URL.java.io.FileNotFoundException - if file not foundjava.lang.IllegalArgumentException - if file is nulljava.lang.SecurityException - if file could not be readWWRuntimeException - if GDAL library was not initializedpublic static org.gdal.gdal.Dataset open(java.lang.Object source,
boolean isSilentMode)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
WWRuntimeException
source - the location of the local file, expressed as either a String path, a File, or a file URL.isSilentMode - specifies a silent mode of reading file (usually needed for canRead() and readMetadata())java.io.FileNotFoundException - if file not foundjava.lang.IllegalArgumentException - if file is nulljava.lang.SecurityException - if file could not be readWWRuntimeException - if GDAL library was not initializedprotected static void replaceLibraryLoader()
protected static void restoreJavaLibraryPath()
protected static void scanFill(java.awt.image.BufferedImage sourceImage)
protected static boolean setNoDataValue(org.gdal.gdal.Band band,
java.lang.Double nodata)
protected static java.awt.image.BufferedImage verticalFlip(java.awt.image.BufferedImage img)
img - A source raster as a BufferedImage