Package org.geotools.coverage
Class TypeMap
Object
TypeMap
Utility methods for choosing a sample model or a color model on the
basis of a range of values. This class provides also some methods for mapping
SampleDimensionType to
DataBuffer types.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColorInterpretationgetColorInterpretation(ColorModel model, int band) Returns the color interpretation code for the specified color model and band number.static intReturns theDataBuffertype.static InternationalStringgetName(SampleDimensionType type) Returns the sample dimension type name as an international string.static NumberRange<? extends Number>Returns the range of positive sample values (excluding 0).static NumberRange<? extends Number>getRange(SampleDimensionType type) Returns the full range of sample values for the specified dimension type.static SampleDimensionTypegetSampleDimensionType(double min, double max) Returns the smallest sample dimension type capable to hold the specified range of values.static SampleDimensionTypegetSampleDimensionType(long min, long max) Returns the smallest sample dimension type capable to hold the specified range of values.static SampleDimensionTypegetSampleDimensionType(SampleModel model, int band) Returns the sample dimension type for the specified sample model and band number.static SampleDimensionTypegetSampleDimensionType(Range<?> range) Returns the smallest sample dimension type capable to hold the specified range of values.static intgetSize(SampleDimensionType type) Returns the size in bits.static booleanReturnstruefor floating-point data type.static booleanisSigned(SampleDimensionType type) Returnstruefor signed sample type.static NumberwrapSample(double value, SampleDimensionType type, boolean allowWidening) Wraps the specified value into a number of the specified data type.
-
Method Details
-
getSampleDimensionType
Returns the smallest sample dimension type capable to hold the specified range of values.- Parameters:
range- The range of values.- Returns:
- The smallest sample dimension type for the specified range.
-
getSampleDimensionType
Returns the smallest sample dimension type capable to hold the specified range of values. An heuristic approach is used for non-integer values.- Parameters:
min- The lower value, inclusive.max- The upper value, inclusive as well.- Returns:
- The smallest sample dimension type for the specified range.
-
getSampleDimensionType
Returns the smallest sample dimension type capable to hold the specified range of values.- Parameters:
min- The lower value, inclusive.max- The upper value, inclusive as well.- Returns:
- The smallest sample dimension type for the specified range.
-
getSampleDimensionType
public static SampleDimensionType getSampleDimensionType(SampleModel model, int band) throws IllegalArgumentException Returns the sample dimension type for the specified sample model and band number. If the sample model use an undefined data type, then this method returnsnull.- Parameters:
model- The sample model.band- The band to query.- Returns:
- The sample dimension type for the specified sample model and band number.
- Throws:
IllegalArgumentException- if the band number is not in the valid range.
-
getName
Returns the sample dimension type name as an international string. For example, the localized name forSampleDimensionType.UNSIGNED_16BITSis "16 bits unsigned integer" in English and "Entier non-signé sur 16 bits" in French. -
getDataBufferType
Returns theDataBuffertype. This is one of the following constants:TYPE_BYTE,TYPE_USHORT,TYPE_SHORT,TYPE_INT,TYPE_FLOAT,TYPE_DOUBLEorDataBuffer.TYPE_UNDEFINEDif the type is unrecognized. -
getSize
Returns the size in bits. The value range from 1 to 64. This is similar, but different thanDataBuffer.getDataTypeSize(int), which have values ranging from 8 to 64. -
isSigned
Returnstruefor signed sample type. -
isFloatingPoint
Returnstruefor floating-point data type. -
getRange
Returns the full range of sample values for the specified dimension type. -
getPositiveRange
Returns the range of positive sample values (excluding 0). This range is non-null only for unsigned type. A range excluding 0 is sometime usefull when the 0 value is reserved for a "no data" category. -
wrapSample
public static Number wrapSample(double value, SampleDimensionType type, boolean allowWidening) throws IllegalArgumentException Wraps the specified value into a number of the specified data type. If the value can't fit in the specified type, then a wider type is choosen unlessallowWideningisfalse.- Parameters:
value- The value to wrap in aNumberobject.type- A constant from theSampleDimensionTypecode list.allowWidening-trueif this method is allowed to returns a wider type than the usual one for the specifiedtype.- Returns:
- The value as a
Number. - Throws:
IllegalArgumentException- iftypeis not a recognized constant.IllegalArgumentException- ifallowWideningisfalseand the specifiedvaluecan't fit in the specified sample type.
-
getColorInterpretation
public static ColorInterpretation getColorInterpretation(ColorModel model, int band) throws IllegalArgumentException Returns the color interpretation code for the specified color model and band number.- Parameters:
model- The color model.band- The band to query.- Returns:
- The code for the specified color model and band number.
- Throws:
IllegalArgumentException- if the band number is not in the valid range.
-