Sunday, January 18, 2009

How to recognize a call sign

In the course of my work of validating K5EHX's repeater database, and more generally in building a union repeater database for my repeater footprint project, I've been wanting a way to validate whether a given string is a valid call sign.  It was relatively easy to figure out what a valid US call sign is; the FCC has pretty well-defined standards and it's easy enough to write a regexp that matches all valid US ham call signs, especially if you're willing to ignore the X series that's reserved for experimental stations and don't care to differentiate the outlying areas from the lower 48.  Expanding this to the rest of the world, though, is a bit harder.  I had been using the cty.dat file from the Contest Country File collection, but that database is overly complex for what I want to do as it breaks out down to the island level and has all sorts of additional complexity that I'm sure is useful to contesters, but not so much to me.

Last night, however, I finally came across the ITU specifications for a call sign; the specification is set forth in Section 30 and is actually pretty simple: either one of the letters B, F, G, I, K, M, N, R, or W, or any two characters, followed by a digit and one to four additional characters, the last of which must be a letter.  What could be simpler?

The one thing this doesn't offer is any way to tell what country or authority a given callsign is from.  Well, the ITU has that information too, in Appendix 42, the Table of Allocation of International Call Sign Series.  This table is slightly nonintuitive, because it shows three-letter codes; for ham purposes only the first two are used, or the first only if the first character is one of the nine above plus the digit 2.  An enterprising individual should be able to figure out how to determine the nationality of a callsign using only this table relatively easily.

I'll be adding this to my validation routines for database imports for the footprint project soon; I'm in the process right now of modifying the validator for the K5EHX import to be more reusable so I can (eventually) import data from other sources as well, and once I finish that I'll start adding more validation checks.