[Distance plotting] This now follows chosen distance measurement. MAP file added for broken highstock.js.
这个提交包含在:
父节点
a0fe49e04b
当前提交
3e59cd3651
共有 4 个文件被更改,包括 44 次插入 和 11 次删除
|
|
@ -41,8 +41,15 @@ class Distances extends CI_Controller {
|
||||||
//load model
|
//load model
|
||||||
$this->load->model('Distances_model');
|
$this->load->model('Distances_model');
|
||||||
|
|
||||||
|
if ($this->session->userdata('user_measurement_base') == NULL) {
|
||||||
|
$measurement_base = $this->config->item('measurement_base');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$measurement_base = $this->session->userdata('user_measurement_base');
|
||||||
|
}
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
$data = $this->Distances_model->get_distances($postData);
|
$data = $this->Distances_model->get_distances($postData, $measurement_base);
|
||||||
|
|
||||||
return json_encode($data);
|
return json_encode($data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class Distances_model extends CI_Model
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_distances($postdata)
|
function get_distances($postdata, $measurement_base)
|
||||||
{
|
{
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
$CI->load->model('Stations');
|
$CI->load->model('Stations');
|
||||||
|
|
@ -29,17 +29,32 @@ class Distances_model extends CI_Model
|
||||||
}
|
}
|
||||||
$this->db->where('station_id', $station_id);
|
$this->db->where('station_id', $station_id);
|
||||||
$dataarrayata = $this->db->get($this->config->item('table_name'));
|
$dataarrayata = $this->db->get($this->config->item('table_name'));
|
||||||
$this->plot($dataarrayata->result_array(), $gridsquare);
|
$this->plot($dataarrayata->result_array(), $gridsquare, $measurement_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This functions takes query result from the database and extracts grids from the qso,
|
// This functions takes query result from the database and extracts grids from the qso,
|
||||||
// then calculates distance between homelocator and locator given in qso.
|
// then calculates distance between homelocator and locator given in qso.
|
||||||
// It builds an array, which has 50km intervals, then inputs each length into the correct spot
|
// It builds an array, which has 50km intervals, then inputs each length into the correct spot
|
||||||
// The function returns a json-encoded array.
|
// The function returns a json-encoded array.
|
||||||
function plot($qsoArray, $gridsquare) {
|
function plot($qsoArray, $gridsquare, $measurement_base) {
|
||||||
$stationgrid = strtoupper($gridsquare[0]); // We use only the first entered gridsquare from the active profile
|
$stationgrid = strtoupper($gridsquare[0]); // We use only the first entered gridsquare from the active profile
|
||||||
if (strlen($stationgrid) == 4) $stationgrid .= 'MM'; // adding center of grid if only 4 digits are specified
|
if (strlen($stationgrid) == 4) $stationgrid .= 'MM'; // adding center of grid if only 4 digits are specified
|
||||||
|
|
||||||
|
switch ($measurement_base) {
|
||||||
|
case 'M':
|
||||||
|
$unit = "mi";
|
||||||
|
$dist = '13000';
|
||||||
|
break;
|
||||||
|
case 'K':
|
||||||
|
$unit = "km";
|
||||||
|
$dist = '20000';
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
$unit = "nmi";
|
||||||
|
$dist = '11000';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->valid_locator($stationgrid)) {
|
if (!$this->valid_locator($stationgrid)) {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(array('Error' => 'Error. There is a problem with the gridsquare set in your profile!'));
|
echo json_encode(array('Error' => 'Error. There is a problem with the gridsquare set in your profile!'));
|
||||||
|
|
@ -47,8 +62,8 @@ class Distances_model extends CI_Model
|
||||||
else {
|
else {
|
||||||
// Making the array we will use for plotting, we save occurrences of the length of each qso in the array
|
// Making the array we will use for plotting, we save occurrences of the length of each qso in the array
|
||||||
$j = 0;
|
$j = 0;
|
||||||
for ($i = 0; $j < 20000; $i++) {
|
for ($i = 0; $j < $dist; $i++) {
|
||||||
$dataarray[$i]['dist'] = $j . 'km - ' . ($j + 50) . 'km';
|
$dataarray[$i]['dist'] = $j . $unit . ' - ' . ($j + 50) . $unit;
|
||||||
$dataarray[$i]['count'] = 0;
|
$dataarray[$i]['count'] = 0;
|
||||||
$dataarray[$i]['calls'] = '';
|
$dataarray[$i]['calls'] = '';
|
||||||
$dataarray[$i]['callcount'] = 0;
|
$dataarray[$i]['callcount'] = 0;
|
||||||
|
|
@ -65,7 +80,7 @@ class Distances_model extends CI_Model
|
||||||
|
|
||||||
foreach ($qsoArray as $qso) {
|
foreach ($qsoArray as $qso) {
|
||||||
$qrb['Qsoes']++; // Counts up number of qsoes
|
$qrb['Qsoes']++; // Counts up number of qsoes
|
||||||
$bearingdistance = $this->bearing_dist($stationgrid, $qso['grid']); // Calculates distance based on grids
|
$bearingdistance = $this->bearing_dist($stationgrid, $qso['grid'], $measurement_base); // Calculates distance based on grids
|
||||||
$arrayplacement = $bearingdistance / 50; // Resolution is 50, calculates where to put result in array
|
$arrayplacement = $bearingdistance / 50; // Resolution is 50, calculates where to put result in array
|
||||||
if ($bearingdistance > $qrb['Distance']) { // Saves the longest QSO
|
if ($bearingdistance > $qrb['Distance']) { // Saves the longest QSO
|
||||||
$qrb['Distance'] = $bearingdistance;
|
$qrb['Distance'] = $bearingdistance;
|
||||||
|
|
@ -87,6 +102,7 @@ class Distances_model extends CI_Model
|
||||||
$data['ok'] = 'OK';
|
$data['ok'] = 'OK';
|
||||||
$data['qrb'] = $qrb;
|
$data['qrb'] = $qrb;
|
||||||
$data['qsodata'] = $dataarray;
|
$data['qsodata'] = $dataarray;
|
||||||
|
$data['unit'] = $unit;
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -137,7 +153,7 @@ class Distances_model extends CI_Model
|
||||||
return (M_PI * $deg/180);
|
return (M_PI * $deg/180);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bearing_dist($loc1, $loc2) {
|
function bearing_dist($loc1, $loc2, $measurement_base) {
|
||||||
$loc1 = strtoupper($loc1);
|
$loc1 = strtoupper($loc1);
|
||||||
$loc2 = strtoupper($loc2);
|
$loc2 = strtoupper($loc2);
|
||||||
|
|
||||||
|
|
@ -154,6 +170,15 @@ class Distances_model extends CI_Model
|
||||||
$co = cos($l1[1] - $l2[1]) * cos($l1[0]) * cos($l2[0]) + sin($l1[0]) * sin($l2[0]);
|
$co = cos($l1[1] - $l2[1]) * cos($l1[0]) * cos($l2[0]) + sin($l1[0]) * sin($l2[0]);
|
||||||
$ca = atan2(sqrt(1 - $co*$co), $co);
|
$ca = atan2(sqrt(1 - $co*$co), $co);
|
||||||
|
|
||||||
return round(6371*$ca);
|
|
||||||
|
|
||||||
|
switch ($measurement_base) {
|
||||||
|
case 'M':
|
||||||
|
return round(6371*$ca/1.609344);
|
||||||
|
case 'K':
|
||||||
|
return round(6371*$ca);
|
||||||
|
case 'N':
|
||||||
|
return round(6371*$ca/1.852);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1292,7 +1292,7 @@ $(document).ready(function(){
|
||||||
xAxis: {
|
xAxis: {
|
||||||
labels: {
|
labels: {
|
||||||
formatter: function() {
|
formatter: function() {
|
||||||
return this.value * '50' + ' km';
|
return this.value * '50' + ' ' + tmp.unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1331,7 +1331,7 @@ $(document).ready(function(){
|
||||||
$('#information').html(tmp.qrb.Qsoes + " contacts were plotted.<br /> Your furthest contact was with " + tmp.qrb.Callsign
|
$('#information').html(tmp.qrb.Qsoes + " contacts were plotted.<br /> Your furthest contact was with " + tmp.qrb.Callsign
|
||||||
+ " in gridsquare "+ tmp.qrb.Grid
|
+ " in gridsquare "+ tmp.qrb.Grid
|
||||||
+" the distance was "
|
+" the distance was "
|
||||||
+tmp.qrb.Distance +"km.");
|
+tmp.qrb.Distance + tmp.unit +".");
|
||||||
|
|
||||||
var chart = new Highcharts.Chart(options);
|
var chart = new Highcharts.Chart(options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
assets/js/highstock.js.map
普通文件
1
assets/js/highstock.js.map
普通文件
文件差异因一行或多行过长而隐藏
正在加载…
在新工单中引用