[Distances Worked] Fixed Offset Error

这个提交包含在:
Peter Goodhall 2022-10-05 14:31:33 +01:00
父节点 327fb1f485
当前提交 2b6a2ce6c4
共有 2 个文件被更改,包括 44 次插入14 次删除

查看文件

@ -44,4 +44,25 @@ class Distances extends CI_Controller {
return json_encode($data); return json_encode($data);
} }
public function test_distance(){
// POST data
$postdata['band'] = "sat";
$postdata['sat'] = "All";
//load 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
$data = $this->Distances_model->get_distances($postdata, $measurement_base);
return json_encode($data);
}
} }

查看文件

@ -43,11 +43,13 @@ class Distances_model extends CI_Model
if ($queryresult->result_array()) { if ($queryresult->result_array()) {
$temp = $this->plot($queryresult->result_array(), $gridsquare, $measurement_base); $temp = $this->plot($queryresult->result_array(), $gridsquare, $measurement_base);
$result = $this->mergeresult($result, $temp); $result = $this->mergeresult($result, $temp);
} }
} }
} }
if ($result) { if ($result) {
@ -74,20 +76,25 @@ class Distances_model extends CI_Model
$result['qrb']['Qsos'] += $add['qrb']['Qsos']; $result['qrb']['Qsos'] += $add['qrb']['Qsos'];
for ($i = 0; $i <= 399; $i++) { for ($i = 0; $i <= 399; $i++) {
$result['qsodata'][$i]['count'] += $add['qsodata'][$i]['count'];
if(isset($result['qsodata'][$i]['count'])) {
$result['qsodata'][$i]['count'] += $add['qsodata'][$i]['count'];
}
if ($result['qsodata'][$i]['callcount'] < 5 && $add['qsodata'][$i]['callcount'] > 0) { if(isset($result['qsodata'][$i]['callcount'])) {
$calls = explode(',', $add['qsodata'][$i]['calls']); if ($result['qsodata'][$i]['callcount'] < 5 && $add['qsodata'][$i]['callcount'] > 0) {
foreach ($calls as $c) { $calls = explode(',', $add['qsodata'][$i]['calls']);
if ($result['qsodata'][$i]['callcount'] < 5) { foreach ($calls as $c) {
if ($result['qsodata'][$i]['callcount'] > 0) { if ($result['qsodata'][$i]['callcount'] < 5) {
$result['qsodata'][$i]['calls'] .= ', '; if ($result['qsodata'][$i]['callcount'] > 0) {
} $result['qsodata'][$i]['calls'] .= ', ';
$result['qsodata'][$i]['calls'] .= $c; }
$result['qsodata'][$i]['callcount']++; $result['qsodata'][$i]['calls'] .= $c;
} $result['qsodata'][$i]['callcount']++;
} }
} }
}
}
} }
return $result; return $result;
} }
@ -115,6 +122,7 @@ class Distances_model extends CI_Model
// 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, $measurement_base) { 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
@ -139,6 +147,7 @@ class Distances_model extends CI_Model
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!'));
exit;
} }
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