new function for return json data for map

这个提交包含在:
abarrau 2023-12-12 07:40:12 +01:00
父节点 4424868b88
当前提交 5886ce2dc8
共有 3 个文件被更改,包括 63 次插入4 次删除

查看文件

@ -4479,6 +4479,64 @@ 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) {
$this->load->library('qra');
$json["markers"] = array();
$plot = array('lat'=>0, 'lng'=>0, 'html'=>'', 'label'=>'', 'confirmed'=>'N');
foreach ($qsos_result as $row) {
$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 (($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')

查看文件

@ -513,14 +513,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();
}
}

查看文件

@ -59,8 +59,9 @@ function initmap(ShowGrid='No', MapTag='map', 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)) {