Base implementation for gridmap for activated grids

这个提交包含在:
phl0 2023-09-11 16:59:05 +02:00
父节点 78671273fe
当前提交 9ce313a902
找不到此签名对应的密钥
GPG 密钥 ID: 48EA1E640798CA9A
共有 8 个文件被更改,包括 581 次插入3 次删除

查看文件

@ -0,0 +1,191 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Activated_gridmap extends CI_Controller {
function __construct() {
parent::__construct();
}
public function index() {
$data['page_title'] = "Activated Gridsquare Map";
$this->load->model('bands');
$this->load->model('activated_gridmap_model');
$this->load->model('stations');
$data['homegrid'] = explode(',', $this->stations->find_gridsquare());
$data['modes'] = $this->activated_gridmap_model->get_worked_modes();
$data['bands'] = $this->bands->get_worked_bands();
$data['sats_available'] = $this->bands->get_worked_sats();
$data['user_gridmap_default_band'] = $this->session->userdata('user_gridmap_default_band');
$data['user_gridmap_confirmation'] = $this->session->userdata('user_gridmap_confirmation');
$data['layer'] = $this->optionslib->get_option('option_map_tile_server');
$data['attribution'] = $this->optionslib->get_option('option_map_tile_server_copyright');
$data['gridsquares_gridsquares'] = lang('gridsquares_gridsquares');
$data['gridsquares_gridsquares_confirmed'] = lang('gridsquares_gridsquares_confirmed');
$data['gridsquares_gridsquares_not_confirmed'] = lang('gridsquares_gridsquares_not_confirmed');
$data['gridsquares_gridsquares_total_activated'] = lang('gridsquares_gridsquares_total_activated');
$footerData = [];
$footerData['scripts'] = [
'assets/js/leaflet/geocoding.js',
'assets/js/leaflet/L.MaidenheadColouredGridMap.js',
'assets/js/sections/gridmap.js?'
];
$this->load->view('interface_assets/header', $data);
$this->load->view('activated_gridmap/index');
$this->load->view('interface_assets/footer', $footerData);
}
public function getGridsjs() {
$band = $this->security->xss_clean($this->input->post('band'));
$mode = $this->security->xss_clean($this->input->post('mode'));
$qsl = $this->security->xss_clean($this->input->post('qsl'));
$lotw = $this->security->xss_clean($this->input->post('lotw'));
$eqsl = $this->security->xss_clean($this->input->post('eqsl'));
$sat = $this->security->xss_clean($this->input->post('sat'));
$this->load->model('activated_gridmap_model');
$array_grid_2char = array();
$array_grid_4char = array();
$array_grid_6char = array();
$array_grid_2char_confirmed = array();
$array_grid_4char_confirmed = array();
$array_grid_6char_confirmed = array();
$grid_2char = "";
$grid_4char = "";
$grid_6char = "";
$grid_2char_confirmed = "";
$grid_4char_confirmed = "";
$grid_6char_confirmed = "";
$query = $this->activated_gridmap_model->get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $sat);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$gridlist = explode(',', $row->GRID_SQUARES);
foreach ($gridlist as $grid) {
$grid_2char_confirmed = strtoupper(substr($grid,0,2));
$grid_4char_confirmed = strtoupper(substr($grid,0,4));
if ($this->config->item('map_6digit_grids')) {
$grid_6char_confirmed = strtoupper(substr($grid,0,6));
}
// Check if 2 Char is in array
if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){
array_push($array_grid_2char_confirmed, $grid_2char_confirmed);
}
if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){
array_push($array_grid_4char_confirmed, $grid_4char_confirmed);
}
if ($this->config->item('map_6digit_grids')) {
if(!in_array($grid_6char_confirmed, $array_grid_6char_confirmed)){
array_push($array_grid_6char_confirmed, $grid_6char_confirmed);
}
}
}
}
}
$query = $this->activated_gridmap_model->get_band($band, $mode, $qsl, $lotw, $eqsl, $sat);
if ($query && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$gridlist = explode(',', $row->GRID_SQUARES);
foreach ($gridlist as $grid) {
$grid_two = strtoupper(substr($grid,0,2));
$grid_four = strtoupper(substr($grid,0,4));
if ($this->config->item('map_6digit_grids')) {
$grid_six = strtoupper(substr($grid,0,6));
}
// Check if 2 Char is in array
if(!in_array($grid_two, $array_grid_2char)){
array_push($array_grid_2char, $grid_two);
}
if(!in_array($grid_four, $array_grid_4char)){
array_push($array_grid_4char, $grid_four);
}
if ($this->config->item('map_6digit_grids')) {
if(!in_array($grid_six, $array_grid_6char)){
array_push($array_grid_6char, $grid_six);
}
}
}
}
}
$query_vucc = $this->activated_gridmap_model->get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat);
if ($query_vucc && $query_vucc->num_rows() > 0) {
foreach ($query_vucc->result() as $row) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
foreach($grids as $key) {
$grid_two = strtoupper(substr($key,0,2));
$grid_four = strtoupper(substr($key,0,4));
// Check if 2 Char is in array
if(!in_array($grid_two, $array_grid_2char)){
array_push($array_grid_2char, $grid_two);
}
if(!in_array($grid_four, $array_grid_4char)){
array_push($array_grid_4char, $grid_four);
}
}
}
}
// // Confirmed Squares
$query_vucc = $this->activated_gridmap_model->get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat);
if ($query_vucc && $query_vucc->num_rows() > 0) {
foreach ($query_vucc->result() as $row) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
foreach($grids as $key) {
$grid_2char_confirmed = strtoupper(substr($key,0,2));
$grid_4char_confirmed = strtoupper(substr($key,0,4));
// Check if 2 Char is in array
if(!in_array($grid_2char_confirmed, $array_grid_2char_confirmed)){
array_push($array_grid_2char_confirmed, $grid_2char_confirmed);
}
if(!in_array($grid_4char_confirmed, $array_grid_4char_confirmed)){
array_push($array_grid_4char_confirmed, $grid_4char_confirmed);
}
}
}
}
$data['grid_2char_confirmed'] = ($array_grid_2char_confirmed);
$data['grid_4char_confirmed'] = ($array_grid_4char_confirmed);
$data['grid_6char_confirmed'] = ($array_grid_6char_confirmed);
$data['grid_2char'] = ($array_grid_2char);
$data['grid_4char'] = ($array_grid_4char);
$data['grid_6char'] = ($array_grid_6char);
header('Content-Type: application/json');
echo json_encode($data);
}
}

