diff --git a/application/libraries/Qra.php b/application/libraries/Qra.php index 01578128..2da16a6b 100644 --- a/application/libraries/Qra.php +++ b/application/libraries/Qra.php @@ -2,14 +2,26 @@ class Qra { - // Name: QRA + /* + * Class Description: QRA handles manipulation of the Gridsquares used within amateur radio + * + * Units of measurement are the following + * + * Info: Distance Function + * + * M = Miles + * K = Kilometers + * N = Nautical Miles + */ + + // Name: qra2latlong // Task: convert qra to lat/long - function qra2latlong($strQRA) { return qra2latlong($strQRA); } + // calculate the bearing between two squares function bearing($tx, $rx, $unit = 'M') { $my = qra2latlong($tx); $stn = qra2latlong($rx); @@ -18,16 +30,27 @@ class Qra { return $bearing; } + + /* + * Function: calculate the distance between two gridsqaures + * + * Inputs are QRA's TX and TX and the unit + * + */ + function distance($tx, $rx, $unit = 'M') { + // Calc LatLongs + $my = qra2latlong($tx); + $stn = qra2latlong($rx); + + // Feed in Lat Longs plus the unit type + $total_distance = distance($my[0], $my[1], $stn[0], $stn[1], $unit); + + // Return the distance + return $total_distance; + } } -/* - Info: Distance Function - - M = Miles - K = Kilometers - N = Nautical Miles -*/ function distance($lat1, $lon1, $lat2, $lon2, $unit = 'M') { $theta = $lon1 - $lon2; diff --git a/application/views/view_log/qso.php b/application/views/view_log/qso.php index 32f1c441..47a6a831 100644 --- a/application/views/view_log/qso.php +++ b/application/views/view_log/qso.php @@ -67,6 +67,34 @@ + COL_GRIDSQUARE != null) { ?> + + + Total Distance + + load->library('qra'); + + // Cacluate Distance + echo $CI->qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, 'M'); + switch ($this->config->item('measurement_base')) { + case 'M': + echo "mi"; + break; + case 'K': + echo "km"; + break; + case 'N': + echo "nmi"; + break; + } + ?> + + + + COL_VUCC_GRIDS != null) { ?> Gridsquare (Multi):