|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectMetadataHelper
public class MetadataHelper
Utility methods extracting commonly used informations from ISO 19115-2 or ISO 19123 objects.
Instances of ISO 19115-2 metadata are typically obtained from SpatialMetadata objects.
| coverage/geotk-coverageio (download) | View source code for this class |
| Field Summary | |
|---|---|
static MetadataHelper |
INSTANCE
The default instance. |
| Constructor Summary | |
|---|---|
MetadataHelper(Localized owner)
Creates a new metadata helper for the given ImageReader or ImageWriter. |
|
| Method Summary | |
|---|---|
double |
adjustForRoundingError(double value)
Works around the rounding errors found in some metadata numbers. |
String |
formatCellDimension(RectifiedGrid domain,
CoordinateSystem cs)
Returns the dimension of pixels as a text, or null if none. |
AffineTransform |
getAffineTransform(RectifiedGrid domain,
IIOParam param)
Creates an affine transform from the origin and offset vectors of the given domain. |
Dimension2D |
getCellDimension(AffineTransform gridToCRS)
Returns the dimension of pixels, or null if not applicable. |
double |
getCellSize(AffineTransform gridToCRS)
Returns the size of pixels, which must be square. |
List<GridSampleDimension> |
getGridSampleDimensions(List<? extends SampleDimension> sampleDimensions)
Converts the given SampleDimension instances to GridSampleDimension instances. |
MathTransform |
getGridToCRS(RectifiedGrid domain)
Creates the Grid to CRS conversion from the origin and offset vectors of the given domain. |
Locale |
getLocale()
Returns the locale used by this helper, or null for the default locale. |
NumberRange<?> |
getValidSampleValues(SampleDimension dimension)
Returns the range of sample values defined in the given SampleDimension object. |
NumberRange<?> |
getValidSampleValues(SampleDimension dimension,
double[] fillSampleValues)
Returns the range of sample values defined in the given SampleDimension object. |
NumberRange<?> |
getValidValues(SampleDimension dimension)
Returns the range of geophysics values defined in the given SampleDimension object. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final MetadataHelper INSTANCE
| Constructor Detail |
|---|
public MetadataHelper(Localized owner)
ImageReader or ImageWriter.
owner - The image reader or writer for which we are creating metadata,
or null if none.| Method Detail |
|---|
public Locale getLocale()
null for the default locale. This is
used for formatting text in methods like formatCellDimension,
and for localization of error messages when an exception is thrown.
getLocale in interface Localizednull if unspecified.public NumberRange<?> getValidValues(SampleDimension dimension)
SampleDimension object.
This method tries to build the range from the
minimum value,
maximum value,
scale factor,
offset and the
fill sample values metadata attributes.
dimension - The object from which to extract the range.
null.public NumberRange<?> getValidSampleValues(SampleDimension dimension)
SampleDimension object. This
method first looks at the value returned by SampleDimension.getValidSampleValues().
If the later returns null, then this method tries to build the range from the
minimum value,
maximum value and the
fill sample values metadata attributes.
The fill sample values are used in order to determine if the minimum and maximum values are inclusive or exclusive: if an extremum is equals to a fill sample value, then it is considered exclusive. Otherwise it is considered inclusive.
dimension - The object from which to extract the range.
null.
public NumberRange<?> getValidSampleValues(SampleDimension dimension,
double[] fillSampleValues)
SampleDimension object.
This method performs the same work than getValidSampleValues(SampleDimension),
except that the fill sample values are given explicitly. Note that the fill sample values
is not an ISO 19115-2 attribute.
dimension - The object from which to extract the range.fillSampleValues - The no-data values, or null if none.
null.
public MathTransform getGridToCRS(RectifiedGrid domain)
throws ImageMetadataException
This method is similar to getAffineTransform(RectifiedGrid, IIOParam), except that
it is not restricted to a two-dimensional conversion and does not take an IIOParam
object in account.
domain - The domain from which to extract the origin and offset vectors.
ImageMetadataException - If a mandatory attribute is missing from the given domain.
public AffineTransform getAffineTransform(RectifiedGrid domain,
IIOParam param)
throws ImageMetadataException
param parameter is non-null, then the affine transform is scaled and
translated according the subsampling, source and destination regions specified.
Note that the returned transform may maps pixel corner or pixel center, depending on the
value returned by Georectified.getPointInPixel().
It is caller responsibility to make the necessary adjustments (tip:
PixelTranslation may be useful).
domain - The domain from which to extract the origin and offset vectors.param - Optional Image I/O parameters, or null if none.
ImageMetadataException - If a mandatory attribute is missing from the given domain,
or if this method can not extract the two first dimensions from the domain.
public double getCellSize(AffineTransform gridToCRS)
throws ImageMetadataException
gridToCRS argument is
typically the output of getAffineTransform. This method
checks if the given transform complies with the following conditions:
scaleX coefficient must be
greater than zero.scaleY coefficient must be
the negative value of scaleX, because the Y axis is assumed
reversed.shearX and shearY coefficients must be zero.
If all those conditions are meet, then scaleX is returned. Otherwise an
exception is thrown. This behavior is convenient for code like the
ASCII Grid writer,
which require square pixels as of format specification.
gridToCRS - The affine transform from which to extract the cell size.
ImageMetadataException - If the affine transform does not comply with the above cited conditions.public Dimension2D getCellDimension(AffineTransform gridToCRS)
null if not applicable. The gridToCRS
argument is typically the output of getAffineTransform. This
method checks if the given transform complies with the following conditions:
If this condition is meet, then scaleX and the negative value
of scaleY (because the Y axis is assumed reversed) are returned in a new
Dimension2D object. Otherwise null is returned. This behavior is
convenient for code like the ASCII Grid writer, which require square pixels unless some extensions are enabled for
rectangular pixel.
gridToCRS - The affine transform from which to extract the cell size.
null if the image is rotated.
public String formatCellDimension(RectifiedGrid domain,
CoordinateSystem cs)
null if none. This method computes
the dimension from the offset vectors and
appends the axis units, if any.
domain - The domain from which to compute the cell dimensions.cs - The "real world" coordinate system, or null if unknown.
null if there is no
offset vectors.
public List<GridSampleDimension> getGridSampleDimensions(List<? extends SampleDimension> sampleDimensions)
throws ImageMetadataException
SampleDimension instances to GridSampleDimension instances.
For each input sample dimension, this method creates a qualitative category for each fill values (if any)
and a single quantitative category for the range of sample values.
The sampleDimensions argument is typically obtained by the following method call:
SpatialMetadata metadata = ... sampleDimensions = metadata.getListForType(SampleDimension.class);
sampleDimensions - The sample dimensions from Image I/O metadata, or null.
GridSampleDimensions, or null if the given list was null or empty.
ImageMetadataException - If this method can not create the grid sample dimensions.public double adjustForRoundingError(double value)
This method processes as below:
value - The value that we want to adjust.
XMath.roundIfAlmostInteger(double, int),
XAffineTransform.roundIfAlmostInteger(AffineTransform, double)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||