Merge pull request #2810 from abarrau/map-simplify-centralize-json-call

[MAP] Simplify call function for map json data
这个提交包含在:
Andreas Kristiansen 2023-12-28 14:15:16 +01:00 提交者 GitHub
当前提交 77a1c0772d
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 11 个文件被更改,包括 158 次插入597 次删除

查看文件

@ -140,103 +140,5 @@ class Dashboard extends CI_Controller {
$this->load->view('components/radio_display_table', $data);
}
function map() {
$this->load->model('logbook_model');
$this->load->library('qra');
$qsos = $this->logbook_model->get_last_qsos('18');
echo "{\"markers\": [";
$count = 1;
foreach ($qsos->result() as $row) {
// check if qso is confirmed //
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; }
//print_r($row);
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
}elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
} else {
if($count != 1) {
echo ",";
}
if(isset($row->lat) && isset($row->long)) {
$lat = $row->lat;
$lng = $row->long;
}
echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
$count++;
}
}
echo "]";
// [MAP Custom] ADD Station //
$this->load->model('Stations');
$station_json = $this->Stations->get_station_json_for_map();
echo (!empty($station_json))?', '.$station_json:'';
echo "}";
}
}

查看文件

@ -589,109 +589,6 @@ class Logbook extends CI_Controller {
}
}
/* Used to generate maps for displaying on /logbook/ */
function qso_map() {
header('Content-Type: application/json; charset=utf-8');
$this->load->model('logbook_model');
$this->load->library('qra');
$data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4));
echo "{\"markers\": [";
$count = 1;
foreach ($data['qsos']->result() as $row) {
// check if qso is confirmed //
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; }
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
}elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
} else {
if($count != 1) {
echo ",";
}
$result = $this->logbook_model->dxcc_lookup($row->COL_CALL, $row->COL_TIME_ON);
if(isset($result)) {
$lat = $result['lat'];
$lng = $result['long'];
}
echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
$count++;
}
}
echo "]";
// [MAP Custom] ADD Station //
$this->load->model('Stations');
$station_json = $this->Stations->get_station_json_for_map();
echo (!empty($station_json))?', '.$station_json:'';
echo "}";
}
function view($id) {
$this->load->library('DxccFlag');

查看文件

@ -3,32 +3,8 @@
class Map extends CI_Controller {
function index()
{
// Calculate Lat/Lng from Locator to use on Maps
if($this->session->userdata('user_locator')) {
$this->load->library('qra');
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
$data['qra'] = "set";
$data['qra_lat'] = $qra_position[0];
$data['qra_lng'] = $qra_position[1];
} else {
$data['qra'] = "none";
}
$this->load->model('Stations');
$station_id = $this->Stations->find_active();
$station_data = $this->Stations->profile_clean($station_id);
// load the view
$data['station_profile'] = $station_data;
$data['page_title'] = "Map QSOs";
$this->load->view('interface_assets/header', $data);
$this->load->view('map/qsos');
$this->load->view('interface_assets/footer');
function index() {
redirect('map/custom');
}
function custom()
@ -79,221 +55,38 @@ class Map extends CI_Controller {
$data['logbook_name'] = $logbook_name;
$data['page_title'] = "Map QSOs";
if ($this->input->post('from')) {
$from = $this->input->post('from');
$footer_data['date_from'] = $from;
} else {
$footer_data['date_from'] = date('Y-m-d H:i:00');
}
if ($this->input->post('to')) {
$to = $this->input->post('to');
$footer_data['date_to'] = $to;
} else {
$temp_to = new DateTime('tomorrow');
$footer_data['date_to'] = $temp_to->format('Y-m-d H:i:00');
}
$data['date_from'] = $data['date_to'] = date('Y-m-d');
$this->load->view('interface_assets/header', $data);
$this->load->view('map/custom_date');
$this->load->view('interface_assets/footer',$footer_data);
$this->load->view('interface_assets/footer');
}
function map_data_custom() {
$start_date = $this->uri->segment(3);
$end_date = $this->uri->segment(4);
$band = $this->uri->segment(5);
$mode = $this->uri->segment(6);
$propagation = $this->uri->segment(7);
// Generic fonction for return Json for MAP //
public function map_plot_json() {
$this->load->model('Stations');
$this->load->model('logbook_model');
$this->load->library('qra');
$qsos = $this->logbook_model->map_custom_qsos(rawurldecode($start_date), rawurldecode($end_date), $band, rawurldecode($mode), rawurldecode($propagation));
// set informations //
if ($this->input->post('isCustom') == true) {
$date_from = xss_clean($this->input->post('date_from'));
$date_to = xss_clean($this->input->post('date_to'));
$band = xss_clean($this->input->post('band'));
$mode = xss_clean($this->input->post('mode'));
$prop_mode = xss_clean($this->input->post('prop_mode'));
$qsos = $this->logbook_model->map_custom_qsos($date_from, $date_to, $band, $mode, $prop_mode);
} else {
$nb_qso = (intval($this->input->post('nb_qso'))>0)?xss_clean($this->input->post('nb_qso')):18;
$offset = (intval($this->input->post('offset'))>0)?xss_clean($this->input->post('offset')):null;
$qsos = $this->logbook_model->get_qsos($nb_qso, $offset);
}
// [PLOT] ADD plot //
$plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result());
// [MAP Custom] ADD Station //
$station_array = $this->Stations->get_station_array_for_map();
header('Content-Type: application/json; charset=utf-8');
echo "{\"markers\": [";
$count = 1;
if ($qsos) {
foreach ($qsos->result() as $row) {
// check if qso is confirmed //
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; }
//print_r($row);
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
}elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
} else {
if($count != 1) {
echo ",";
}
if(isset($row->lat) && isset($row->long)) {
$lat = $row->lat;
$lng = $row->long;
}
echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
$count++;
}
}
}
echo "]";
// [MAP Custom] ADD Station //
$this->load->model('Stations');
$station_json = $this->Stations->get_station_json_for_map();
echo (!empty($station_json))?', '.$station_json:'';
echo "}";
echo json_encode(array_merge($plot_array, $station_array));
}
function map_data() {
$this->load->model('logbook_model');
$this->load->library('qra');
//echo date('Y-m-d')
$raw = strtotime('Monday last week');
$mon = date('Y-m-d', $raw);
$sun = date('Y-m-d', strtotime('Monday next week'));
$qsos = $this->logbook_model->map_all_qsos_for_active_station_profile();
echo "{\"markers\": [";
$count = 1;
foreach ($qsos->result() as $row) {
// check if qso is confirmed //
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) { $row->_is_confirmed = 'Y'; } else { $row->_is_confirmed = 'N'; }
//print_r($row);
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
} elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
}
$count++;
} else {
$query = $this->db->query('
SELECT *
FROM dxcc_entities
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
');
foreach ($query->result() as $dxcc) {
if($count != 1) {
echo ",";
}
echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\", \"confirmed\":\"".$row->_is_confirmed."\"}";
$count++;
}
}
}
echo "]";
// [MAP Custom] ADD Station //
$this->load->model('Stations');
$station_json = $this->Stations->get_station_json_for_map();
echo (!empty($station_json))?', '.$station_json:'';
echo "}";
}
}

