/maidenhead

Convert coordinates between Latitude/Longitude and Maidenhead locator system

Primary LanguageCommon LispGNU General Public License v3.0GPL-3.0

maidenhead

The active repository is at https://codeberg.org/glv/maidenhead

This is a Common Lisp library to convert coordinates between Latitude/Longitude and Maidenhead locator system.

API

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->maidenhead latitude longitude) -> string

Return the Maidenhead locator for the given latitude and longitude.

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

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

Examples

Load the library:

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

Get the Maidenhead locator of Munich:

> (maidenhead:lat/lon->maidenhead 48.14666 11.60833)
"JN58td25"

Get back the latitude and longitude of Munich:

> (maidenhead:maidenhead->lat/lon "JN58td25" t)
(48.147916666666674d0 11.60416666666666d0)

Tests

The tests require the fiveam library.

(asdf:test-system "maidenhead")