mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-23 01:59:14 +00:00
Convert bearing lookup to POST request
This commit is contained in:
parent
522854377b
commit
3efcbf0b0d
@ -878,7 +878,9 @@ class Logbook extends CI_Controller {
|
||||
|
||||
|
||||
/* return station bearing */
|
||||
function searchbearing($locator, $station_id = null) {
|
||||
function searchbearing() {
|
||||
$locator = xss_clean($this->input->post('grid'));
|
||||
$station_id = xss_clean($this->input->post('stationProfile'));
|
||||
$this->load->library('Qra');
|
||||
|
||||
if($locator != null) {
|
||||
|
@ -26,9 +26,12 @@ class Qra {
|
||||
$my = qra2latlong($tx);
|
||||
$stn = qra2latlong($rx);
|
||||
|
||||
if ($my !== false && $stn !== false ) {
|
||||
$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit);
|
||||
|
||||
return $bearing;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -168,6 +171,11 @@ function qra2latlong($strQRA) {
|
||||
if (substr_count($strQRA, ',') == 3) {
|
||||
// Handle grid corners
|
||||
$grids = explode(',', $strQRA);
|
||||
$gridlengths = array(strlen($grids[0]), strlen($grids[1]), strlen($grids[2]), strlen($grids[3]));
|
||||
$same = array_count_values($gridlengths);
|
||||
if (count($same) != 1) {
|
||||
return false;
|
||||
}
|
||||
$coords = array(0, 0);
|
||||
for($i=0; $i<4; $i++) {
|
||||
$cornercoords[$i] = qra2latlong($grids[$i]);
|
||||
@ -178,6 +186,9 @@ function qra2latlong($strQRA) {
|
||||
} else if (substr_count($strQRA, ',') == 1) {
|
||||
// Handle grid lines
|
||||
$grids = explode(',', $strQRA);
|
||||
if (strlen($grids[0]) != strlen($grids[1])) {
|
||||
return false;
|
||||
}
|
||||
$coords = array(0, 0);
|
||||
for($i=0; $i<2; $i++) {
|
||||
$linecoords[$i] = qra2latlong($grids[$i]);
|
||||
|
@ -829,7 +829,20 @@ $("#locator").keyup(function(){
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
})
|
||||
|
||||
$('#locator_info').load(base_url +"index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow");
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/logbook/searchbearing',
|
||||
type: 'post',
|
||||
data: {
|
||||
grid: $(this).val(),
|
||||
stationProfile: $('#stationProfile').val()
|
||||
},
|
||||
success: function(data) {
|
||||
$('#locator_info').html(data).fadeIn("slow");
|
||||
},
|
||||
error: function() {
|
||||
$('#locator_info').text("Error loading bearing and distance").fadeIn("slow");
|
||||
},
|
||||
});
|
||||
$.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) {
|
||||
document.getElementById("distance").value = result;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user