查看文件

@ -161,92 +161,12 @@ class Visitor extends CI_Controller {
show_404('Unknown Public Page.');
}
$qsos = $this->logbook_model->get_last_qsos('18', $logbooks_locations_array);
header('Content-Type: application/json; charset=utf-8');
echo "{\"markers\": [";
$count = 1;
foreach ($qsos->result() as $row) {
//print_r($row);
$begindate=date('d/m/y', strtotime($row->COL_TIME_ON));
if($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date: ".$begindate."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date: ".$begindate."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
}
$count++;
} elseif($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if($count != 1) {
echo ",";
}
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date: ".$begindate."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date: ".$begindate."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
}
$count++;
} else {
if($count != 1) {
echo ",";
}
if(isset($row->lat) && isset($row->long)) {
$lat = $row->lat;
$lng = $row->long;
}
echo "{\"lat\":\"".$lat."\",\"lng\":\"".$lng."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date: ".$begindate."<br />Band: ".$row->COL_BAND."<br />Mode: ";
echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE;
echo "\",\"label\":\"".$row->COL_CALL."\"}";
$count++;
}
}
echo "]";
echo "}";
$qsos = $this->logbook_model->get_qsos('18', null, $logbooks_locations_array);
// [PLOT] ADD plot //
$plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result());
header('Content-Type: application/json; charset=utf-8');
echo json_encode($plot_array);
}
public function satellites()

查看文件

