[Mapping] calculate midpoint of multi grids for markers
这个提交包含在:
父节点
f113d1c17b
当前提交
0eb2b6043e
共有 4 个文件被更改,包括 143 次插入 和 0 次删除
|
|
@ -121,7 +121,43 @@ class Dashboard extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$count++;
|
$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."\"}";
|
||||||
|
} 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."\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$count++;
|
||||||
} else {
|
} else {
|
||||||
$query = $this->db->query('
|
$query = $this->db->query('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
|
||||||
|
|
@ -375,7 +375,44 @@ class Logbook extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$count++;
|
$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."\"}";
|
||||||
|
} 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."\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$query = $this->db->query('
|
$query = $this->db->query('
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,46 @@ class Qra {
|
||||||
$stn = qra2latlong($rx);
|
$stn = qra2latlong($rx);
|
||||||
return get_bearing($my[0], $my[1], $stn[0], $stn[1]);
|
return get_bearing($my[0], $my[1], $stn[0], $stn[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Find the Midpoint between two gridsquares using lat / long
|
||||||
|
|
||||||
|
Needs following passed
|
||||||
|
|
||||||
|
$coords[]=array('lat' => '53.344104','lng'=>'-6.2674937');
|
||||||
|
$coords[]=array('lat' => '51.5081289','lng'=>'-0.128005');
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function get_midpoint($coords)
|
||||||
|
{
|
||||||
|
$count_coords = count($coords);
|
||||||
|
$xcos=0.0;
|
||||||
|
$ycos=0.0;
|
||||||
|
$zsin=0.0;
|
||||||
|
|
||||||
|
foreach ($coords as $lnglat)
|
||||||
|
{
|
||||||
|
$lat = $lnglat['lat'] * pi() / 180;
|
||||||
|
$lon = $lnglat['lng'] * pi() / 180;
|
||||||
|
|
||||||
|
$acos = cos($lat) * cos($lon);
|
||||||
|
$bcos = cos($lat) * sin($lon);
|
||||||
|
$csin = sin($lat);
|
||||||
|
$xcos += $acos;
|
||||||
|
$ycos += $bcos;
|
||||||
|
$zsin += $csin;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xcos /= $count_coords;
|
||||||
|
$ycos /= $count_coords;
|
||||||
|
$zsin /= $count_coords;
|
||||||
|
$lon = atan2($ycos, $xcos);
|
||||||
|
$sqrt = sqrt($xcos * $xcos + $ycos * $ycos);
|
||||||
|
$lat = atan2($zsin, $sqrt);
|
||||||
|
|
||||||
|
return array($lat * 180 / pi(), $lon * 180 / pi());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function distance($lat1, $lon1, $lat2, $lon2, $unit = 'M') {
|
function distance($lat1, $lon1, $lat2, $lon2, $unit = 'M') {
|
||||||
|
|
@ -158,4 +198,6 @@ function qra2latlong($strQRA) {
|
||||||
return array(0, 0);
|
return array(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* End of file Qra.php */
|
/* End of file Qra.php */
|
||||||
|
|
|
||||||
|
|
@ -434,6 +434,34 @@
|
||||||
$lat = $stn_loc[0];
|
$lat = $stn_loc[0];
|
||||||
$lng = $stn_loc[1];
|
$lng = $stn_loc[1];
|
||||||
}
|
}
|
||||||
|
} 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]);
|
||||||
|
|
||||||
|
$midpoint = $this->qra->get_midpoint($coords);
|
||||||
|
$lat = $midpoint[0];
|
||||||
|
$lng = $midpoint[1];
|
||||||
|
}
|
||||||
|
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]);
|
||||||
|
|
||||||
|
$midpoint = $this->qra->get_midpoint($coords);
|
||||||
|
$lat = $midpoint[0];
|
||||||
|
$lng = $midpoint[1];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用