olc

2022-04-01

Convert coordinates between Latitude/Longitude and Open Location Code.

Upstream URL

github.com/glv2/olc

Author

Guillaume Le Vaillant

License

GPL-3
README
olc

This is a Common Lisp library to convert coordinates between Latitude/Longitude and Open Location Code.

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->olc latitude longitude &optional extra-precision) -> string

Return the Open Location Code for the given latitude and longitude. If extra-precision is not nil, an 11 digit code will be returned instead of a 10 digit one.

(olc->lat/lon code &optional center-p) -> list

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

2Examples

Load the library:

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

Get the Open Locator Code for the Nairobi Youth Sports Organization and Information Centre in Kibera, Nairobi:

> (olc:lat/lon->olc -1.314121 36.798829 t)
"6GCRMQPX+9G4"

Get back the latitude and longitude of the Nairobi Youth Sports Organization and Information Centre in Kibera, Nairobi:

> (olc:olc->lat/lon "6GCRMQPX+9G4" t)
(-1.3141125000000042d0 36.798828125d0)

3Tests

The tests require the fiveam library.

(asdf:test-system "olc")

Dependencies (1)

  • fiveam

Dependents (0)

    • GitHub
    • Quicklisp