@ -2129,7 +2129,7 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray =
}
$this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
$this->db->where("COL_TIME_ON BETWEEN '".$start." 00:00:00' AND '".$end." 23:59:59'");
$this->db->where_in("station_id", $logbooks_locations_array);
if($band != "All" && $band != "SAT") {
@ -2223,20 +2223,6 @@ function check_if_callsign_worked_in_logbook($callsign, $StationLocationsArray =
}
}
/* Return QSOs for the year for the active profile */
function map_all_qsos_for_active_station_profile() {
$CI =& get_instance();
$CI->load->model('stations');
$station_id = $CI->stations->find_active();
$this->db->where("station_id", $station_id);
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
/* Return QSOs made during the current Year */
function year_qsos($StationLocationsArray = null, $api_key = null) {
@ -4511,6 +4497,67 @@ function lotw_last_qsl_date($user_id) {
}
return false;
}
// [JSON PLOT] return array for plot qso for map //
public function get_plot_array_for_map($qsos_result, $isVisitor=false) {
$this->load->library('qra');
$json["markers"] = array();
foreach ($qsos_result as $row) {
$plot = array('lat'=>0, 'lng'=>0, 'html'=>'', 'label'=>'', 'confirmed'=>'N');
$plot['label'] = $row->COL_CALL;
$plot['html'] = "Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />";
$plot['html'] .= ($row->COL_SAT_NAME != null) ? ("SAT: ".$row->COL_SAT_NAME."<br />") : ("Band: ".$row->COL_BAND."<br />");
$plot['html'] .= "Mode: ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)."<br />";
// check if qso is confirmed //
if (!$isVisitor) {
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) {
$plot['confirmed'] = "Y";
}
}
// check lat / lng (depend info source) //
if ($row->COL_GRIDSQUARE != null) {
$stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
} elseif ($row->COL_VUCC_GRIDS != null) {
$grids = explode(",", $row->COL_VUCC_GRIDS);
if (count($grids) == 2) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
if (count($grids) == 4) {
$grid1 = $this->qra->qra2latlong(trim($grids[0]));
$grid2 = $this->qra->qra2latlong(trim($grids[1]));
$grid3 = $this->qra->qra2latlong(trim($grids[2]));
$grid4 = $this->qra->qra2latlong(trim($grids[3]));
$coords[]=array('lat' => $grid1[0],'lng'=> $grid1[1]);
$coords[]=array('lat' => $grid2[0],'lng'=> $grid2[1]);
$coords[]=array('lat' => $grid3[0],'lng'=> $grid3[1]);
$coords[]=array('lat' => $grid4[0],'lng'=> $grid4[1]);
$stn_loc = $this->qra->get_midpoint($coords);
}
} else {
if (isset($row->lat) && isset($row->long)) {
$stn_loc = array($row->lat, $row->long);
}
}
list($plot['lat'], $plot['lng']) = $stn_loc;
// add plot //
$json["markers"][] = $plot;
}
return $json;
}
}
function validateADIFDate($date, $format = 'Ymd')

查看文件

@ -515,14 +515,14 @@ class Stations extends CI_Model {
return false;
}
// [MAP Custom] get json structure (for map) about info's station //
public function get_station_json_for_map() {
// [MAP Custom] get array for json structure (for map) about info's station //
public function get_station_array_for_map() {
$_jsonresult = array();
list($station_lat, $station_lng) = array(0,0);
$station_active = $this->profile($this->find_active())->row();
if (!empty($station_active)) { list($station_lat, $station_lng) = $this->qra->qra2latlong($station_active->station_gridsquare); }
if (($station_lat!=0)&&($station_lng!=0)) { $_jsonresult = array('lat'=>$station_lat,'lng'=>$station_lng,'html'=>$station_active->station_gridsquare,'label'=>$station_active->station_profile_name,'icon'=>'stationIcon'); }
return (count($_jsonresult)>0)?("\"station\":".json_encode($_jsonresult)):'';
return (count($_jsonresult)>0)?(array('station'=>$_jsonresult)):array();
}
}

查看文件

