[QRB Calculator] Tweaked the popup output a little bit

这个提交包含在:
Andreas 2022-02-15 20:28:37 +01:00
父节点 0357eb40df
当前提交 c27bc1243a
共有 4 个文件被更改,包括 58 次插入12 次删除

查看文件

@ -15,6 +15,10 @@ class Qrbcalc extends CI_Controller {
public function index() {
$data['page_title'] = "QRB Calculator";
$this->load->model('stations');
$data['station_locator'] = $this->stations->find_gridsquare();
$this->load->view('qrbcalc/index', $data);
}
@ -29,9 +33,23 @@ class Qrbcalc extends CI_Controller {
$measurement_base = $this->session->userdata('user_measurement_base');
}
switch ($measurement_base) {
case 'M':
$var_dist = " miles";
break;
case 'N':
$var_dist = " nautic miles";
break;
case 'K':
$var_dist = " kilometers";
break;
}
$this->load->library('Qra');
$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);
header('Content-Type: application/json');

查看文件

@ -60,6 +60,16 @@ class Qra {
// Return the distance
return $total_distance;
}
/*
* Function returns just the bearing
* Input locator1 and locator2
*/
function get_bearing($tx, $rx) {
$my = qra2latlong($tx);
$stn = qra2latlong($rx);
return get_bearing($my[0], $my[1], $stn[0], $stn[1]);
}
}
function distance($lat1, $lon1, $lat2, $lon2, $unit = 'M') {

查看文件

@ -454,13 +454,23 @@ function spawnQrbCalculator() {
}
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': form.locator1.value,
'locator2': form.locator2.value},
data: {'locator1': locator1,
'locator2': locator2},
success: function (html) {
$(".qrbResult").append(html['result']);
var result = "<h5>Negative latitudes are south of the equator, negative longitudes are west of Greenwich. <br/>";
result += ' ' + locator1.toUpperCase() + ' Latitude = ' + html['latlng1'][0] + ' Longitude = ' + html['latlng1'][1] + '<br/>';
result += ' ' + locator2.toUpperCase() + ' Latitude = ' + html['latlng2'][0] + ' Longitude = ' + html['latlng2'][1] + '<br/>';
result += 'Distance between ' + locator1.toUpperCase() + ' and ' + locator2.toUpperCase() + ' is ' + html['distance'] + '. and ';
result += 'the bearing is ' + html['bearing'] + '.</h5>';
$(".qrbResult").html(result);
newpath(html['latlng1'], html['latlng2']);
}
});
@ -474,23 +484,31 @@ function newpath(locator1, locator2) {
container._leaflet_id = null;
}
const map = L.map('mapqrb').setView([30, 0], 1.5);
const map = new L.map('mapqrb').setView([30, 0], 1.5);
var maidenhead = L.maidenheadqrb().addTo(map);
L.tileLayer('https://a.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
maxZoom: 10,
noWrap: false,
}).addTo(map);
var osmUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
var osm = new L.TileLayer(osmUrl, {minZoom: 1, maxZoom: 9, attribution: osmAttrib});
var redIcon = L.icon({
iconUrl: icon_dot_url,
iconSize: [10, 10], // size of the icon
});
map.addLayer(osm);
var marker = L.marker([locator1[0], locator1[1]], {icon: redIcon});
map.addLayer(marker);
var marker2 = L.marker([locator2[0], locator2[1]], {icon: redIcon});
map.addLayer(marker2);
const multiplelines = [];
//$.each(locs, function(){
multiplelines.push(
new L.LatLng(locator1[0], locator1[1]),
new L.LatLng(locator2[0], locator2[1])
)
//});
const geodesic = L.geodesic(multiplelines, {
weight: 1,

查看文件

@ -3,7 +3,7 @@
<div class="form-group row">
<div class="col-md-2 control-label" for="input">Locator 1</div>
<div class="col-md-4">
<input class="form-control input-group-sm" id="locator1" type="text" name="locator1" placeholder="" aria-label="locator1">
<input class="form-control input-group-sm" id="locator1" type="text" name="locator1" placeholder="" value="<?php if ($station_locator != "0") echo $station_locator; ?>" aria-label="locator1">
</div>
</div>