kopia lustrzana https://github.com/magicbug/Cloudlog
[KML Export] Bugfix, as it was not working. Also made a GUI with options for what you want to export.
rodzic
c1b0d49ae7
commit
b2750b827f
|
@ -9,7 +9,28 @@
|
|||
|
||||
class Kml extends CI_Controller {
|
||||
|
||||
public function index()
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('user_model');
|
||||
$this->load->model('modes');
|
||||
$this->load->model('dxcc');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['worked_bands'] = $this->dxcc->get_worked_bands(); // Used in the view for band select
|
||||
$data['modes'] = $this->modes->active(); // Used in the view for mode select
|
||||
$data['dxcc'] = $this->logbook_model->fetchDxcc(); // Used in the view for dxcc select
|
||||
|
||||
$data['page_title'] = "KML Export";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('kml/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
// Load Librarys
|
||||
$this->load->library('qra');
|
||||
|
@ -18,12 +39,18 @@ class Kml extends CI_Controller {
|
|||
// Load Database connections
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
// Get QSOs with Valid QRAs
|
||||
$qsos = $this->logbook_model->kml_get_all_qsos();
|
||||
// Parameters
|
||||
$band = $this->input->post('band');
|
||||
$mode = $this->input->post('mode');
|
||||
$dxcc = $this->input->post('dxcc_id');
|
||||
$cqz = $this->input->post('cqz');
|
||||
$propagation = $this->input->post('prop_mode');
|
||||
$fromdate = $this->input->post('fromdate');
|
||||
$todate = $this->input->post('todate');
|
||||
|
||||
// Get QSOs with Valid QRAs
|
||||
$qsos = $this->logbook_model->kml_get_all_qsos($band, $mode, $dxcc, $cqz, $propagation, $fromdate, $todate);
|
||||
|
||||
//header('Content-type: text/xml');
|
||||
//header("Cache-Control: no-cache");
|
||||
|
||||
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
$output .= "<kml xmlns=\"http://www.opengis.net/kml/2.2\">";
|
||||
|
||||
|
@ -32,7 +59,7 @@ class Kml extends CI_Controller {
|
|||
foreach ($qsos->result() as $row)
|
||||
{
|
||||
$output .= "<Placemark>";
|
||||
//print_r($row);
|
||||
|
||||
if($row->COL_GRIDSQUARE != null) {
|
||||
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
|
||||
|
||||
|
@ -41,7 +68,7 @@ class Kml extends CI_Controller {
|
|||
} else {
|
||||
$query = $this->db->query('
|
||||
SELECT *
|
||||
FROM dxcc
|
||||
FROM dxcc_entities
|
||||
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
|
||||
ORDER BY LENGTH( prefix ) DESC
|
||||
LIMIT 1
|
||||
|
@ -55,7 +82,6 @@ class Kml extends CI_Controller {
|
|||
|
||||
$timestamp = strtotime($row->COL_TIME_ON);
|
||||
|
||||
|
||||
$output .= "<name>".$row->COL_CALL."</name>";
|
||||
$output .= "<description><![CDATA[<p>Date/Time: ".date('Y-m-d H:i:s', ($timestamp))."<br/>Band: ".$row->COL_BAND."<br /></p>]]></description>";
|
||||
$output .= "<Point>";
|
||||
|
@ -64,13 +90,16 @@ class Kml extends CI_Controller {
|
|||
$output .= "</Placemark>";
|
||||
}
|
||||
|
||||
|
||||
$output .= "</Document>";
|
||||
$output .= "</kml>";
|
||||
|
||||
if (!file_exists('kml')) {
|
||||
mkdir('kml', 0755, true);
|
||||
}
|
||||
|
||||
if ( ! write_file('kml/qsos.kml', $output))
|
||||
{
|
||||
echo 'Unable to write the file - Make the folder KML has write permissions.';
|
||||
echo 'Unable to write the file - Make sure the folder KML has write permissions.';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -810,10 +810,49 @@ class Logbook_model extends CI_Model {
|
|||
return $query;
|
||||
}
|
||||
|
||||
/* Get All QSOs with a Valid Grid */
|
||||
function kml_get_all_qsos() {
|
||||
/* 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\'');
|
||||
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$this->db->where('COL_PROP_MODE = \'' . $band . '\'');
|
||||
}
|
||||
else {
|
||||
$this->db->where('COL_PROP_MODE != \'SAT\'');
|
||||
$this->db->where('COL_BAND = \'' . $band .'\'');
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode != 'All') {
|
||||
$this->db->where('COL_MODE = \'' . $mode . '\'');
|
||||
}
|
||||
|
||||
if ($dxcc != 'All') {
|
||||
$this->db->where('COL_DXCC = ' . $dxcc);
|
||||
}
|
||||
|
||||
if ($cqz != 'All') {
|
||||
$this->db->where('COL_CQZ = ' . $cqz);
|
||||
}
|
||||
|
||||
if ($propagation != 'All') {
|
||||
$this->db->where('COL_PROP_MODE = ' . $propagation);
|
||||
}
|
||||
|
||||
// If date is set, we format the date and add it to the where-statement
|
||||
if ($fromdate != "") {
|
||||
$from = DateTime::createFromFormat('d/m/Y', $fromdate);
|
||||
$from = $from->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) >= '".$from."'");
|
||||
}
|
||||
if ($todate != "") {
|
||||
$to = DateTime::createFromFormat('d/m/Y', $todate);
|
||||
$to = $to->format('Y-m-d');
|
||||
$this->db->where("date(".$this->config->item('table_name').".COL_TIME_ON) <= '".$to."'");
|
||||
}
|
||||
|
||||
$query = $this->db->get($this->config->item('table_name'));
|
||||
|
||||
return $query;
|
||||
|
|
|
@ -2284,6 +2284,23 @@ $(document).ready(function(){
|
|||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "kml") { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#datetimepicker1').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
$(function () {
|
||||
$('#datetimepicker2').datetimepicker({
|
||||
format: 'DD/MM/YYYY',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<script>
|
||||
function viewQsl(picture, callsign) {
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
|
|
|
@ -164,6 +164,10 @@
|
|||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('update');?>" title="Update Country Files"><i class="fas fa-sync"></i> Update Country Files</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<a class="dropdown-item" href="<?php echo site_url('kml');?>" title="KML Export for Google Earth"><i class="fas fa-sync"></i> KML Export</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
<div class="container">
|
||||
<br>
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Export your logbook to a KML file for use in Google Earth.
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning" role="alert">
|
||||
Only QSOs with a gridsquare defined, is exported!
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<form class="form" action="<?php echo site_url('kml/export'); ?>" method="post" enctype="multipart/form-data">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="band">Band</label>
|
||||
<select id="band" name="band" class="custom-select">
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> >Every band</option>
|
||||
<?php foreach($worked_bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="dxcc_id">DXCC</label>
|
||||
<select class="custom-select" id="dxcc_id" name="dxcc_id">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
foreach($dxcc as $d){
|
||||
echo '<option value=' . $d->adif . '>' . $d->prefix . ' - ' . ucwords(strtolower(($d->name))) . '</option>';
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="mode">Mode</label>
|
||||
<select id="mode" name="mode" class="form-control custom-select">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
foreach($modes->result() as $mode){
|
||||
if ($mode->submode == null) {
|
||||
echo '<option value="' . $mode->mode . '">'. $mode->mode . '</option>'."\n";
|
||||
} else {
|
||||
echo '<option value="' . $mode->submode . '">' . $mode->submode . '</option>'."\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="cqz">CQ Zone</label>
|
||||
<select class="custom-select" id="cqz" name="cqz">
|
||||
<option value="All">All</option>
|
||||
<?php
|
||||
for ($i = 1; $i<=40; $i++) {
|
||||
echo '<option value="'. $i . '">'. $i .'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="selectPropagation">Propagation Mode</label>
|
||||
<select class="custom-select" id="selectPropagation" name="prop_mode">
|
||||
<option value="All">All</option>
|
||||
<option value="AUR">Aurora</option>
|
||||
<option value="AUE">Aurora-E</option>
|
||||
<option value="BS">Back scatter</option>
|
||||
<option value="ECH">EchoLink</option>
|
||||
<option value="EME">Earth-Moon-Earth</option>
|
||||
<option value="ES">Sporadic E</option>
|
||||
<option value="FAI">Field Aligned Irregularities</option>
|
||||
<option value="F2">F2 Reflection</option>
|
||||
<option value="INTERNET">Internet-assisted</option>
|
||||
<option value="ION">Ionoscatter</option>
|
||||
<option value="IRL">IRLP</option>
|
||||
<option value="MS">Meteor scatter</option>
|
||||
<option value="RPT">Terrestrial or atmospheric repeater or transponder</option>
|
||||
<option value="RS">Rain scatter</option>
|
||||
<option value="SAT">Satellite</option>
|
||||
<option value="TEP">Trans-equatorial</option>
|
||||
<option value="TR">Tropospheric ducting</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<p class="card-text">From date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker1" data-target-input="nearest">
|
||||
<input name="fromdate" type="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="card-text">To date:</p>
|
||||
<div class="row">
|
||||
<div class="input-group date col-md-3" id="datetimepicker2" data-target-input="nearest">
|
||||
<input name="todate" "totype="text" placeholder="DD/MM/YYYY" class="form-control datetimepicker-input" data-target="#datetimepicker2"/>
|
||||
<div class="input-group-append" data-target="#datetimepicker2" data-toggle="datetimepicker">
|
||||
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="btn btn-primary mb-2" value="Export">Export</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Ładowanie…
Reference in New Issue