*/
private void parseLinearUnit(final ProjectedCRS projectedCRS,
GeoTiffIIOMetadataEncoder metadata) {
// getting the linear unit
final Unit linearUnit = CRSUtilities.getUnit(projectedCRS
.getCoordinateSystem());
if (linearUnit != null && !SI.METER.isCompatible(linearUnit)) {
throw new IllegalArgumentException(Errors.format(
ErrorKeys.NON_LINEAR_UNIT_$1, linearUnit));
}
if (SI.METER.isCompatible(linearUnit)) {
if (SI.METER.equals(linearUnit)) {
metadata.addGeoShortParam(
GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
GeoTiffUoMCodes.Linear_Meter);
metadata.addGeoDoubleParam(
GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, 1.0);
}
if (NonSI.NAUTICAL_MILE.equals(linearUnit)) {
metadata.addGeoShortParam(
GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
GeoTiffUoMCodes.Linear_Mile_International_Nautical);
metadata.addGeoDoubleParam(
GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
.getConverterTo(SI.METER).convert(1));
}
if (NonSI.FOOT.equals(linearUnit)) {
metadata.addGeoShortParam(
GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
GeoTiffUoMCodes.Linear_Foot);
metadata.addGeoDoubleParam(
GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
.getConverterTo(SI.METER).convert(1));
}
if (NonSI.YARD.equals(linearUnit)) {
metadata.addGeoShortParam(
GeoTiffPCSCodes.ProjLinearUnitsGeoKey,
GeoTiffUoMCodes.Linear_Yard_Sears);// ??
metadata.addGeoDoubleParam(
GeoTiffPCSCodes.ProjLinearUnitSizeGeoKey, linearUnit
.getConverterTo(SI.METER).convert(1));
}
}
}