查看文件

@ -23,4 +23,5 @@ $lang['gridsquares_button_plot'] = 'Plot';
$lang['gridsquares_gridsquares'] = 'Gridsquares';
$lang['gridsquares_gridsquares_confirmed'] = 'Gridsquares confirmed';
$lang['gridsquares_gridsquares_not_confirmed'] = 'Gridsquares not confirmed';
$lang['gridsquares_gridsquares_total_worked'] = 'Total gridsquares worked';
$lang['gridsquares_gridsquares_total_worked'] = 'Total gridsquares worked';
$lang['gridsquares_gridsquares_total_activated'] = 'Total gridsquares activated';

查看文件

@ -24,3 +24,4 @@ $lang['gridsquares_gridsquares'] = 'Planquadrate';
$lang['gridsquares_gridsquares_confirmed'] = 'Planquadrate bestätigt';
$lang['gridsquares_gridsquares_not_confirmed'] = 'Planquadrate nicht bestätigt';
$lang['gridsquares_gridsquares_total_worked'] = 'Summe gearbeiteter Planquadrate';
$lang['gridsquares_gridsquares_total_activated'] = 'Summe aktivierter Planquadrate';

查看文件

@ -0,0 +1,226 @@
<?php
class Activated_gridmap_model extends CI_Model {
function get_band_confirmed($band, $mode, $qsl, $lotw, $eqsl, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
. 'WHERE station_profile.station_gridsquare != "" ';
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
return $this->db->query($sql);
}
function get_band($band, $mode, $qsl, $lotw, $eqsl, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT DISTINCT station_gridsquare AS GRID_SQUARES, COL_BAND FROM '
. 'station_profile JOIN '.$this->config->item('table_name').' on '.$this->config->item('table_name').'.station_id = station_profile.station_id '
. 'WHERE station_profile.station_gridsquare != "" ';
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
return $this->db->query($sql);
}
function get_band_worked_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('
.$location_list.') AND COL_VUCC_GRIDS != ""';
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
return null;
return $this->db->query($sql);
}
function get_band_confirmed_vucc_squares($band, $mode, $qsl, $lotw, $eqsl, $sat) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$sql = 'SELECT distinct COL_VUCC_GRIDS, COL_BAND FROM '
.$this->config->item('table_name')
.' WHERE station_id in ('
.$location_list.') AND COL_VUCC_GRIDS != ""';
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
if ($sat != 'All') {
$sql .= " and col_sat_name ='" . $sat . "'";
}
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and (col_mode ='" . $mode . "' or col_submode ='" . $mode . "')";
}
$sql .= $this->addQslToQuery($qsl, $lotw, $eqsl);
return null;
return $this->db->query($sql);
}
// Adds confirmation to query
function addQslToQuery($qsl, $lotw, $eqsl) {
$sql = '';
if ($lotw == "true" && $qsl == "false" && $eqsl == "false") {
$sql .= " and col_lotw_qsl_rcvd = 'Y'";
}
if ($qsl == "true" && $lotw == "false" && $eqsl == "false") {
$sql .= " and col_qsl_rcvd = 'Y'";
}
if ($eqsl == "true" && $lotw == "false" && $qsl == "false") {
$sql .= " and col_eqsl_qsl_rcvd = 'Y'";
}
if ($lotw == "true" && $qsl == "true" && $eqsl == "false") {
$sql .= " and (col_lotw_qsl_rcvd = 'Y' or col_qsl_rcvd = 'Y')";
}
if ($qsl == "true" && $lotw == "false" && $eqsl == "true") {
$sql .= " and (col_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
}
if ($eqsl == "true" && $lotw == "true" && $qsl == "false") {
$sql .= " and (col_eqsl_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
}
if ($qsl == "true" && $lotw == "true" && $eqsl == "true") {
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y' or col_eqsl_qsl_rcvd = 'Y')";
}
if ($qsl == "false" && $lotw == "false" && $eqsl == "false") {
$sql .= " and (col_qsl_rcvd != 'Y' and col_lotw_qsl_rcvd != 'Y' and col_eqsl_qsl_rcvd != 'Y')";
}
return $sql;
}
/*
* Get's the worked modes from the log
*/
function get_worked_modes() {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$location_list = "'".implode("','",$logbooks_locations_array)."'";
// get all worked modes from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_MODE`) as `COL_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") order by COL_MODE ASC"
);
$results = array();
foreach ($data->result() as $row) {
array_push($results, $row->COL_MODE);
}
$data = $this->db->query(
"SELECT distinct LOWER(`COL_SUBMODE`) as `COL_SUBMODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id in (" . $location_list . ") and coalesce(COL_SUBMODE, '') <> '' order by COL_SUBMODE ASC"
);
foreach ($data->result() as $row) {
if (!in_array($row, $results)) {
array_push($results, $row->COL_SUBMODE);
}
}
asort($results);
return $results;
}
}

