Package org.geotools.referencing
Class CoordinateFormat
- All Implemented Interfaces:
Serializable,Cloneable
Formats a direct position in an arbitrary coordinate reference system. The format for each ordinate is infered from the coordinate system units using the
following rules:
- Ordinate values in degrees are formated as angles using
AngleFormat. - Ordinate values in any unit compatible with seconds are formated as dates using
DateFormat. - All other values are formatted as numbers using
NumberFormat.
- Since:
- 2.0
- Author:
- Martin Desruisseaux (PMO, IRD)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new coordinate format with default locale and a two-dimensional geographic (WGS 1984) coordinate reference system.CoordinateFormat(Locale locale) Construct a new coordinate format for the specified locale and a two-dimensional geographic (WGS 1984) coordinate reference system.CoordinateFormat(Locale locale, CoordinateReferenceSystem crs) Constructs a new coordinate format for the specified locale and coordinate reference system. -
Method Summary
Modifier and TypeMethodDescriptionformat(Object object, StringBuffer toAppendTo, FieldPosition position) Formats a direct position and appends the resulting text to a given string buffer.Formats a direct position.format(Position point, StringBuffer toAppendTo, FieldPosition position) Formats a direct position and appends the resulting text to a given string buffer.Returns the coordinate reference system for points to be formatted.getFormat(int dimension) Returns the format to use for formatting an ordinate at the given dimension.Returns the separator between each coordinate (number, angle or date).parseObject(String source, ParsePosition position) Not yet implemented.voidsetAnglePattern(String pattern) Set the pattern for angles fields.voidSet the coordinate reference system for points to be formatted.voidsetDatePattern(String pattern) Set the pattern for dates fields.voidsetNumberPattern(String pattern) Set the pattern for numbers fields.voidsetSeparator(String separator) Set the separator between each coordinate.voidsetTimeZone(TimeZone timezone) Set the time zone for dates fields.Methods inherited from class Format
clone, format, formatToCharacterIterator, parseObject
-
Constructor Details
-
CoordinateFormat
public CoordinateFormat()Constructs a new coordinate format with default locale and a two-dimensional geographic (WGS 1984) coordinate reference system. -
CoordinateFormat
Construct a new coordinate format for the specified locale and a two-dimensional geographic (WGS 1984) coordinate reference system.- Parameters:
locale- The locale for formatting coordinates and numbers.
-
CoordinateFormat
Constructs a new coordinate format for the specified locale and coordinate reference system.- Parameters:
locale- The locale for formatting coordinates and numbers.crs- The output coordinate reference system.
-
-
Method Details
-
getCoordinateReferenceSystem
Returns the coordinate reference system for points to be formatted.- Returns:
- The output coordinate reference system.
-
setCoordinateReferenceSystem
Set the coordinate reference system for points to be formatted. The number of dimensions must matched the dimension of points to be formatted.- Parameters:
crs- The new coordinate system.
-
getSeparator
Returns the separator between each coordinate (number, angle or date).- Returns:
- The current coordinate separator.
- Since:
- 2.2
-
setSeparator
Set the separator between each coordinate.- Parameters:
separator- The new coordinate separator.- Since:
- 2.2
-
setNumberPattern
Set the pattern for numbers fields. If some ordinates are formatted as plain number (for example in cartesian coordinate system), then those numbers will be formatted using this pattern.- Parameters:
pattern- The number pattern as specified inDecimalFormat.
-
setAnglePattern
Set the pattern for angles fields. If some ordinates are formatted as angle (for example in ellipsoidal coordinate system), then those angles will be formatted using this pattern.- Parameters:
pattern- The angle pattern as specified inAngleFormat.
-
setDatePattern
Set the pattern for dates fields. If some ordinates are formatted as date (for example in time coordinate system), then those dates will be formatted using this pattern.- Parameters:
pattern- The date pattern as specified inSimpleDateFormat.
-
setTimeZone
Set the time zone for dates fields. If some ordinates are formatted as date (for example in time coordinate system), then those dates will be formatted using the specified time zone.- Parameters:
timezone- The time zone for dates.
-
getFormat
Returns the format to use for formatting an ordinate at the given dimension. The dimension parameter range from 0 inclusive to the coordinate reference system's dimension, exclusive. This method returns a direct reference to the internal format; any change to the returnedFormatobject will change the formatting for thisCoordinateFormatobject.- Parameters:
dimension- The dimension for the ordinate to format.- Returns:
- The format for the given dimension.
- Throws:
IndexOutOfBoundsException- ifdimensionis out of range.
-
format
Formats a direct position. The position's dimension must matches the coordinate reference system dimension.- Parameters:
point- The position to format.- Returns:
- The formatted position.
- Throws:
IllegalArgumentException- if thisCoordinateFormatcannot format the given object.
-
format
public StringBuffer format(Position point, StringBuffer toAppendTo, FieldPosition position) throws IllegalArgumentException Formats a direct position and appends the resulting text to a given string buffer. The position's dimension must matches the coordinate reference system dimension.- Parameters:
point- The position to format.toAppendTo- Where the text is to be appended.position- AFieldPositionidentifying a field in the formatted text, ornullif none.- Returns:
- The string buffer passed in as
toAppendTo, with formatted text appended. - Throws:
IllegalArgumentException- if thisCoordinateFormatcannot format the given object.
-
format
public StringBuffer format(Object object, StringBuffer toAppendTo, FieldPosition position) throws IllegalArgumentException Formats a direct position and appends the resulting text to a given string buffer. The position's dimension must matches the coordinate reference system dimension.- Specified by:
formatin classFormat- Parameters:
object- ThePositionto format.toAppendTo- Where the text is to be appended.position- AFieldPositionidentifying a field in the formatted text, ornullif none.- Returns:
- The string buffer passed in as
toAppendTo, with formatted text appended. - Throws:
NullPointerException- iftoAppendTois null.IllegalArgumentException- if thisCoordinateFormatcannot format the given object.
-
parseObject
Not yet implemented.- Specified by:
parseObjectin classFormat- Parameters:
source- The string to parse.position- The position of the first character to parse.
-