diff --git a/application/controllers/Map.php b/application/controllers/Map.php index 11d26462..998a8f97 100644 --- a/application/controllers/Map.php +++ b/application/controllers/Map.php @@ -113,7 +113,7 @@ class Map extends CI_Controller { $this->load->library('qra'); $qsos = $this->logbook_model->map_custom_qsos(rawurldecode($start_date), rawurldecode($end_date), $band); - + header('Content-Type: application/json; charset=utf-8'); echo "{\"markers\": ["; $count = 1; if ($qsos) { @@ -132,7 +132,43 @@ class Map extends CI_Controller { } $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."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; + } else { + echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; + } + + $count++; } else { if($count != 1) { echo ","; @@ -176,7 +212,7 @@ class Map extends CI_Controller { $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."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; @@ -185,7 +221,44 @@ class Map extends CI_Controller { } $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."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; + } else { + echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}"; + } + + $count++; } else { $query = $this->db->query(' SELECT *