org.geotools.measure
Class CoordinateFormat

java.lang.Object
  extended byjava.text.Format
      extended byorg.geotools.measure.CoordinateFormat
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
CoordinateFormat

public class CoordinateFormat
extends java.text.Format

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:

Note: parsing is not yet implemented in this version.

Since:
2.0
Version:
$Id: CoordinateFormat.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Constructor Summary
CoordinateFormat()
          Constructs a new coordinate format with default locale and a two-dimensional geographic (WGS 1984) coordinate reference system.
CoordinateFormat(java.util.Locale locale)
          Construct a new coordinate format for the specified locale and a two-dimensional geographic (WGS 1984) coordinate reference system.
CoordinateFormat(java.util.Locale locale, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Constructs a new coordinate format for the specified locale and coordinate reference system.
 
Method Summary
 java.lang.String format(org.opengis.spatialschema.geometry.DirectPosition point)
          Formats a direct position.
 java.lang.StringBuffer format(org.opengis.spatialschema.geometry.DirectPosition point, java.lang.StringBuffer toAppendTo, java.text.FieldPosition position)
          Formats a direct position and appends the resulting text to a given string buffer.
 java.lang.StringBuffer format(java.lang.Object object, java.lang.StringBuffer toAppendTo, java.text.FieldPosition position)
          Formats a direct position and appends the resulting text to a given string buffer.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the coordinate reference system for points to be formatted.
 java.text.Format getFormat(int dimension)
          Returns the format to use for formatting an ordinate at the given dimension.
 java.lang.String getSeparator()
          Returns the separator between each coordinate (number, angle or date).
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition position)
          Not yet implemented.
 void setAnglePattern(java.lang.String pattern)
          Set the pattern for angles fields.
 void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Set the coordinate reference system for points to be formatted.
 void setDatePattern(java.lang.String pattern)
          Set the pattern for dates fields.
 void setNumberPattern(java.lang.String pattern)
          Set the pattern for numbers fields.
 void setSeparator(java.lang.String separator)
          Set the separator between each coordinate.
 void setTimeZone(java.util.TimeZone timezone)
          Set the time zone for dates fields.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinateFormat

public CoordinateFormat()
Constructs a new coordinate format with default locale and a two-dimensional geographic (WGS 1984) coordinate reference system.


CoordinateFormat

public CoordinateFormat(java.util.Locale locale)
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

public CoordinateFormat(java.util.Locale locale,
                        org.opengis.referencing.crs.CoordinateReferenceSystem crs)
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 Detail

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the coordinate reference system for points to be formatted.

Returns:
The output coordinate reference system.

setCoordinateReferenceSystem

public void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
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

public java.lang.String getSeparator()
Returns the separator between each coordinate (number, angle or date).

Since:
2.2

setSeparator

public void setSeparator(java.lang.String separator)
Set the separator between each coordinate.

Since:
2.2

setNumberPattern

public void setNumberPattern(java.lang.String pattern)
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 in DecimalFormat.

setAnglePattern

public void setAnglePattern(java.lang.String pattern)
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 in AngleFormat.

setDatePattern

public void setDatePattern(java.lang.String pattern)
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 in SimpleDateFormat.

setTimeZone

public void setTimeZone(java.util.TimeZone timezone)
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

public java.text.Format getFormat(int dimension)
                           throws java.lang.IndexOutOfBoundsException
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 returned Format object will change the formatting for this object.

Parameters:
dimension - The dimension for the ordinate to format.
Returns:
The format for the given dimension.
Throws:
java.lang.IndexOutOfBoundsException - if is out of range.

format

public java.lang.String format(org.opengis.spatialschema.geometry.DirectPosition point)
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:
java.lang.IllegalArgumentException - if this cannot format the given object.

format

public java.lang.StringBuffer format(org.opengis.spatialschema.geometry.DirectPosition point,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition position)
                              throws java.lang.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 - A identifying a field in the formatted text, or if none.
Returns:
The string buffer passed in as , with formatted text appended.
Throws:
java.lang.IllegalArgumentException - if this cannot format the given object.

format

public java.lang.StringBuffer format(java.lang.Object object,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition position)
                              throws java.lang.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:
object - The DirectPosition to format.
toAppendTo - Where the text is to be appended.
position - A identifying a field in the formatted text, or if none.
Returns:
The string buffer passed in as , with formatted text appended.
Throws:
java.lang.NullPointerException - if is null.
java.lang.IllegalArgumentException - if this cannot format the given object.

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition position)
Not yet implemented.



Copyright © GeoTools. All Rights Reserved.