Aura's Den



Maidenhead locator converter

I wrote a little program to convert between Maidenhead locators and GPS coordinates. There are plenty of these things out there, and, being a terminal program, it's probably not going to be too useful for you, but I figured I'd put it up anyways.

Here's the source file (C source file, 8.46 KB). It's a txt file because Neocities doesn't allow free accounts to upload a file with a .c extension, even though it's literally just plain text. Just replace the txt in the extension with c. You're smart. You can figure it out.

To build it, just run cc -o maidenhead maidenhead.c -lm. (Or, you know, whatever C compiler you wanna use.) This should work on any system that supports C99 with POSIX extensions. It's pretty basic stuff. (I mean, hell, it might even work with C89 with POSIX extensions, but fuck if I know. But it's definitely nothing fancier than C99. I never bothered to learn features in newer C standards, so I don't use them.)

To use it, you run the program with one of two sets of options. If you have a Maidenhead locator and want coordinates, run the program with -M locator, where locator is the locator you want the coordinates for. If you have coordinates and want the Maidenhead locator, run the program with -L latitude longitude, where latitude longitude are the decimal coordinates with north/east coordinates being positive numbers and south/west coordinates being negative numbers. (So, for instance, give 30° N 40° W as 30 -40). By default, it will print the Maidenhead locator to square precision. If you want more or less, add on the -p precision option, where precision is an integer between 1 and 5. (1 gives field (e.g. FN), 2 gives square (e.g. FN31), 3 gives subsquare (e.g. FN31PR), 4 gives extended squares, and 5 gives extended subsquares.) If you put in an integer less than 1, it'll give an error. If you put in an integer more than 5, it'll work, but will still only give extended subsquare precision. This option does nothing if you're trying to convert from Maidenhead to coordinates.

A couple of notes and disclaimers:

I was going to put this under the Clumsy Wolf Public License, but that seems overkill for this stupid, silly little thing, so, uh, fuck it. 0BSD. I'd appreciate credit if you use this as a basis for something else, but, have your fun, I guess.

Zero-Clause BSD

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.