org.deegree.coverage.raster.utils
Class RasterFactory

java.lang.Object
  extended by org.deegree.coverage.raster.utils.RasterFactory

public class RasterFactory
extends Object

This class reads and writes raster files. The actual raster loading and writing is handled by RasterReader and RasterWriter implementations. TODO use the new, not yet implemented, configuration framework to allow customization of the IO classes

Version:
$Revision: 31644 $
Author:
Oliver Tonnhofer, last edited by: $Author: mschneider $

Constructor Summary
RasterFactory()
           
 
Method Summary
static SimpleRaster createEmptyRaster(RasterDataInfo rdi, Envelope worldEnvelope, RasterGeoReference rasterGeoReference)
          Creates a new Raster data object from the given world envelope, a raster reference and the data info object (holding information about type, size etc...).
static SimpleRaster createEmptyRaster(RasterDataInfo rdi, Envelope worldEnvelope, RasterGeoReference rasterGeoReference, RasterReader reader, boolean addToCache, RasterIOOptions options)
          Creates a new Raster data object from the given world envelope, a raster reference and the data info object (holding information about type, size etc...).
static AbstractRaster createRasterFromImage(RenderedImage image, Envelope envelope, RasterGeoReference.OriginLocation originLocation)
          Creates a simple raster from a given BufferedImage and sets the geo reference to the given envelope.
static AbstractRaster createRasterFromImage(RenderedImage image, Envelope envelope, RasterGeoReference.OriginLocation originLocation, RasterIOOptions options)
          Creates a simple raster from a given BufferedImage and sets the geo reference to the given envelope.
static Set<String> getAllSupportedWritingFormats()
          Find all RasterIOLoaders and retrieve all the (image) formats they support on writing.
static BufferedImage imageFromRaster(AbstractRaster raster)
          Creates a buffered image from a given AbstractRaster, note creating an image might result in a incorrect view of the raster.
static AbstractRaster loadRasterFromFile(File filename)
          Load a raster from a file.
static AbstractRaster loadRasterFromFile(File filename, RasterIOOptions options)
          Load a raster from a file.
static AbstractRaster loadRasterFromStream(InputStream in, RasterIOOptions options)
          Load a raster from a stream.
static ByteBufferRasterData rasterDataFromImage(BufferedImage img)
          Creates a buffered image from the given raster data by calling the rasterDataFromImage(RenderedImage, RasterIOOptions, ByteBuffer) method without any options
static ByteBufferRasterData rasterDataFromImage(RenderedImage img, RasterIOOptions options)
          Creates Raster data from the given RenderedImage image.
static ByteBufferRasterData rasterDataFromImage(RenderedImage img, RasterIOOptions options, ByteBuffer byteBuffer)
          Creates Raster data from the given buffered image.
static BufferedImage rasterDataToImage(RasterData sourceRaster)
          Convert RasterData into a BufferedImage
static ByteBuffer rasterToByteBuffer(Raster imageRaster, int x, int y, int width, int height, DataType type, ByteBuffer byteBuffer)
          Create a byte buffer from the given raster, the Bytebuffer will be filled row order, that is, pixel(0,0);(0,1)
static void saveRasterToFile(AbstractRaster raster, File filename)
          Save a raster to a file.
static void saveRasterToFile(AbstractRaster raster, File filename, RasterIOOptions options)
          Save a raster to a file.
static void saveRasterToStream(AbstractRaster raster, OutputStream out, RasterIOOptions options)
          Save a raster to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RasterFactory

public RasterFactory()
Method Detail

loadRasterFromFile

public static AbstractRaster loadRasterFromFile(File filename)
                                         throws IOException
Load a raster from a file.

Parameters:
filename - the filename of the raster
Returns:
the loaded raster as an AbstractRaster
Throws:
IOException

loadRasterFromFile

public static AbstractRaster loadRasterFromFile(File filename,
                                                RasterIOOptions options)
                                         throws IOException
Load a raster from a file.

Parameters:
filename - the filename of the raster
options -
Returns:
the loaded raster as an AbstractRaster
Throws:
IOException

loadRasterFromStream

public static AbstractRaster loadRasterFromStream(InputStream in,
                                                  RasterIOOptions options)
                                           throws IOException
Load a raster from a stream.

Parameters:
in -
options - map with options for the raster writer
Returns:
the loaded raster as an AbstractRaster
Throws:
IOException

saveRasterToFile

public static void saveRasterToFile(AbstractRaster raster,
                                    File filename)
                             throws IOException
Save a raster to a file.

Parameters:
raster -
filename -
Throws:
IOException

saveRasterToFile

public static void saveRasterToFile(AbstractRaster raster,
                                    File filename,
                                    RasterIOOptions options)
                             throws IOException
Save a raster to a file.

Parameters:
raster -
filename -
options - map with options for the raster writer
Throws:
IOException

saveRasterToStream

