Decimal-degree strings use five decimal places: approximately 1.1 metres
in latitude and at most 1.1 metres in longitude. Inverse coordinates reflect
the MGRS cell centers returned by GEOTRANS 3.10.

>>> import mgrs
>>> latitude = 42.0
>>> longitude = -93.0

>>> m = mgrs.MGRS()
>>> c = m.toMGRS(latitude, longitude)
>>> print(c)
15TWG0000049776

>>> lat, lon = m.toLatLon(c)
>>> '%.5f' % lat
'42.00000'

>>> '%.5f' % lon
'-92.99999'

>>> yp = '321942N'
>>> yd = m.dmstodd(yp)
>>> '%.5f' % yd
'32.32833'


>>> y = '321942.29N'
>>> yd = m.dmstodd(y)
>>> '%.5f' % yd
'32.32841'


>>> x = '671328.35W'
>>> yd = m.dmstodd(x)
>>> '%.5f' % yd
'-67.22454'

>>> y = '321942.29S'
>>> yd = m.dmstodd(y)
>>> '%.5f' % yd
'-32.32841'

For DMS output, two decimal places in arcseconds resolve about 0.3 metres.

>>> d, m, s = m.ddtodms(32.328414)
>>> (d, m, '%.2f' % s)
(32.0, 19.0, '42.29')

>>> m = mgrs.MGRS()
>>> washingtondc = (38.9072, -77.0369)
>>> c = m.toMGRS(*washingtondc)
>>> str(c)
'18SUJ2338308450'

>>> philadelphia = (39.9526, -75.1652)
>>> c = m.toMGRS(*philadelphia)
>>> str(c)
'18SVK8588822509'

>>> convert = mgrs.MGRS()
>>> coords = u"15SWC8081751205"

>>> lat, lon = convert.toLatLon(coords)
>>> '%.5f' % lat
'38.40543'

>>> '%.5f' % lon
'-92.07439'

UTM coordinates retain the exact half-metre offsets of a precision-5 cell
center, rather than rounding them to whole metres.

>>> convert.MGRSToUTM(coords)
(15, 'N', 580817.5, 4251205.5)

>>> convert.UTMToMGRS(15,'N',580817,4251205)
'15SWC8081751205'

>>> # These two MGRS coordinates produce a warning in libmgrs (see issue #45)
>>> import warnings
>>> convert = mgrs.MGRS()

>>> coords = "50TMK5045027900"
>>> with warnings.catch_warnings(record=True) as caught:
...     warnings.simplefilter("always")
...     v = convert.toLatLon(coords)
>>> assert len(caught) == 1
>>> assert caught[0].category is RuntimeWarning
>>> assert "Latitude Warning" in str(caught[0].message)
>>> '%.5f, %.5f' % v
'39.99984, 116.41952'

>>> coords = "32TNK0000000000"
>>> with warnings.catch_warnings(record=True) as caught:
...     warnings.simplefilter("always")
...     v = convert.toLatLon(coords)
>>> assert len(caught) == 1
>>> assert caught[0].category is RuntimeWarning
>>> assert "Latitude Warning" in str(caught[0].message)
>>> '%.5f, %.5f' % v
'39.74991, 9.00001'
