|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.coverage.grid.GridCoverageBuilder
public class GridCoverageBuilder
Helper class for the creation of GridCoverage2D
instances. The only purpose of this
builder is to make GridCoverage2D
construction a little bit easier for some common
cases. This class provides default values for each property which make it convenient for simple
cases and testing purpose, but is not generic. Users wanting more control and flexibility should
use GridCoverageFactory
directly.
Usage example:
GridCoverageBuilder builder = new GridCoverageBuilder(); builder.#setCoordinateReferenceSystem(String) setCoordinateReferenceSystem("EPSG:4326"); builder.{@linkplain #setEnvelope(double...) setEnvelope}(-60, 40, -50, 50); // Will use sample value in the range 0 inclusive to 20000 exclusive. builder.{@linkplain #setSampleRange(int,int) setSampleRange}(0, 20000); // Defines elevation (m) = sample / 10 Variable elevation = builder.{@linkplain #newVariable newVariable}("Elevation", SI.METRE); elevation.{@linkplain GridCoverageBuilder.Variable#setLinearTransform setLinearTransform}(0.1, 0); elevation.addNodataValue("No data", 32767); // Gets the image, draw anything we want in it. builder.{@linkplain #setImageSize(int,int) setImageSize}(500,500); BufferedImage image = builder.{@linkpalin #getBufferedImage getBufferedImage}(); Graphics2D gr = image.createGraphics(); gr.draw(...); gr.dispose(); // Gets the coverage. GridCoverage2D coverage = builder.{@linkplain #getGridCoverage2D getGridCoverage2D}();
Nested Class Summary | |
---|---|
class |
GridCoverageBuilder.Variable
A variable to be mapped to a sample dimension. |
Field Summary | |
---|---|
protected java.util.List<GridCoverageBuilder.Variable> |
variables
The list of variables created. |
Constructor Summary | |
---|---|
GridCoverageBuilder()
Creates a builder initialized to default values and factory. |
|
GridCoverageBuilder(GridCoverageFactory factory)
Creates a builder initialized to default values. |
Method Summary | |
---|---|
java.awt.image.BufferedImage |
getBufferedImage()
Returns the buffered image to be wrapped by GridCoverage2D . |
org.opengis.referencing.crs.CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the current coordinate reference system. |
org.opengis.geometry.Envelope |
getEnvelope()
Returns a copy of current envelope. |
GridCoverage2D |
getGridCoverage2D()
Returns the grid coverage. |
java.awt.Dimension |
getImageSize()
Returns the image size. |
NumberRange<? extends java.lang.Number> |
getSampleRange()
Returns the range of sample values. |
GridCoverageBuilder.Variable |
newVariable(java.lang.CharSequence name,
javax.measure.unit.Unit<?> units)
Creates a new variable, which will be mapped to a sample dimension. |
void |
setBufferedImage(java.awt.image.BufferedImage image)
Sets the buffered image. |
void |
setBufferedImage(java.io.File file)
Sets the buffered image by reading it from the given file. |
void |
setBufferedImage(java.util.Random random)
Sets the buffered image to a raster filled with random value using the specified random number generator. |
void |
setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Sets the coordinate reference system to the specified value. |
void |
setCoordinateReferenceSystem(java.lang.String code)
Sets the coordinate reference system to the specified authority code. |
void |
setEnvelope(double... ordinates)
Sets the envelope to the specified values, which must be the lower corner coordinates followed by upper corner coordinates. |
void |
setEnvelope(org.opengis.geometry.Envelope envelope)
Sets the envelope to the specified value. |
void |
setImageSize(java.awt.Dimension size)
Sets the image size. |
void |
setImageSize(int width,
int height)
Sets the image size. |
void |
setSampleRange(int lower,
int upper)
Sets the range of sample values. |
void |
setSampleRange(NumberRange<? extends java.lang.Number> range)
Sets the range of sample values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.List<GridCoverageBuilder.Variable> variables
newVariable(java.lang.CharSequence, javax.measure.unit.Unit>)
Constructor Detail |
---|
public GridCoverageBuilder()
public GridCoverageBuilder(GridCoverageFactory factory)
Method Detail |
---|
public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
public void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the CRS is illegal for the
current envelope.public void setCoordinateReferenceSystem(java.lang.String code) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the given CRS is illegal.public org.opengis.geometry.Envelope getEnvelope()
public void setEnvelope(org.opengis.geometry.Envelope envelope) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the envelope is illegal for the
current CRS.public void setEnvelope(double... ordinates) throws java.lang.IllegalArgumentException
Example: (xmin, ymin, zmin, xmax, ymax, zmax)
java.lang.IllegalArgumentException
public NumberRange<? extends java.lang.Number> getSampleRange()
public void setSampleRange(NumberRange<? extends java.lang.Number> range)
public void setSampleRange(int lower, int upper)
lower
- The lower sample value (inclusive), typically 0.upper
- The upper sample value (exclusive), typically 256.public java.awt.Dimension getImageSize()
public void setImageSize(java.awt.Dimension size)
public void setImageSize(int width, int height)
public GridCoverageBuilder.Variable newVariable(java.lang.CharSequence name, javax.measure.unit.Unit<?> units)
name
- The variable name, or null
for a default name.units
- The variable units, or null
if unknown.
public java.awt.image.BufferedImage getBufferedImage()
GridCoverage2D
. If no image has been
explicitly defined, a new one is created the first time
this method is invoked. Users can write in this image before to create the grid coverage.
public void setBufferedImage(java.awt.image.BufferedImage image)
public void setBufferedImage(java.io.File file) throws java.io.IOException
java.io.IOException
- if the image can't be read.public void setBufferedImage(java.util.Random random)
public GridCoverage2D getGridCoverage2D()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |