## Features

This calculator parses latitude and longitude coordinates in a variety of formats and outputs a selection of widely used formats. It also provides links to the coordinates on various internet maps: Open Street Map, Google Maps, and Bing Maps.

### Try It Out

Here are a variety of global coordinates to demonstrate the cabalibities and variety of accepted input formats. Click on any of the following to see that the given input is parsed:

### How It Works

The heart of this converter is a regular expression which matches a coordinate in pretty much any format:
`(([NEWS]?)[ \t]*(-?)([0-9]{1,3})(?:[ \t\:°]+([0-9]{1,2}))?(?:[ \t\:\']+([0-9]{1,2}))?(\.[0-9]+)?[ \t°\'\"]*)([NEWS]?)`
To break that down:
• `[NEWS]?` -- The optional "north", "south", "east" and "west" symbols that are at often at the beginning or end of a coordinate
• `[ \t]*` or `[ \t\:°]+` or `[ \t\:\']+` or `[ \t°\'\"]*` -- Various whitespace and separators
• `[0-9]{1,3}` -- A one to three digit number
• `\.[0-9]+` -- A decimal point and the digits that follow it
• `()` -- Capturing group parenthesis for pulling out whatever is contained
• `(?:)` -- Non-capturing parenthesis used just for precedence and not for capturing
1. This regex is applied twice to the input, once to pull out the latitude and a second time to pull out the longitude.
2. Each coordinate is converted from its input format into decimal degrees.
1. Seconds are divided by 60 to get minutes
2. Minutes are divided by 60 to get degrees
3. Which coordinate is latitude and which is longitute is taken from their positions if not specified by cardinal directions
4. Further checks on the input are performed:
1. Degrees are within bounds (-180 to 180 for longitude, -90 to 90 for latitude)
2. One coordinate is latitude and the other longitude (not two "south" coordinates, for example)
3. The latitude coordinate is before the longitude coordinate (the two are swapped if they are in the wrong order)
5. The number of significant figures in the input are calculated so that the output can use the same accuracy as the input
6. The coordinates are outputted in various formats
1. Fractional degrees are multiplied by 60 to get minutes
2. Fractional minutes are multiplied by 60 to get seconds
3. Decimals are rounded to the same number of significant figures as were in the input
4. A formatting system is used to replace letters in a format string to easily create various formats
• `D`: Decimal degrees
• `d`: Degrees without the decimal
• `M`: Decimal minutes
• `m`: Minutes without the decimal
• `S`: Decimal seconds
• `s`: Seconds without the decimal
• `g`: A negative sign (if present)
• `N`: The cardinal direction symbol ("N", "S", "E", or "W")
So for example `"D° N"` would represent a decimal degrees format and `"gd:m:S"` would represent a degrees, minutes, seconds format.