Geo::OLC Perl module

[Update: now on CPAN]

There are multiple competing algorithms for converting latitude/longitude locations into something easier for humans to work with. Some of them are proprietary, which makes them pretty useless offline or after that company goes out of business.

Google came up with a plausible rationale for inventing their own Open Location Code rather than adopting geohash or something similar. It’s Open Source up on Github, and they supply APIs for several common languages.

But not Perl. Naturally, I had to fix that, so here’s Geo::OLC (compressed tarball). It has a full test suite, a simple command-line tool, and a CGI script that generates a dynamic labeled grid for Google Earth. I think I’ve about got it cleaned up enough to put it on CPAN.

For amusement, the sample location I use in the POD documentation, 8Q6QMG93+742, is Tenka Gyoza in Osaka, which is exactly the sort of place that you’d have trouble finding with standard addressing methods. Actually, you’d have trouble finding it with Google Maps on your phone, as my sister learned.

I tried not to go overboard with Perlisms, but the code still ended up fairly compact, largely because most of the existing APIs were written while the formatting was still in flux, so they’re more generic than necessary.

[Update: turns out someone did write one, but it never made it to CPAN: Geo::OpenLocationCode. Looks like he converted one of the other APIs instead of writing it from scratch, so he inherited the same bug in recover_nearest.]