simplify visitor map function

这个提交包含在:
abarrau 2023-12-12 14:58:55 +01:00
父节点 fae3c8a86e
当前提交 d4e5a6ab88
共有 3 个文件被更改,包括 12 次插入90 次删除

查看文件

@ -99,7 +99,7 @@ class Map extends CI_Controller {
}
// Generic fonction for return Json for MAP //
function map_plot_json() {
public function map_plot_json() {
$this->load->model('Stations');
$this->load->model('logbook_model');

查看文件

@ -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()

查看文件

@ -4481,7 +4481,7 @@ function lotw_last_qsl_date($user_id) {
}
// [JSON PLOT] return array for plot qso for map //
public function get_plot_array_for_map($qsos_result) {
public function get_plot_array_for_map($qsos_result, $isVisitor=false) {
$this->load->library('qra');
$json["markers"] = array();
@ -4495,8 +4495,10 @@ function lotw_last_qsl_date($user_id) {
$plot['html'] .= "Mode: ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)."<br />";
// check if qso is confirmed //
if (($row->COL_EQSL_QSL_RCVD=='Y') || ($row->COL_LOTW_QSL_RCVD=='Y') || ($row->COL_QSL_RCVD=='Y')) {
$plot['confirmed'] = "Y";
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) {