查看文件

@ -0,0 +1,150 @@
<style>
/*Legend specific*/
.legend {
padding: 6px 8px;
font: 14px Arial, Helvetica, sans-serif;
background: white;
line-height: 24px;
color: #555;
border-radius: 10px;
}
.legend h4 {
text-align: center;
font-size: 16px;
margin: 2px 12px 8px;
color: #777;
}
.legend span {
position: relative;
bottom: 3px;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin: 0 8px 0 0;
}
.coordinates {
justify-content: center;
align-items: stretch;
}
.cohidden {
display:none;
}
#latDeg, #lngDeg {
width: 170px;
}
#locator, #distance, #bearing {
width: 120px;
}
</style>
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<form class="form-inline">
<label class="my-1 mr-2" for="band"><?php echo lang('gridsquares_band'); ?></label>
<select class="custom-select my-1 mr-sm-2" id="band">
<option value="All">All</option>
<?php foreach($bands as $band) {
echo '<option value="'.$band.'"';
if ($user_gridmap_default_band == $band) {
echo ' selected="selected"';
}
echo '>'.$band.'</option>'."\n";
} ?>
</select>
<?php if (count($sats_available) != 0) { ?>
<label class="my-1 mr-2" for="distplot_sats"><?php echo lang('gridsquares_sat'); ?></label>
<select class="custom-select my-1 mr-sm-2" id="sats" <?php if ($user_gridmap_default_band != "SAT") { ?>disabled<?php } ?>>
<option value="All">All</option>
<?php foreach($sats_available as $sat) {
echo '<option value="' . $sat . '"' . '>' . $sat . '</option>'."\n";
} ?>
</select>
<?php } else { ?>
<input id="sats" type="hidden" value="All"></input>
<?php } ?>
<label class="my-1 mr-2" for="mode"><?php echo lang('gridsquares_mode'); ?></label>
<select class="custom-select my-1 mr-sm-2" id="mode">
<option value="All">All</option>
<?php
foreach($modes as $mode){
if ($mode->submode ?? '' == '') {
echo '<option value="' . $mode . '">' . strtoupper($mode) . '</option>'."\n";
}
}
?>
</select>
<label class="my-1 mr-2"><?php echo lang('gridsquares_confirmation'); ?></label>
<div>
<div class="form-check-inline">
<?php echo '<input class="form-check-input" type="checkbox" name="qsl" id="qsl"';
if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'Q') !== false) {
echo ' checked' ;
}
echo '>'; ?>
<label class="form-check-label" for="qsl">QSL</label>
</div>
<div class="form-check-inline">
<?php echo '<input class="form-check-input" type="checkbox" name="lotw" id="lotw"';
if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'L') !== false) {
echo ' checked' ;
}
echo '>'; ?>
<label class="form-check-label" for="lotw">LoTW</label>
</div>
<div class="form-check-inline">
<?php echo '<input class="form-check-input" type="checkbox" name="eqsl" id="eqsl"';
if (isset($user_gridmap_confirmation) && strpos($user_gridmap_confirmation, 'E') !== false) {
echo ' checked' ;
}
echo '>'; ?>
<label class="form-check-label" for="eqsl">eQSL</label>
</div>
</div>
<button id="plot" type="button" name="plot" class="btn btn-primary mr-1 ld-ext-right ld-ext-right-plot" onclick="gridPlot(this.form)"><?php echo lang('gridsquares_button_plot'); ?><div class="ld ld-ring ld-spin"></div></button>
<button id="clear" type="button" name="clear" class="btn btn-primary mr-1 ld-ext-right ld-ext-right-clear" onclick="clearMarkers()">Clear markers<div class="ld ld-ring ld-spin"></div></button>
</form>
<?php if($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<p><?php echo $this->session->flashdata('message'); ?></p>
</div>
<?php } ?>
</div>
<div id="gridmapcontainer">
<div id="gridsquare_map" style="width: 100%; height: 800px"></div>
</div>
<div class="coordinates d-flex">
<div class="cohidden">Latitude: </div>
<div class="cohidden col-auto text-success font-weight-bold" id="latDeg"></div>
<div class="cohidden">Longitude: </div>
<div class="cohidden col-auto text-success font-weight-bold" id="lngDeg"></div>
<div class="cohidden">Gridsquare: </div>
<div class="cohidden col-auto text-success font-weight-bold" id="locator"></div>
<div class="cohidden">Distance: </div>
<div class="cohidden col-auto text-success font-weight-bold" id="distance"></div>
<div class="cohidden">Bearing: </div>
<div class="cohidden col-auto text-success font-weight-bold" id="bearing"></div>
</div>
<script>var gridsquaremap = true;
var type = "activated";
<?php
echo 'var jslayer ="' . $layer .'";';
echo "var jsattribution ='" . $attribution . "';";
echo "var homegrid ='" . strtoupper($homegrid[0]) . "';";
echo 'var gridsquares_gridsquares = "' . $gridsquares_gridsquares . '";';
echo 'var gridsquares_gridsquares_confirmed = "' . $gridsquares_gridsquares_confirmed . '";';
echo 'var gridsquares_gridsquares_not_confirmed = "' . $gridsquares_gridsquares_not_confirmed . '";';
echo 'var gridsquares_gridsquares_total_worked = "' . $gridsquares_gridsquares_total_activated . '";';
?>
</script>

