*/
@Override
protected String formatTo(final Formatter formatter) {
WKTUtilities.appendName(descriptor, formatter, ElementKind.PARAMETER);
final Unit<?> targetUnit = formatter.toContextualUnit(descriptor.getUnit());
final Convention convention = formatter.getConvention();
final boolean isWKT1 = convention.majorVersion() == 1;
if (isWKT1 && targetUnit != null) {
double convertedValue;
try {
convertedValue = doubleValue(targetUnit);
} catch (IllegalStateException exception) {
// May happen if a parameter is mandatory (e.g. "semi-major")
// but no value has been set for this parameter.
formatter.setInvalidWKT(descriptor, exception);
convertedValue = Double.NaN;
}
formatter.append(convertedValue);
} else {
formatter.appendAny(value);
}
if (unit != null && !isWKT1 && (!convention.isSimplified() || !unit.equals(targetUnit))) {
formatter.append(unit);
}
return "Parameter";
}