@ -728,7 +728,7 @@ function showActivatorsMap(call, count, grids) {
var q_lng = -32.695312;
<?php } ?>
var qso_loc = '<?php echo site_url('map/map_data_custom/');?><?php echo rawurlencode($date_from); ?>/<?php echo rawurlencode($date_to); ?>/<?php echo rawurlencode($this->input->post('band')); ?>/<?php echo rawurlencode($this->input->post('mode')); ?>/<?php echo rawurlencode($this->input->post('prop_mode')); ?>';
var qso_loc = '<?php echo site_url('map/map_plot_json/');?>';
var q_zoom = 3;
$(document).ready(function(){
@ -737,38 +737,26 @@ function showActivatorsMap(call, count, grids) {
<?php } else { ?>
var grid = "No";
<?php } ?>
initmap(grid, 'custommap');
initmap(grid, 'custommap', {'initmap_only':true});
// Check and change date if to < from //
$('.custom-map-QSOs input[name="to"]').off('change').on('change', function() {
if ($('.custom-map-QSOs input[name="to"]').val().replaceAll('-','') < $('.custom-map-QSOs input[name="from"]').val().replaceAll('-','')) {
$('.custom-map-QSOs input[name="from"]').val($('.custom-map-QSOs input[name="to"]').val());
}
});
$('.custom-map-QSOs input[name="from"]').off('change').on('change', function() {
if ($('.custom-map-QSOs input[name="from"]').val().replaceAll('-','') > $('.custom-map-QSOs input[name="to"]').val().replaceAll('-','')) {
$('.custom-map-QSOs input[name="to"]').val($('.custom-map-QSOs input[name="from"]').val());
}
});
// Form "submit" //
$('.custom-map-QSOs .btn_submit_map_custom').off('click').on('click',function() {
var customdata = {'dataPost':{'date_from': $('.custom-map-QSOs input[name="from"]').val(), 'date_to': $('.custom-map-QSOs input[name="to"]').val(),
'band': $('.custom-map-QSOs select[name="band"]').val(), 'mode': $('.custom-map-QSOs select[name="mode"]').val(),
'prop_mode': $('.custom-map-QSOs select[name="prop_mode"]').val(), 'isCustom':true }, 'map_id':'#custommap'};
initplot(qso_loc, customdata);
})
});
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "map" && $this->uri->segment(2) == "") { ?>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/L.Maidenhead.js"></script>
<script id="leafembed" type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leafembed.js" tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>"></script>
<script type="text/javascript">
$(function () {
$('[data-bs-toggle="tooltip"]').tooltip()
});
<?php if($qra == "set") { ?>
var q_lat = <?php echo $qra_lat; ?>;
var q_lng = <?php echo $qra_lng; ?>;
<?php } else { ?>
var q_lat = 40.313043;
var q_lng = -32.695312;
<?php } ?>
var qso_loc = '<?php echo site_url('map/map_data');?>';
var q_zoom = 2;
$(document).ready(function(){
<?php if ($this->config->item('map_gridsquares') != FALSE) { ?>
var grid = "Yes";
<?php } else { ?>
var grid = "No";
<?php } ?>
initmap(grid);
});
</script>
@ -791,7 +779,7 @@ function showActivatorsMap(call, count, grids) {
var q_lng = -32.695312;
<?php } ?>
var qso_loc = '<?php echo site_url('dashboard/map');?>';
var qso_loc = '<?php echo site_url('map/map_plot_json');?>';
var q_zoom = 3;
$(document).ready(function(){
@ -800,7 +788,7 @@ function showActivatorsMap(call, count, grids) {
<?php } else { ?>
var grid = "No";
<?php } ?>
initmap(grid);
initmap(grid,'map',{'dataPost':{'nb_qso':'18'}});
});
</script>
@ -990,7 +978,7 @@ $($('#callsign')).on('keypress',function(e) {
var q_lng = -32.695312;
<?php } ?>
var qso_loc = '<?php echo site_url('logbook/qso_map/25/'.$this->uri->segment(3)); ?>';
var qso_loc = '<?php echo site_url('map/map_plot_json'); ?>';
var q_zoom = 3;
<?php if ($this->config->item('map_gridsquares') != FALSE) { ?>
@ -998,7 +986,7 @@ $($('#callsign')).on('keypress',function(e) {
<?php } else { ?>
var grid = "No";
<?php } ?>
initmap(grid);
initmap(grid,'map',{'dataPost':{'nb_qso':'25','offset':'<?php echo $this->uri->segment(3); ?>'}});
</script>
<?php } ?>

查看文件

@ -12,12 +12,12 @@
<div class="row">
<div class="mb-3 col-md-3">
<label for="from"><?php echo lang('gen_from_date') . ": " ?></label>
<input name="from" id="from" type="date" class="form-control w-auto">
<input name="from" id="from" type="date" class="form-control w-auto" value="<?php echo $date_from; ?>">
</div>
<div class="mb-3 col-md-3">
<label for="to"><?php echo lang('gen_to_date') . ": " ?></label>
<input name="to" id="to" type="date" class="form-control w-auto">
<input name="to" id="to" type="date" class="form-control w-auto" value="<?php echo $date_to; ?>" max="<?php echo $date_to; ?>">
</div>
</div>
@ -81,13 +81,19 @@
</div>
</div>
<input class="btn btn-primary" type="submit" value="Load Map">
<br><br>
<div class="row">
<div class="mb-1 col-md-1">
<input class="btn btn-primary btn_submit_map_custom" type="button" value="Load Map">
</div>
<div class="mb-4 col-md-4">
<div class="alert alert-danger warningOnSubmit" style="display:none;"><span><i class="fas fa-times-circle"></i></span> <span class="warningOnSubmit_txt ms-1">Error</span></div>
</div>
</div>
</form>
</div>
<!-- Map -->
<div id="custommap" class="map-leaflet" style="width: 100%; height: calc(100vh - 380px); max-height: 900px;"></div>
<div id="custommap" class="map-leaflet mt-2" style="width: 100%; height: calc(100vh - 390px); max-height: 900px;"></div>
<div class="alert alert-success" role="alert">Showing QSOs for Custom Date for Active Logbook <?php echo $logbook_name ?></div>

查看文件

@ -10,6 +10,6 @@
</div>
<!-- Map -->
<div id="map" style="width: 100%; height: 700px;"></div>
<div id="map" class="map-leaflet" style="width: 100%; height: 700px;"></div>
<div class="alert alert-success" role="alert">Showing all QSOs for the active Station Profile: <?php echo $station_profile->station_profile_name; ?> </div>

查看文件

@ -48,7 +48,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) {
</div>
<!-- Map -->
<div id="map" style="width: 100%; height: 350px"></div>
<div id="map" class="map-leaflet" style="width: 100%; height: 350px"></div>
<div id="container" style="padding-top: 0px; margin-top: 5px;" class="container dashboard">

查看文件

@ -9,6 +9,7 @@ var redIconImg = L.icon({ iconUrl: icon_dot_url, iconSize: [10, 10] }); // old /
var osmUrl = $('#leafembed').attr("tileUrl");
// function to initialise map (can called alone, without plot) //
function initmap(ShowGrid='No', MapTag='map', options={}) {
// set up the map
map = new L.Map(MapTag);
@ -38,29 +39,36 @@ function initmap(ShowGrid='No', MapTag='map', options={}) {
var layerControl = new L.Control.Layers(null, { 'Gridsquares': maidenhead = L.maidenhead() }).addTo(map);
if(ShowGrid == "Yes") { maidenhead.addTo(map); }
if ((typeof options.initmap_only=="undefined") || (options.initmap_only!=true)) { initplot(_url_qso, options); }
}
// function to initialise plot on map - Don't forget the "map_id" arg on options, if call alone //
function initplot(_url_qso, options={}) {
//console.log(_url_qso);
// get map custon infos //
var _visitor = (typeof visitor==="undefined")?false:visitor;
if (_visitor) {
askForPlots(_url_qso, options);
} else {
$.ajax({
url: base_url+'index.php/user_options/get_map_custom', type: 'GET', dataType: 'json',
error: function() { askForPlots(_url_qso, options); console.log('[ERROR] ajax get_map_custom() function return error.'); },
success: function(json_mapinfo) {
if (typeof json_mapinfo.qso !== "undefined") { iconsList = json_mapinfo; }
if(json_mapinfo.gridsquare_show == "1") { maidenhead.addTo(map); }
askForPlots(_url_qso, options);
}
});
if (_url_qso != '') {
var _visitor = (typeof visitor==="undefined")?false:visitor;
if (_visitor) {
askForPlots(_url_qso, options);
} else {
$.ajax({
url: base_url+'index.php/user_options/get_map_custom', type: 'GET', dataType: 'json',
error: function() { askForPlots(_url_qso, options); console.log('[ERROR] ajax get_map_custom() function return error.'); },
success: function(json_mapinfo) {
if (typeof json_mapinfo.qso !== "undefined") { iconsList = json_mapinfo; }
if(json_mapinfo.gridsquare_show == "1") { maidenhead.addTo(map); }
askForPlots(_url_qso, options);
}
});
}
}
}
function askForPlots(_url_qso, options={}) {
removeMarkers();
if (typeof options.dataPost !== "undefined") { _dataPost = options.dataPost; } else { _dataPost = {}; }
$.ajax({
url: _url_qso, type: 'GET', dataType: 'json',
url: _url_qso, type: 'POST', dataType: 'json', data: _dataPost,
error: function() { console.log('[ERROR] ajax askForPlots() function return error.'); },
success: function(plotjson) {
if ((typeof plotjson['markers'] !== "undefined")&&(plotjson['markers'].length>0)) {