mgrs

2022-04-01

Convert coordinates between Latitude/Longitude and MGRS.

Upstream URL

github.com/glv2/mgrs

Author

Guillaume Le Vaillant

License

GPL-3
README
mgrs

This is a Common Lisp library to convert coordinates between Latitude/Longitude and MGRS.

1API

In the library, latitude and longitude are represented by real numbers (degrees), positive for northern latitude and eastern longitudes, and negative for southern latitude and western longitudes.

(lat/lon->mgrs latitude longitude &optional precision) -> string

Return the MGRS locator for the given latitude and longitude. The precision (in meters) of the locator can be 1, 10, 100, 1000, 10000.

(mgrs->lat/lon locator &optional center-p) -> list

Return the latitude and longitude for the southwest corner of the given MGRS locator square, or the center of the square if center-p is not nil.

2Examples

Load the library:

> (asdf:load-system "mgrs")
...

Get the MGRS locator of Munich:

> (mgrs:lat/lon->mgrs 48.146660d0 11.60833d0)
"32UPU9401035891"

Same thing with a lower precision (100 meters):

> (mgrs:lat/lon->mgrs 48.146660d0 11.60833d0 100)
"32UPU940358"

Get back the latitude and longitude of Munich:

> (mgrs:mgrs->lat/lon "32UPU9401035891")
(48.146655723267834d0 11.60832570541976d0)

3Tests

The tests require the fiveam library.

(asdf:test-system "mgrs")

Dependencies (2)

  • fiveam
  • utm-ups

Dependents (0)

    • GitHub
    • Quicklisp