public static void saveRasterToStream(AbstractRaster raster,
                                      OutputStream out,
                                      RasterIOOptions options)
                               throws IOException
Save a raster to a stream.

Parameters:
raster -
out -
options - map with options for the raster writer
Throws:
IOException

getAllSupportedWritingFormats

public static Set<String> getAllSupportedWritingFormats()
Find all RasterIOLoaders and retrieve all the (image) formats they support on writing.

Returns:
a set of supported writable mime-types.

createRasterFromImage

public static AbstractRaster createRasterFromImage(RenderedImage image,
                                                   Envelope envelope,
                                                   RasterGeoReference.OriginLocation originLocation)
Creates a simple raster from a given BufferedImage and sets the geo reference to the given envelope.

Parameters:
image - to get as a raster
envelope - of the raster
originLocation - the mapped location of the world coordinate origin on the upper left raster coordinate.
Returns:
a geo referenced AbstractRaster.

createRasterFromImage

public static AbstractRaster createRasterFromImage(RenderedImage image,
                                                   Envelope envelope,
                                                   RasterGeoReference.OriginLocation originLocation,
                                                   RasterIOOptions options)
Creates a simple raster from a given BufferedImage and sets the geo reference to the given envelope.

Parameters:
image - to get as a raster
envelope - of the raster
originLocation - the mapped location of the world coordinate origin on the upper left raster coordinate.
options - with information about the image and resulting raster.
Returns:
a geo referenced AbstractRaster.

imageFromRaster

public static BufferedImage imageFromRaster(AbstractRaster raster)
Creates a buffered image from a given AbstractRaster, note creating an image might result in a incorrect view of the raster.

Parameters:
raster - to create the image from
Returns:
a BufferedImage created from the given raster.

rasterDataToImage

public static BufferedImage rasterDataToImage(RasterData sourceRaster)
Convert RasterData into a BufferedImage

Parameters:
sourceRaster - the source RasterData
Returns:
a BufferedImage

rasterDataFromImage

public static ByteBufferRasterData rasterDataFromImage(RenderedImage img,
                                                       RasterIOOptions options)
Creates Raster data from the given RenderedImage image. The options can be used to modify the outcome of the raster data image.

Parameters:
img -
options - which can hold information about the image read, may be null
Returns:
the rasterdata object from the image or null if the given img is null

rasterDataFromImage

public static ByteBufferRasterData rasterDataFromImage(RenderedImage img,
                                                       RasterIOOptions options,
                                                       ByteBuffer byteBuffer)
Creates Raster data from the given buffered image. The options can be used to modify the outcome of the raster data image.

Parameters:
img -
options - which can hold information about the image read, may be null
byteBuffer - to fill
Returns:
the rasterdata object from the image or null if the given img is null

rasterToByteBuffer

public static ByteBuffer rasterToByteBuffer(Raster imageRaster,
                                            int x,
                                            int y,
                                            int width,
                                            int height,
                                            DataType type,
                                            ByteBuffer byteBuffer)
Create a byte buffer from the given raster, the Bytebuffer will be filled row order, that is, pixel(0,0);(0,1)

Parameters:
imageRaster -
x -
y -
width -
height -
type -
byteBuffer -
Returns:
the byte buffer filled with data from the image raster.

rasterDataFromImage

public static ByteBufferRasterData rasterDataFromImage(BufferedImage img)
Creates a buffered image from the given raster data by calling the rasterDataFromImage(RenderedImage, RasterIOOptions, ByteBuffer) method without any options. *

Parameters:
img -
Returns:
the ByteBufferRasterData object from the image or null if the given img is null

createEmptyRaster

public static SimpleRaster createEmptyRaster(RasterDataInfo rdi,
                                             Envelope worldEnvelope,
                                             RasterGeoReference rasterGeoReference)
Creates a new Raster data object from the given world envelope, a raster reference and the data info object (holding information about type, size etc...). If any of the parameters are null null will be returned.

Parameters:
rdi -
worldEnvelope - describing the raster data.
rasterGeoReference - the raster geo reference defining the resolution of the raster.
Returns:
a raster data object according to the given parameters.

createEmptyRaster

public static SimpleRaster createEmptyRaster(RasterDataInfo rdi,
                                             Envelope worldEnvelope,
                                             RasterGeoReference rasterGeoReference,
                                             RasterReader reader,
                                             boolean addToCache,
                                             RasterIOOptions options)
Creates a new Raster data object from the given world envelope, a raster reference and the data info object (holding information about type, size etc...). If any of the parameters are null null will be returned.

Parameters:
rdi -
worldEnvelope - describing the raster data.
rasterGeoReference - the raster geo reference defining the resolution of the raster.
reader - to lazily instantiate the data from, may be null, if the raster should not be backed by any data.
addToCache - true if the raster data of the given raster should be added to the cache.
options - containing information about the raster caching.
Returns:
a raster data object according to the given parameters.


Copyright © 2011. All Rights Reserved.