Package com.luciad.util
Class TLcdLonLatFormatter
java.lang.Object
com.luciad.util.TLcdLonLatFormatter
- All Implemented Interfaces:
ILcdCloneable,ILcdLonLatFormatter,Serializable,Cloneable
public class TLcdLonLatFormatter
extends Object
implements Serializable, ILcdCloneable, ILcdLonLatFormatter
This class provides various methods for formatting longitude/latitude coordinate
pairs as String objects. The pattern property determines the format.
The following patterns are provided:
- dd°mm'ss",ddd°mm'ss"
- dd°mm'ss.s",ddd°mm's.ss"
- dd°mm'ss.ss",ddd°mm'ss.ss"
- ddmmssNdddmmssE
- ddmmss.ssssNdddmmss.ssssE
- dddmmssEddmmssN
- xx°,xxx°
- xx.x°,xxx.x°
- xx.xx°,xxx.xx°
- xx.xxx°,xxx.xxx°
- xx.xxxx°,xxx.xxxx°
- xx.xxxxx°,xxx.xxxxx°
- xx.xxxxxx°,xxx.xxxxxx°
- xx°xx',xxx°xx'
- xx°xx.x',xxx°xx.x'
- xx°xx.xx',xxx°xx.xx'
- x°,x°
- x.x°,x.x°
- x.xx°,x.xx°
- x',x'
- x.x',x.x'
- x.xx',x.xx'
- x",x"
- x.x",x.x"
- x.xx",x.xx"
They can be specified using the constant pattern String objects of this class.
If you want to format your coordinates with a pattern other than the patterns listed above, you can use TLcdLonLatPointFormat instead.
That class also comes in handy if you want to use the coordinates in Swing text fields, for example.
The decimal separator may change depending on the locale.
The longitude/latitude separator may be changed with the method
setLonLatSeparatorChar(char).
This class is not thread safe, but an instance of this class can be shared by separate threads at the same time as long as the pattern and the separator character are not being modified in the process.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDecimal degrees pattern 0: xx°,xxx° .static final StringDecimal degrees pattern 1: xx.x°,xxx.x° .static final StringDecimal degrees pattern 2: xx.xx°,xxx.xx° .static final StringDecimal degrees pattern 3: xx.xxx°,xxx.xxx° .static final StringDecimal degrees pattern 4: xx.xxxx°,xxx.xxxx° .static final StringDecimal degrees pattern 5: xx.xxxxx°,xxx.xxxxx° .static final StringDecimal degrees pattern 6: xx.xxxxxx°,xxx.xxxxxx° .static final StringDecimal minutes pattern 0: xx°xx',xxx°xx' .static final StringDecimal minutes pattern 1: xx°xx.x',xxx°xx.x' .static final StringDecimal minutes pattern 2: xx°xx.xx',xxx°xx.xx' .static final StringDefault pattern: dd°mm'ss",ddd°mm'ss" .static final StringDefault pattern 1: dd°mm'ss.s",ddd°mm'ss.s" .static final StringDefault pattern 2: dd°mm'ss.ss",ddd°mm'ss.ss" .static final StringNSWE pattern: ddmmssNdddmmssE .static final StringNSWE pattern 2: ddmmss.ssssNdddmmss.ssssE .static final StringShort decimal degrees pattern 0: x°,x° .static final StringShort decimal degrees pattern 1: x.x°,x.x° .static final StringShort decimal degrees pattern 2: x.xx°,x.xx° .static final StringShort decimal minutes pattern 0: x',x' .static final StringShort decimal minutes pattern 1: x.x',x.x' .static final StringShort decimal minutes pattern 2: x.xx',x.xx' .static final StringShort decimal seconds pattern 0: x",x" .static final StringShort decimal seconds pattern 1: x.x",x.x" .static final StringShort decimal seconds pattern 2: x.xx",x.xx" .static final StringWENS pattern: dddmmssEddmmssN . -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TLcdLonLatFormatter that will use theDEFAULTpattern, for example 30°32'45",-123°45'15".TLcdLonLatFormatter(String aPattern) Creates a new TLcdLonLatFormatter that will use the specified pattern. -
Method Summary
Modifier and TypeMethodDescriptionclone()MakesObject.clone()public.format(double aLon, double aLat) Formats the given longitude/latitude coordinate pair as a String, following the current pattern.formatLat(double aLat) Formats the given latitude coordinate as a String, following the current pattern.formatLon(double aLon) Formats the given longitude coordinate pair as a String, following the current pattern.static charstatic voidsetLonLatSeparatorChar(char aLonLatSeparatorChar) Sets the character to separate longitudes and latitudes.voidsetPattern(String aPattern) Sets the pattern following which Strings will be formatted.
-
Field Details
-
DEFAULT
Default pattern: dd°mm'ss",ddd°mm'ss" .- See Also:
-
DEFAULT1
Default pattern 1: dd°mm'ss.s",ddd°mm'ss.s" .- See Also:
-
DEFAULT2
Default pattern 2: dd°mm'ss.ss",ddd°mm'ss.ss" .- See Also:
-
NSWE
NSWE pattern: ddmmssNdddmmssE .- See Also:
-
NSWE2
NSWE pattern 2: ddmmss.ssssNdddmmss.ssssE .- See Also:
-
WENS
WENS pattern: dddmmssEddmmssN .- See Also:
-
DEC_DEG_0
Decimal degrees pattern 0: xx°,xxx° .- See Also:
-
DEC_DEG_1
Decimal degrees pattern 1: xx.x°,xxx.x° .- See Also:
-
DEC_DEG_2
Decimal degrees pattern 2: xx.xx°,xxx.xx° .- See Also:
-
DEC_DEG_3
Decimal degrees pattern 3: xx.xxx°,xxx.xxx° .- See Also:
-
DEC_DEG_4
Decimal degrees pattern 4: xx.xxxx°,xxx.xxxx° .- See Also:
-
DEC_DEG_5
Decimal degrees pattern 5: xx.xxxxx°,xxx.xxxxx° .- See Also:
-
DEC_DEG_6
Decimal degrees pattern 6: xx.xxxxxx°,xxx.xxxxxx° .- See Also:
-
DEC_MIN_0
Decimal minutes pattern 0: xx°xx',xxx°xx' .- See Also:
-
DEC_MIN_1
Decimal minutes pattern 1: xx°xx.x',xxx°xx.x' .- See Also:
-
DEC_MIN_2
Decimal minutes pattern 2: xx°xx.xx',xxx°xx.xx' .- See Also:
-
SHORT_DEC_DEG_0
Short decimal degrees pattern 0: x°,x° .- See Also:
-
SHORT_DEC_DEG_1
Short decimal degrees pattern 1: x.x°,x.x° .- See Also:
-
SHORT_DEC_DEG_2
Short decimal degrees pattern 2: x.xx°,x.xx° .- See Also:
-
SHORT_DEC_MIN_0
Short decimal minutes pattern 0: x',x' .- See Also:
-
SHORT_DEC_MIN_1
Short decimal minutes pattern 1: x.x',x.x' .- See Also:
-
SHORT_DEC_MIN_2
Short decimal minutes pattern 2: x.xx',x.xx' .- See Also:
-
SHORT_DEC_SEC_0
Short decimal seconds pattern 0: x",x" .- See Also:
-
SHORT_DEC_SEC_1
Short decimal seconds pattern 1: x.x",x.x" .- See Also:
-
SHORT_DEC_SEC_2
Short decimal seconds pattern 2: x.xx",x.xx" .- See Also:
-
-
Constructor Details
-
TLcdLonLatFormatter
public TLcdLonLatFormatter()Creates a new TLcdLonLatFormatter that will use theDEFAULTpattern, for example 30°32'45",-123°45'15". -
TLcdLonLatFormatter
Creates a new TLcdLonLatFormatter that will use the specified pattern.- Parameters:
aPattern- one of the pattern String constants defined in this class.
-
-
Method Details
-
setLonLatSeparatorChar
public static void setLonLatSeparatorChar(char aLonLatSeparatorChar) Sets the character to separate longitudes and latitudes. This character is used in the methodformat(double, double).- Parameters:
aLonLatSeparatorChar-
-
getLonLatSeparator
public static char getLonLatSeparator() -
setPattern
Sets the pattern following which Strings will be formatted.- Parameters:
aPattern- one of the pattern String constants defined in this class.
-
getPattern
-
format
Formats the given longitude/latitude coordinate pair as a String, following the current pattern.- Specified by:
formatin interfaceILcdLonLatFormatter- Parameters:
aLon- the longitude, expressed in degrees.aLat- the latitude, expressed in degrees.- Returns:
- the formatted String.
-
formatLat
Formats the given latitude coordinate as a String, following the current pattern.- Specified by:
formatLatin interfaceILcdLonLatFormatter- Parameters:
aLat- the latitude, expressed in degrees.- Returns:
- the formatted String.
-
formatLon
Formats the given longitude coordinate pair as a String, following the current pattern.- Specified by:
formatLonin interfaceILcdLonLatFormatter- Parameters:
aLon- the longitude, expressed in degrees.- Returns:
- the formatted String.
-
clone
Description copied from interface:ILcdCloneableMakes
When for example extending fromObject.clone()public.java.lang.Object, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }- Specified by:
clonein interfaceILcdCloneable- Overrides:
clonein classObject- See Also:
-