Package org.locationtech.jts.io
Class OrdinateFormat
java.lang.Object
org.locationtech.jts.io.OrdinateFormat
Formats numeric values for ordinates
in a consistent, accurate way.
The format has the following characteristics:
- It is consistent in all locales (in particular, the decimal separator is always a period)
- Scientific notation is never output, even for very large numbers. This means that it is possible that output can contain a large number of digits.
- The maximum number of decimal places reflects the available precision
- NaN values are represented as "NaN"
- Inf values are represented as "Inf" or "-Inf"
- Author:
- mdavis
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic OrdinateFormat
The default formatter using the maximum number of digits in the fraction portion of a number.static final int
The maximum number of fraction digits to support output of reasonable ordinate values.static final String
The output representation ofDouble.NaN
static final String
The output representation ofDouble.NEGATIVE_INFINITY
static final String
The output representation ofDouble.POSITIVE_INFINITY
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an OrdinateFormat using the default maximum number of fraction digits.OrdinateFormat
(int maximumFractionDigits) Creates an OrdinateFormat using the given maximum number of fraction digits. -
Method Summary
Modifier and TypeMethodDescriptionstatic OrdinateFormat
create
(int maximumFractionDigits) Creates a new formatter with the given maximum number of digits in the fraction portion of a number.format
(double ord) Returns a string representation of the given ordinate numeric value.
-
Field Details
-
REP_POS_INF
The output representation ofDouble.POSITIVE_INFINITY
- See Also:
-
REP_NEG_INF
The output representation ofDouble.NEGATIVE_INFINITY
- See Also:
-
REP_NAN
The output representation ofDouble.NaN
- See Also:
-
MAX_FRACTION_DIGITS
public static final int MAX_FRACTION_DIGITSThe maximum number of fraction digits to support output of reasonable ordinate values. The default is chosen to allow representing the smallest possible IEEE-754 double-precision value, although this is not expected to occur (and is not supported by other areas of the JTS code).- See Also:
-
DEFAULT
The default formatter using the maximum number of digits in the fraction portion of a number.
-
-
Constructor Details
-
OrdinateFormat
public OrdinateFormat()Creates an OrdinateFormat using the default maximum number of fraction digits. -
OrdinateFormat
public OrdinateFormat(int maximumFractionDigits) Creates an OrdinateFormat using the given maximum number of fraction digits.- Parameters:
maximumFractionDigits
- the maximum number of fraction digits to output
-
-
Method Details
-
create
Creates a new formatter with the given maximum number of digits in the fraction portion of a number.- Parameters:
maximumFractionDigits
- the maximum number of fraction digits to output- Returns:
- a formatter
-
format
Returns a string representation of the given ordinate numeric value.- Parameters:
ord
- the ordinate value- Returns:
- the formatted number string
-