|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectPropertySourceImpl
AbstractCoverage
CoverageStack
public class CoverageStack
Wraps a stack of coverages as an extra dimension. For example this class
can wraps an array of GridCoverage2D
on the same geographic
area, but where each GridCoverage2D
is for a different date. This CoverageStack
manages the two-dimensional coverages as if the whole set was a three-dimensional coverage.
Each coverage element in the stack usually covers the same geographic area, but this is not a requirement. As of GeoTools 2.5, elements are not required to have the same coordinate reference system neither, but they are required to handle the transformation from this coverage CRS to their CRS.
Coverage elements are often two-dimensional, but this is not a requirement. This stack will
simply append one dimension to the element CRS. Coverage elements may be themself backed by
instances of CoverateStack
, thus allowing construction of coverages with four or more
dimensions.
For documentation purpose, the new dimension added by CoverageStack
is called
z. But this is only a naming convention - the new dimension can really be
anything, including time.
GridCoverage2D
objects tend to be big. In order to keep memory usage raisonable, this
implementation doesn't requires all GridCoverage
objects at once. Instead, it requires
an array of CoverageStack.Element
objects, which will load the coverage content only when first
needed. This CoverageStack
implementation remember the last coverage elements used;
it will not trig new data loading as long as consecutive calls to evaluate(...)
methods require the same coverage elements. Apart from this very simple caching mechanism,
caching is the responsability of CoverageStack.Element
implementations. Note that this simple
caching mechanism is suffisient if evaluate(...)
methods are invoked with increasing
z values.
Each coverage element is expected to extends over a range of z values. If an
evaluate(...)
method is invoked with a z value not falling in the middle
of a coverage element, a linear interpolation is applied.
CoverageStack
implementation is thread-safe.
modules/library/coverage (gt-coverage.jar)
Nested Class Summary | |
---|---|
static class |
CoverageStack.Adapter
A convenience adapter class for wrapping a pre-loaded Coverage into an
CoverageStack.Element object. |
static interface |
CoverageStack.Element
An element in a coverage stack. |
Nested classes/interfaces inherited from class AbstractCoverage |
---|
AbstractCoverage.Renderable |
Field Summary | |
---|---|
int |
zDimension
The dimension of the z ordinate (the last value in coordinate points). |
Fields inherited from class AbstractCoverage |
---|
crs |
Fields inherited from class PropertySourceImpl |
---|
cachedPropertyNames, properties, propertySources |
Constructor Summary | |
---|---|
|
CoverageStack(CharSequence name,
Collection<? extends Coverage> coverages)
Constructs a new coverage stack with all the supplied elements. |
|
CoverageStack(CharSequence name,
CoordinateReferenceSystem crs,
Collection<? extends CoverageStack.Element> elements)
Constructs a new coverage stack with all the supplied elements. |
protected |
CoverageStack(CharSequence name,
CoverageStack source)
Constructs a new coverage using the same elements than the specified coverage stack. |
Method Summary | |
---|---|
void |
addIIOReadProgressListener(IIOReadProgressListener listener)
Adds an IIOReadProgressListener to the list of registered progress listeners. |
void |
addIIOReadWarningListener(IIOReadWarningListener listener)
Adds an IIOReadWarningListener to the list of registered warning listeners. |
List<Coverage> |
coveragesAt(double z)
Returns the coverages to be used for the specified z value. |
Object |
evaluate(DirectPosition coord)
Returns a sequence of values for a given point in the coverage. |
boolean[] |
evaluate(DirectPosition coord,
boolean[] dest)
Returns a sequence of boolean values for a given point in the coverage. |
byte[] |
evaluate(DirectPosition coord,
byte[] dest)
Returns a sequence of byte values for a given point in the coverage. |
double[] |
evaluate(DirectPosition coord,
double[] dest)
Returns a sequence of double values for a given point in the coverage. |
float[] |
evaluate(DirectPosition coord,
float[] dest)
Returns a sequence of float values for a given point in the coverage. |
int[] |
evaluate(DirectPosition coord,
int[] dest)
Returns a sequence of integer values for a given point in the coverage. |
Envelope |
getEnvelope()
Returns the bounding box for the coverage domain in coordinate system coordinates. |
int |
getNumSampleDimensions()
Returns the number of sample dimension in this coverage. |
SampleDimension |
getSampleDimension(int index)
Retrieve sample dimension information for the coverage. |
boolean |
isInterpolationEnabled()
Returns true if interpolation are enabled in the z value dimension. |
protected void |
logLoading(LogRecord record)
Invoked automatically when an image is about to be loaded. |
void |
removeIIOReadProgressListener(IIOReadProgressListener listener)
Removes an IIOReadProgressListener from the list of registered progress listeners. |
void |
removeIIOReadWarningListener(IIOReadWarningListener listener)
Removes an IIOReadWarningListener from the list of registered warning listeners. |
void |
setInterpolationEnabled(boolean flag)
Enable or disable interpolations in the z value dimension. |
void |
snap(DirectPosition point)
Snaps the specified coordinate point to the coordinate of the nearest voxel available in this coverage. |
Methods inherited from class AbstractCoverage |
---|
dispose, evaluate, evaluateInverse, find, find, getCommonPointRule, getCoordinateReferenceSystem, getDimension, getDomainElements, getDomainExtents, getLocale, getName, getRangeElements, getRangeType, getRenderableImage, getSources, list, select, show, show, show, toString |
Methods inherited from class PropertySourceImpl |
---|
getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int zDimension
Constructor Detail |
---|
public CoverageStack(CharSequence name, Collection<? extends Coverage> coverages) throws IOException
Coverage
).
The example below constructs two dimensional grid coverages (to be given as the
coverages
argument) for the same geographic area, but at different elevations:
This convenience constructor wraps all coverage intos anGridCoverageFactory factory = ...; CoordinateReferenceSystem crs2D = ...; // Yours horizontal CRS. TemporalCRS timeCRS = ...; // Yours CRS for time measurement. CoordinateReferenceSystem crs3D = new CompoundCRS(crs3D, timeCRS); List<Coverage> coverages = new ArrayList<Coverage>(); GeneralEnvelope envelope = new GeneralEnvelope(DefaultGeographicCRS.WGS84_3D); envelope.setRange(0, westLongitudeBound, eastLongitudeBound); envelope.setRange(1, southLatitudeBound, northLatitudeBound); for (int i=0; i<...; i++) { envelope.setRange(2, minElevation, maxElevation); coverages.add(factory.create(..., crs, envelope, ...); }
Adapter
object.
Users with a significant amount of data are encouraged to uses the constructor expecting
Element
objects instead, in order to provides their own implementation
loading data only when needed.
name
- The name for this coverage.coverages
- All Coverage
elements for this stack.
IOException
- if an I/O operation was required and failed.public CoverageStack(CharSequence name, CoordinateReferenceSystem crs, Collection<? extends CoverageStack.Element> elements) throws IOException
If crs
is null
, this constructor will try to infer the CRS from the
element envelope but at least one of those must be
associated with a full CRS (including the z dimension).
name
- The name for this coverage.crs
- The coordinate reference system for this coverage, or null
.elements
- All coverage Element
s for this stack.
IOException
- if an I/O operation was required and failed.protected CoverageStack(CharSequence name, CoverageStack source)
Method Detail |
---|
public Envelope getEnvelope()
getEnvelope
in interface Coverage
getEnvelope
in class AbstractCoverage
public int getNumSampleDimensions()
public SampleDimension getSampleDimension(int index)
public void snap(DirectPosition point) throws IOException
point
coordinate in the coverage element. The point
is then set to the pixel center coordinate and to the z value of the selected
coverage element. Consequently, calling any evaluate(...)
method with snapped
coordinates will returns non-interpolated values.
point
- The point to snap.
IOException
- if an I/O operation was required but failed.public Object evaluate(DirectPosition coord) throws CannotEvaluateException
evaluate(DirectPosition, double[])
method.
coord
- The coordinate point where to evaluate.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public boolean[] evaluate(DirectPosition coord, boolean[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- The coordinate point where to evaluate.dest
- An array in which to store values, or null
to create a new array.
dest
array, or a newly created array if dest
was null.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public byte[] evaluate(DirectPosition coord, byte[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- The coordinate point where to evaluate.dest
- An array in which to store values, or null
to create a new array.
dest
array, or a newly created array if dest
was null.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public int[] evaluate(DirectPosition coord, int[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- The coordinate point where to evaluate.dest
- An array in which to store values, or null
to create a new array.
dest
array, or a newly created array if dest
was null.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public float[] evaluate(DirectPosition coord, float[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- The coordinate point where to evaluate.dest
- An array in which to store values, or null
to create a new array.
dest
array, or a newly created array if dest
was null.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public double[] evaluate(DirectPosition coord, double[] dest) throws CannotEvaluateException
evaluate
in interface Coverage
evaluate
in class AbstractCoverage
coord
- The coordinate point where to evaluate.dest
- An array in which to store values, or null
to create a new array.
dest
array, or a newly created array if dest
was null.
PointOutsideCoverageException
- if coord
is outside coverage.
CannotEvaluateException
- if the computation failed for some other reason.public List<Coverage> coveragesAt(double z)
z
- The z value for the coverages to be returned.
public boolean isInterpolationEnabled()
true
if interpolation are enabled in the z value dimension.
Interpolations are enabled by default.
public void setInterpolationEnabled(boolean flag)
public void addIIOReadWarningListener(IIOReadWarningListener listener)
IIOReadWarningListener
to the list of registered warning listeners.
public void removeIIOReadWarningListener(IIOReadWarningListener listener)
IIOReadWarningListener
from the list of registered warning listeners.
public void addIIOReadProgressListener(IIOReadProgressListener listener)
IIOReadProgressListener
to the list of registered progress listeners.
public void removeIIOReadProgressListener(IIOReadProgressListener listener)
IIOReadProgressListener
from the list of registered progress listeners.
protected void logLoading(LogRecord record)
"org.geotools.coverage"
logger. Subclasses can override
this method if they wants a different logging.
record
- The log record. The message contains information about the images to load.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |