Skip To: Content | Navigation | Sidebar

Welcome to My Website

I use these pages to collect together various bits and pieces about my ham radio interests, and to share information you might need like QSL details. I also publish my logs here so that you can check if you have ‘worked’ my callsign. My US call is N3QI.

PHP code to convert Maidenhead QRA to Latitude and Longitude · 24 December 2009 by Michael Wells

I was frustrated when searching on the internet for PHP code to convert QRA locators (JO02AF) to latitude and longitude (degrees). It seems that in ham radio circles, most people prefer not to publish their source code. I don’t know why this is, as there is really no money to be made in ham radio software. :-)

Here is my solution, please feel free to use it.

<?php
	

function qra2latlong($strQRA)
{ $strQRA = strtoupper($strQRA); if (strlen($strQRA) == 4) $strQRA .= "MM"; if (!preg_match('/^[A-Z]{2}[0-9]{2}[A-Z]{2}$/',$strQRA)) return false; list($a,$b,$c,$d,$e,$f) = str_split($strQRA,1); $a = ord($a) - ord('A'); $b = ord($b) - ord('A'); $c = ord($c) - ord('0'); $d = ord($d) - ord('0'); $e = ord($e) - ord('A'); $f = ord($f) - ord('A'); $nLong = ($a*20) + ($c*2) + (($e+0.5)/12) - 180; $nLat = ($b*10) + $d + (($f+0.5)/24) - 90; $arLatLong = array($nLat,$nLong); return($arLatLong);
}
?>