public class TLcdLonLatParser extends Object implements ILcdParser
ILcdParser
parses various string formats for
longitude/latitude ordinates. The following formats are recognized:
In these formats, 'd' and 'x' stand for a digit of the degrees, 'm' stands for a digit of the minutes, and 's' stands for a digit of the seconds. Parts of the numbers may be left out, as long as they remain unambiguous. The latitude hemisphere qualifications can be 'N' or 'S', and the longitude hemisphere qualifications can be 'E' or 'W' (all case-insensitive). If the an input strings contains just a single double, it is interpreted as degrees.
The ranges of the input strings are not validated. Input like 306075N will be converted to 31 degrees, 1 minute, and 15 seconds North.
TLcdLonLatPointFormat
Modifier and Type | Field and Description |
---|---|
static String |
DEC_DEG_1
Deprecated.
The pattern property is not used.
|
static String |
DEC_DEG_2
Deprecated.
The pattern property is not used.
|
static String |
DEC_DEG_3
Deprecated.
The pattern property is not used.
|
static String |
DEC_DEG_4
Deprecated.
The pattern property is not used.
|
static String |
DEC_DEG_5
Deprecated.
The pattern property is not used.
|
static String |
DEC_DEG_6
Deprecated.
The pattern property is not used.
|
static String |
DEFAULT
Deprecated.
The pattern property is not used.
|
static String |
DEFAULT2
Deprecated.
The pattern property is not used.
|
static int |
LATCOORD
Deprecated.
The mode property is not used.
|
static int |
LONCOORD
Deprecated.
The mode property is not used.
|
static String |
NSWE
Deprecated.
The pattern property is not used.
|
static String |
NSWE2
Deprecated.
The pattern property is not used.
|
Constructor and Description |
---|
TLcdLonLatParser()
Creates a new TLcdLonLatParser.
|
TLcdLonLatParser(int aMode)
Deprecated.
Use the constructor without parameters.
|
TLcdLonLatParser(String aPattern)
Deprecated.
Use the constructor without parameters.
|
Modifier and Type | Method and Description |
---|---|
int |
getMode()
Deprecated.
The mode property is not used. This method always returns -1.
|
double |
latddmmssAsDouble(String aString)
Parses the given String as a latitude ordinate.
|
double |
londdmmssAsDouble(String aString)
Parses the given String as a longitude ordinate.
|
double |
londdmmssAsDouble(String aString,
int aDegFieldSize)
Deprecated.
|
double |
ordinateAsDouble(String aString)
Parses the given String as a longitude or latitude ordinate.
|
Object |
parse(String aString)
Parses the given String as a longitude or latitude ordinate.
|
Object |
parse(String aString,
int aMode)
Deprecated.
Use the method
parse(String) . |
void |
setMode(int aNewMode)
Deprecated.
The mode property is not used. This method has an empty implementation.
|
void |
setPattern(String aNewPattern)
Deprecated.
The pattern property is not used.
|
public static final int LATCOORD
public static final int LONCOORD
public static final String DEFAULT
public static final String DEFAULT2
public static final String NSWE
public static final String NSWE2
public static final String DEC_DEG_1
public static final String DEC_DEG_2
public static final String DEC_DEG_3
public static final String DEC_DEG_4
public static final String DEC_DEG_5
public static final String DEC_DEG_6
public TLcdLonLatParser()
public TLcdLonLatParser(int aMode)
NSWE
and the given mode.aMode
- the mode: LONCOORD
or LATCOORD
.public TLcdLonLatParser(String aPattern)
LATCOORD
.aPattern
- the pattern.public void setPattern(String aNewPattern)
aNewPattern
- the new pattern.public void setMode(int aNewMode)
aNewMode
- the new mode: LONCOORD
or LATCOORD
.getMode()
public int getMode()
setMode(int)
public Object parse(String aString)
parse
in interface ILcdParser
aString
- the String
to be parsed.Double
,
or null
, when the String passed could not be interpreted as an ordinate.public Object parse(String aString, int aMode)
parse(String)
.parse(String)
.aMode
- not taken into account.aString
- the String
to be parsed.Double
,
or null
if the parsing failed.public double latddmmssAsDouble(String aString)
ordinateAsDouble(String)
.aString
- the String
to be parsed.NumberFormatException
- if the String is not in a longitude or
latitude format that can be parsed.public double londdmmssAsDouble(String aString)
ordinateAsDouble(String)
.aString
- the String
to be parsed.NumberFormatException
- if the String is not in a longitude or
latitude format that can be parsed.public double londdmmssAsDouble(String aString, int aDegFieldSize)
ordinateAsDouble(String)
.aString
- the String
to be parsed.aDegFieldSize
- value in [1,2,3]: 3 means the pattern is dddmmss[EW]
(e.g. 0031645E), 2 means the pattern is ddmmss[EW] (e.g. 031645E),
1 means the pattern is dmmss[EW] (e.g. 31645E).public double ordinateAsDouble(String aString) throws NumberFormatException
aString
- the String
to be parsed.NumberFormatException
- if the String is not in a longitude or
latitude format that can be parsed.