Enable configuring the measurement base distance is measured in

这个提交包含在:
Kim Huebel 2019-06-24 15:57:48 +02:00
父节点 9891b44ae3
当前提交 8365b17f7c
共有 3 个文件被更改,包括 38 次插入11 次删除

查看文件

@ -16,4 +16,20 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| and on QSO-detail-view, set this to TRUE, otherwise set it to FALSE
|
*/
$config['show_time'] = FALSE;
$config['show_time'] = FALSE;
/*
|--------------------------------------------------------------------------
| Configure the measurement base distance is measured in
|--------------------------------------------------------------------------
|
| Here you can configure different measurement bases to be used on
| distance caculations. Valid values are:
| M: miles
| K: kilometers
| N: nautic miles
|
| Default is: M
|
*/
$config['measurement_base'] = 'M';

查看文件

@ -88,7 +88,7 @@ class Logbook extends CI_Controller {
$return['callsign_qth'] = $this->logbook_model->call_qth($callsign);
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['qsl_manager'] = $this->logbook_model->call_qslvia($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra']);
$return['bearing'] = $this->bearing($return['callsign_qra'], $this->config->item('measurement_base'));
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
if ($return['callsign_qra'] != "") {
@ -139,7 +139,7 @@ class Logbook extends CI_Controller {
}
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
}
$return['bearing'] = $this->bearing($return['callsign_qra']);
$return['bearing'] = $this->bearing($return['callsign_qra'], $this->config->item('measurement_base'));
echo json_encode($return, JSON_PRETTY_PRINT);
@ -383,7 +383,7 @@ class Logbook extends CI_Controller {
$mylocator = $this->config->item('locator');
}
$bearing = $this->qra->bearing($mylocator, $locator);
$bearing = $this->qra->bearing($mylocator, $locator, $this->config->item('measurement_base'));
echo $bearing;
}
@ -391,7 +391,7 @@ class Logbook extends CI_Controller {
}
/* return station bearing */
function bearing($locator) {
function bearing($locator, $unit = 'M') {
$this->load->library('Qra');
@ -404,7 +404,7 @@ class Logbook extends CI_Controller {
$bearing = $this->qra->bearing($mylocator, $locator);
$bearing = $this->qra->bearing($mylocator, $locator, $unit);
return $bearing;
}

查看文件

@ -10,11 +10,11 @@ class Qra {
return qra2latlong($strQRA);
}
function bearing($tx, $rx) {
function bearing($tx, $rx, $unit = 'M') {
$my = qra2latlong($tx);
$stn = qra2latlong($rx);
$bearing = bearing($my[0], $my[1], $stn[0], $stn[1]);
$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit);
return $bearing;
}
@ -37,7 +37,7 @@ cos(deg2rad($theta));
return round($dist, 1);
}
function bearing($lat1, $lon1, $lat2, $lon2) {
function bearing($lat1, $lon1, $lat2, $lon2, $unit = 'M') {
if (round($lon1, 1) == round($lon2, 1)) {
if ($lat1 < $lat2) {
$bearing = 0;
@ -45,7 +45,7 @@ function bearing($lat1, $lon1, $lat2, $lon2) {
$bearing = 180;
}
} else {
$dist = distance($lat1, $lon1, $lat2, $lon2, 'N');
$dist = distance($lat1, $lon1, $lat2, $lon2, $unit);
$arad = acos((sin(deg2rad($lat2)) - sin(deg2rad($lat1)) * cos(deg2rad($dist / 60))) / (sin(deg2rad($dist
/ 60)) * cos(deg2rad($lat1))));
$bearing = $arad * 180 / pi();
@ -68,7 +68,18 @@ function bearing($lat1, $lon1, $lat2, $lon2) {
$var_dist = "";
#return $dir;
if (isset($dist)) {
$var_dist = $dist." miles";
$var_dist = $dist;
switch ($unit) {
case 'M':
$var_dist .= " miles";
break;
case 'N':
$var_dist .= " nautic miles";
break;
case 'K':
$var_dist .= " kilometers";
break;
}
}
return round($bearing, 0)."&#186; ".$dir." ".$var_dist;
}