From 0763e647779cb86332e913ffa42fb2fef676e898 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 15 Feb 2022 22:17:37 +0100 Subject: [PATCH] [QRB Calc] Added some error checking and rounding of coordinates. --- application/controllers/Qrbcalc.php | 13 +++-- application/views/interface_assets/footer.php | 48 ++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/application/controllers/Qrbcalc.php b/application/controllers/Qrbcalc.php index 7eb72f67..f7ad22c7 100644 --- a/application/controllers/Qrbcalc.php +++ b/application/controllers/Qrbcalc.php @@ -18,7 +18,7 @@ class Qrbcalc extends CI_Controller { $this->load->model('stations'); $data['station_locator'] = $this->stations->find_gridsquare(); - + $this->load->view('qrbcalc/index', $data); } @@ -50,8 +50,15 @@ class Qrbcalc extends CI_Controller { $data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base); $data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist; $data['bearing'] = $this->qra->get_bearing($locator1, $locator2) . "º "; - $data['latlng1'] = $this->qra->qra2latlong($locator1); - $data['latlng2'] = $this->qra->qra2latlong($locator2); + $latlng1 = $this->qra->qra2latlong($locator1); + $latlng2 = $this->qra->qra2latlong($locator2); + $latlng1[0] = number_format((float)$latlng1[0], 3, '.', '');; + $latlng1[1] = number_format((float)$latlng1[1], 3, '.', '');; + $latlng2[0] = number_format((float)$latlng2[0], 3, '.', '');; + $latlng2[1] = number_format((float)$latlng2[1], 3, '.', '');; + + $data['latlng1'] = $latlng1; + $data['latlng2'] = $latlng2; header('Content-Type: application/json'); echo json_encode($data); } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 227d8118..e4f0c40b 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -457,23 +457,37 @@ function calculateQrb(form) { let locator1 = form.locator1.value; let locator2 = form.locator2.value; - $.ajax({ - url: base_url+'index.php/qrbcalc/calculate', - type: 'post', - data: {'locator1': locator1, - 'locator2': locator2}, - success: function (html) { - - var result = "