查看文件

@ -136,6 +136,7 @@
<div class="cohidden col-auto text-success font-weight-bold" id="bearing"></div>
</div>
<script>var gridsquaremap = true;
var type = "worked";
<?php
echo 'var jslayer ="' . $layer .'";';
echo "var jsattribution ='" . $attribution . "';";

查看文件

@ -102,7 +102,7 @@
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('gridmap');?>" title="Gridmap"><i class="fas fa-globe-europe"></i> <?php echo lang('menu_gridmap'); ?></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('activated_grids');?>" title="Activated Gridsquares"><i class="fas fa-globe-europe"></i> <?php echo lang('menu_activated_gridsquares'); ?></a>
<a class="dropdown-item" href="<?php echo site_url('activated_gridmap');?>" title="Activated Gridsquares"><i class="fas fa-globe-europe"></i> <?php echo lang('menu_activated_gridsquares'); ?></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('activators');?>" title="Gridsquare Activators"><i class="fas fa-globe-europe"></i> <?php echo lang('menu_gridsquare_activators'); ?></a>
<div class="dropdown-divider"></div>

查看文件

@ -28,8 +28,16 @@ function gridPlot(form) {
$("#gridmapcontainer").append('<div id="gridsquare_map" style="width: 100%; height: 800px"></div>');
}
if (type == "activated") {
ajax_url = site_url + '/activated_gridmap/getGridsjs';
} else if (type == "worked") {
ajax_url = site_url + '/gridmap/getGridsjs';
} else {
ajax_url = site_url + '/gridmap/getGridsjs';
}
$.ajax({
url: site_url + '/gridmap/getGridsjs',
url: ajax_url,
type: 'post',
data: {
band: $("#band").val(),