diff --git a/application/controllers/Station.php b/application/controllers/Station.php index f7afddada..78f138d32 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -171,4 +171,13 @@ class Station extends CI_Controller redirect('stationsetup'); } + public function stationProfileCoords($id) { + $id = $this->security->xss_clean($id); + $this->load->model('stations'); + if ($this->stations->check_station_is_accessible($id)) { + $coords = $this->stations->lookupProfileCoords($id); + print json_encode($coords); + } + } + } diff --git a/application/models/Stations.php b/application/models/Stations.php index c59704c3a..d41d80254 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -601,6 +601,21 @@ class Stations extends CI_Model { 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)?(array('station'=>$_jsonresult)):array(); } + + public function lookupProfileCoords($stationid) { + $sql = "SELECT station_gridsquare FROM station_profile WHERE station_id = ?;"; + $query = $this->db->query($sql, $stationid); + if ($query->num_rows() == 1) { + $row = $query->row(); + if ($row->station_gridsquare != '') { + if (!$this->load->is_loaded('Qra')) { + $this->load->library('Qra'); + } + return $this->qra->qra2latlong($row->station_gridsquare); + } + } + return false; + } } ?> diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 83d74988c..993934697 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -305,7 +305,7 @@