03 Why does the coordinate parser exist internally?

The coordinate parser is part of the coordinate functions. It is used with the insert function of the coordinates and with the variable coordinate tool. It has the task to interpret a meaningful coordinate (latitude and longitude) from a text.

Coordinates can be specified in most different formats. Many formats are not necessarily unique. For example, the values for SwissGrid and Gauss-Krüger look basically the same at first. They cannot be distinguished from each other so easily on the basis of a certain pattern.

There are many differences in the notation of the various coordinate formats. Let’s just take the “geocaching format” DEG. You can find it with and without prefixed N/E letters or with minus instead of S/W. With and without degrees/minutes/seconds signs, with comma or dot separator, with spaces and without, with or without leading zeros….

Here are just a few examples:

N 52° 12.312′ E 20° 12.312′
N 52° 12. 312′ E 020° 12. 312′
N 52 12.312 E 20 12.312
N52 12.312, E20 12.312
North 52 12.312, East 20 12.312
52 06.312 S 20 06.312 W
-52 12.312 -20 12.312
52 12.312 20 12.312

In order to minimize problems for the GCWizard user, the parser is designed to be very flexible. However, problems can occur from time to time. Single characters can be enough to turn a seemingly valid format into an uninterpretable text. Even if the parser tolerates a large number of typing errors, the user should still exercise great care. If the parser ever fails, it is necessary to look carefully to see which character could lead to an invalid format.

Here are some more random valid examples:

DEC

00.12312 S 000.12312 W
52.12312N, 20.12312E
52. 12312 20. 12312
52 n 20 o
92 West 0
+2.12312 -020.12312

DEG

52° 12.312′ N 20° 12.312′ E
52 06 S 20 6 W
N 051° 39.688′ E 006° 27.336′
52 12 20 12
N52 12 E20 12
-052 6 -20 06

DMS

52° 12′ 30.15″ N, 20° 12′ 30.15″ E
52 12 45 S, 20 12 45 W
North 52 6 30.15, East 20 06 30.15
52 6 9 20 6 9
N52 12 30.15, E20 12 30.15