[KML Export] Fixed query to get the correct QSOs. Also added an extra check if lat and lng were undefined

这个提交包含在:
Andreas 2021-11-12 12:45:33 +01:00
父节点 6d6c60dd44
当前提交 1ce153a2ca
共有 2 个文件被更改,包括 22 次插入27 次删除

查看文件

@ -9,8 +9,7 @@
class Kml extends CI_Controller {
public function index()
{
public function index() {
$this->load->model('user_model');
$this->load->model('modes');
$this->load->model('dxcc');
@ -27,12 +26,10 @@ class Kml extends CI_Controller {
$this->load->view('interface_assets/header', $data);
$this->load->view('kml/index');
$this->load->view('interface_assets/footer');
}
public function export()
{
// Load Librarys
public function export() {
// Load Libraries
$this->load->library('qra');
$this->load->helper('file');
@ -56,10 +53,7 @@ class Kml extends CI_Controller {
$output .= "<Document>";
foreach ($qsos->result() as $row)
{
$output .= "<Placemark>";
foreach ($qsos->result() as $row) {
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
@ -73,13 +67,15 @@ class Kml extends CI_Controller {
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
');
foreach ($query->result() as $dxcc) {
$lat = $dxcc->lat;
$lng = $dxcc->long;
}
}
if (isset($lat) && isset($lng)) {
$output .= "<Placemark>";
$timestamp = strtotime($row->COL_TIME_ON);
$output .= "<name>".$row->COL_CALL."</name>";
@ -89,6 +85,7 @@ class Kml extends CI_Controller {
$output .= "</Point>";
$output .= "</Placemark>";
}
}
$output .= "</Document>";
$output .= "</kml>";
@ -97,12 +94,10 @@ class Kml extends CI_Controller {
mkdir('kml', 0755, true);
}
if ( ! write_file('kml/qsos.kml', $output))
{
if ( ! write_file('kml/qsos.kml', $output)) {
echo 'Unable to write the file. Make sure the folder KML has write permissions.';
}
else
{
else {
header("Content-Disposition: attachment; filename=\"qsos.kml\"");
echo $output;
}

查看文件

@ -912,7 +912,7 @@ class Logbook_model extends CI_Model {
/* Get all QSOs with a valid grid for use in the KML export */
function kml_get_all_qsos($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate) {
$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_GRIDSQUARE');
$this->db->where('COL_GRIDSQUARE != \'null\'');
$this->db->where("coalesce(COL_GRIDSQUARE, '') <> ''");
if ($band != 'All') {
if ($band == 'SAT') {