java.lang.Object
io.jenetics.jpx.format.LocationFormatter
Formatter for printing and parsing geographic location objects.
Patterns for Formatting and Parsing
Patterns are based on a simple sequence of letters and symbols. A pattern is
used to create a Formatter using the #ofPattern(String) and
#ofPattern(String, Locale) methods.
For example, D°MM'SS.SSS"X will format to 60°15'59.613"N.
A formatter created from a pattern can be used as many times as necessary, it
is immutable and is thread-safe.
| Symbol | Meaning | Examples |
|---|---|---|
| L | deprecated synonym for 'D' | |
| D | Latitude in degrees. Values in -90 <= d <= +90. See examples. |
34; 23.2332 |
| M | Latitude minutes. Values in 0 <= m < 60. See examples. |
45; 45.6 |
| S | Latitude seconds. Values in 0 <= s < 60. See examples. |
7; 07 |
| X | hemisphere (N or S) | N; S |
| l | deprecated synonym for 'd' | |
| d | Longitude degrees. Values in -180 <= d <= +180. Similar to Latitude degrees. |
34; 23.2332 |
| m | Longitude minutes. Similar to latitude minutes. | 45; 45.6 |
| s | Longitude seconds. Similar to Latitude seconds. | 7; 07 |
| x | hemisphere (E or W) | E; W |
| E | Elevation in meters. See examples. | 234; 1023; -12 |
| H | deprecated synonym for 'E' | |
| ' | escape for text | |
| '' | single quote | ' |
| [ | optional section start | |
| ] | optional section end |
| Pattern | Meaning | Examples |
|---|---|---|
| +D | Latitude sign indicated by prefix +/- | +47; -24 |
| D X | Latitude sign indicated by X | 47 N; 24 S |
| D.DD | Latitude degrees with decimal faction | 47.50 |
| D M | Latitude in degrees and minutes | 47 30 |
| D | Latitude degrees in variable width | 9; 47 |
| DD | Latitude degrees in fixed width | 09; 47 |
| D M.MM | Latitude minutes with decimal fraction | 47 2.25 |
| D M S | Latitude minutes and seconds | 47 2 15 |
| D M | Latitude minutes in variable width | 47 2; 46 12 |
| D MM | Latitude minutes in fixed width | 47 02; 46 12 |
| D M S | Latitude seconds in variable width | 47 2 3; 46 2 13 |
| D M SS | Latitude seconds in fixed width | 47 2 03; 46 2 13 |
| D M S.SS | Latitude seconds with decimal fraction | 46 2 13.54 |
| +d | Longitude sign indicated by prefix +/- | +147; -124 |
| d x | Latitude sign indicated by x | 147 E; 124 W |
| d | Longitude degrees in variable width | 9; 47; 175 |
| ddd | Longitude degrees in fixed width | 009; 047; 175 |
| d m.mm | Longitude minutes with decimal fraction | 47 2.25 |
| d m s | Longitude minutes and seconds | 47 2 15 |
| d m | Longitude minutes in variable width | 47 2; 46 12 |
| d mm | Longitude minutes in fixed width | 47 02; 46 12 |
| d m s | Longitude seconds in variable width | 47 2 3; 46 2 13 |
| d m ss | Longitude seconds in fixed width | 47 2 03; 46 2 13 |
| d m s.ss | Longitude seconds with decimal fraction | 46 2 13.54 |
| E | Elevation without positive sign | 9; -9 |
| +E | Elevation with positive or negative sign | +9; -9 |
| E | Elevation in variable width | 9; 19; 190 |
| EEE | Elevation in fixed width | 009; 019; 190 |
| E.EEE | Elevation with decimal fraction | 9.123 |
- Since:
- 1.4
- Version:
- 2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocationFormatterISO 6709 conform elevation format, long:+E.EE'CRS'.static final LocationFormatterISO 6709 conform elevation format, medium:+E.E'CRS'.static final LocationFormatterISO 6709 conform elevation format, short:+E'CRS'.static final LocationFormatterElevation formatter with the patternE.EE'm'.static final LocationFormatterLatitude formatter with the patternD°MM''SS.SSS"X.static final LocationFormatterLongitude formatter with the patternd°mm''ss.sss"x.static final LocationFormatterElevation formatter with the patternD°MM''SS.SSS"X d°mm''ss.sss"x[ E.EE'm'].static final LocationFormatterISO 6709 conform latitude format, long:+DDMMSS.SS.static final LocationFormatterISO 6709 conform latitude format, medium:+DDMM.MMM.static final LocationFormatterISO 6709 conform latitude format, short:+DD.DD.static final LocationFormatterISO 6709 conform longitude format, long:+dddmmss.ss.static final LocationFormatterISO 6709 conform longitude format, medium:+dddmm.mmm.static final LocationFormatterISO 6709 conform longitude format, short:+ddd.dd.static final LocationFormatterISO 6709 conform location format, medium:+DDMMSS.SS+dddmmss.ss[+E.EE'CRS'].static final LocationFormatterISO 6709 conform location format, medium:+DDMM.MMM+dddmm.mmm[+E.E'CRS'].static final LocationFormatterISO 6709 conform location format, short:+DD.DD+ddd.dd[+E'CRS']. -
Method Summary
Modifier and TypeMethodDescriptionFormats the givenlocationusingthisformatter.Formats the given location elements usingthisformatter.Formats the given location elements usingthisformatter.Formats the given location elements usingthisformatter.Formats the given location elements usingthisformatter.Formats the given location elements usingthisformatter.static LocationFormatterCreates a formatter using the specified pattern.parse(CharSequence text) Fully parses the text producing a location.parse(CharSequence text, ParsePosition pos) Parses the text using this formatter, providing control over the text position.Return the pattern string represented by this formatter.toString()
-
Field Details
-
ISO_HUMAN_LAT_LONG
Latitude formatter with the patternD°MM''SS.SSS"X. Example:16°27'59.180"N. -
ISO_HUMAN_LON_LONG
Longitude formatter with the patternd°mm''ss.sss"x. Example:16°27'59.180"E. -
ISO_HUMAN_ELE_LONG
Elevation formatter with the patternE.EE'm'. Example:2045m. -
ISO_HUMAN_LONG
Elevation formatter with the patternD°MM''SS.SSS"X d°mm''ss.sss"x[ E.EE'm']. Example:50°03′46.461″S 125°48′26.533″E 978.90m. -
ISO_LAT_SHORT
ISO 6709 conform latitude format, short:+DD.DD. -
ISO_LAT_MEDIUM
ISO 6709 conform latitude format, medium:+DDMM.MMM. -
ISO_LAT_LONG
ISO 6709 conform latitude format, long:+DDMMSS.SS. -
ISO_LON_SHORT
ISO 6709 conform longitude format, short:+ddd.dd. -
ISO_LON_MEDIUM
ISO 6709 conform longitude format, medium:+dddmm.mmm. -
ISO_LON_LONG
ISO 6709 conform longitude format, long:+dddmmss.ss. -
ISO_ELE_SHORT
ISO 6709 conform elevation format, short:+E'CRS'. -
ISO_ELE_MEDIUM
ISO 6709 conform elevation format, medium:+E.E'CRS'. -
ISO_ELE_LONG
ISO 6709 conform elevation format, long:+E.EE'CRS'. -
ISO_SHORT
ISO 6709 conform location format, short:+DD.DD+ddd.dd[+E'CRS']. -
ISO_MEDIUM
ISO 6709 conform location format, medium:+DDMM.MMM+dddmm.mmm[+E.E'CRS']. -
ISO_LONG
ISO 6709 conform location format, medium:+DDMMSS.SS+dddmmss.ss[+E.EE'CRS'].
-
-
Method Details
-
format
Formats the givenlocationusingthisformatter.- Parameters:
location- the location to format- Returns:
- the format string
- Throws:
NullPointerException- if the givenlocationisnullFormatterException- if the formatter tries to format a non-existing, non-optional location fields.
-
toPattern
Return the pattern string represented by this formatter.- Returns:
- the pattern string of
thisformatter - See Also:
-
format
Formats the given location elements usingthisformatter.- Parameters:
lat- the latitude part of the locationlon- the longitude part of the locationele- the elevation part of the location- Returns:
- the format string
- Throws:
FormatterException- if the formatter tries to format a non-existing, non-optional location fields.- See Also:
-
format
Formats the given location elements usingthisformatter.- Parameters:
lat- the latitude part of the locationlon- the longitude part of the location- Returns:
- the format string
- Throws:
FormatterException- if the formatter tries to format a non-existing, non-optional location fields.- See Also:
-
format
Formats the given location elements usingthisformatter.- Parameters:
lat- the latitude part of the location- Returns:
- the format string
- Throws:
FormatterException- if the formatter tries to format a non-existing, non-optional location fields.- See Also:
-
format
Formats the given location elements usingthisformatter.- Parameters:
lon- the longitude part of the location- Returns:
- the format string
- Throws:
FormatterException- if the formatter tries to format a non-existing, non-optional location fields.- See Also:
-
format
Formats the given location elements usingthisformatter.- Parameters:
ele- the elevation part of the location- Returns:
- the format string
- Throws:
FormatterException- if the formatter tries to format a non-existing, non-optional location field.- See Also:
-
parse
Parses the text using this formatter, providing control over the text position. This parses the text without requiring the parse to start from the beginning of the string or finish at the end. The text will be parsed from the specified start ParsePosition. The entire length of the text does not have to be parsed, theParsePositionwill be updated with the index at the end of parsing.- Parameters:
text- the text to parse, not nullpos- the position to parse from, updated with length parsed and the index of any error, not null- Returns:
- the parsed Location, not null
- Throws:
ParseException- - if unable to parse the requested resultIndexOutOfBoundsException- - if the position is invalid
-
parse
Fully parses the text producing a location. This parses the entire text producing a location. It is typically more useful to useparse(CharSequence, ParsePosition). If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.- Parameters:
text- the text to parse, not null- Returns:
- the parsed temporal object, not null
- Throws:
ParseException- if unable to parse the requested result
-
toString
-
ofPattern
Creates a formatter using the specified pattern.- Parameters:
pattern- the formatter pattern- Returns:
- the location-formatter of the given
pattern - Throws:
NullPointerException- if the givenpatternisnullIllegalArgumentException- if the givenpatternis invalid- See Also:
-