{gps:gps:format}

Description

Parses a GPS coordinate string and returns it as decimal latitude/longitude. It accepts several common notations: decimal degrees with hemisphere letters (49.9679189N, 12.5029972E), signed decimals separated by a space or comma (-50.09697 14.42332 or 41.40338, 2.17403), and degrees-minutes-seconds (49 deg 58 min 4.508 sec N, 12 deg 30 min 10.790 sec E). The hemisphere letter, if present, must follow its number, not precede it. With no format given, the result is "latitude,longitude" (or just the one value that parsed). Pass a format template to control the output: the tokens _#lat and _#lon (case-insensitive) are replaced by the latitude and longitude. The format must not contain a colon - AA reads a colon as a parameter separator, so anything after it is dropped. Input that does not match any recognised pattern yields an empty string.

Parameters

gps required

The coordinate string to parse. Accepts decimal degrees with hemisphere letters (49.9679189N, 12.5029972E), signed decimals separated by space or comma (-50.09697 14.42332 ; 41.40338, 2.17403), or degrees-minutes-seconds with N/S/E/W. A hemisphere letter must come after its number. Unrecognised input gives an empty result.

format optional default (empty) - prints latitude,longitude

Output template. Every _#lat is replaced by the latitude and every _#lon by the longitude (the tokens are case-insensitive). It must not contain a colon, which AA treats as a parameter separator. When omitted, the result is latitude,longitude (or the single value that parsed).

Examples

test{gps:49.9679189N, 12.5029972E}
Expected49.9679189,12.5029972
Actual49.9679189,12.5029972
N/S/E/W letters (after the number) set the sign and order. Northern/eastern stay positive.
test{gps:50.0902N, 14.4005E:lat=_#lat lon=_#lon}
Expectedlat=50.0902 lon=14.4005
Actuallat=50.0902 lon=14.4005
Build any string from the parsed values. The format may not contain a colon (AA would read it as a parameter separator).
test{gps:41.40338, 2.17403}
Expected41.40338,2.17403
Actual41.40338,2.17403
With no format, a plain decimal pair (comma- or space-separated) is normalised to latitude,longitude.
test{gps:41.40338, 2.17403:_#lat}
Expected41.40338
Actual41.40338
A format of just _#lat returns the latitude alone.
test{gps:-50.09697 14.42332:_#lon}
Expected14.42332
Actual14.42332
A format of just _#lon returns the longitude alone. Space-separated signed decimals are accepted.
test[{gps:N 33.8688, E 151.2093}]
Expected[]
Actual[]
A leading hemisphere letter (N before the number) is not recognised and the whole input fails to parse. Put the letter after the number (33.8688S, 151.2093E) instead.
test{gps:33.8688S, 151.2093E}
Expected-33.8688,151.2093
Actual-33.8688,151.2093
A trailing S or W makes the value negative - here 33.8688 South becomes -33.8688. (Degrees-minutes-seconds input is also accepted; see the description.)
test[{gps:not a coordinate}]
Expected[]
Actual[]
Input that matches none of the supported notations yields an empty string (shown here inside brackets).