kopia lustrzana https://github.com/magicbug/Cloudlog
Added a map to the Add QSO page
rodzic
c3bb33ff03
commit
ec5c356cc0
|
@ -70,7 +70,7 @@ class Logbook extends CI_Controller {
|
|||
"workedBefore" => false
|
||||
];
|
||||
|
||||
$return['dxcc'] = $this->find_dxcc($callsign);
|
||||
$return['dxcc'] = $this->dxcheck($callsign);
|
||||
$return['partial'] = $this->partial($callsign);
|
||||
|
||||
// Do we have local data for the Callsign?
|
||||
|
@ -82,6 +82,11 @@ class Logbook extends CI_Controller {
|
|||
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
|
||||
$return['bearing'] = $this->bearing($return['callsign_qra']);
|
||||
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
|
||||
|
||||
if ($return['callsign_qra'] != "") {
|
||||
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
|
||||
}
|
||||
|
||||
echo json_encode($return, JSON_PRETTY_PRINT);
|
||||
return;
|
||||
}
|
||||
|
@ -118,6 +123,9 @@ class Logbook extends CI_Controller {
|
|||
$return['callsign_qra'] = $callbook['gridsquare'];
|
||||
$return['callsign_qth'] = $callbook['city'];
|
||||
$return['callsign_iota'] = $callbook['iota'];
|
||||
if ($return['callsign_qra'] != "") {
|
||||
$return['latlng'] = $this->qralatlng($return['callsign_qra']);
|
||||
}
|
||||
$return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
|
||||
}
|
||||
$return['bearing'] = $this->bearing($return['callsign_qra']);
|
||||
|
@ -343,6 +351,15 @@ class Logbook extends CI_Controller {
|
|||
print json_encode($ans);
|
||||
}
|
||||
|
||||
function dxcheck($call = "", $date = "") {
|
||||
$this->load->model("logbook_model");
|
||||
if ($date == ''){
|
||||
$date = date("Y-m-d");
|
||||
}
|
||||
$ans = $this->logbook_model->dxcc_lookup($call, $date);
|
||||
return $ans;
|
||||
}
|
||||
|
||||
|
||||
/* return station bearing */
|
||||
function searchbearing($locator) {
|
||||
|
@ -385,4 +402,16 @@ class Logbook extends CI_Controller {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function qralatlng($qra) {
|
||||
$this->load->library('Qra');
|
||||
$latlng = $this->qra->qra2latlong($qra);
|
||||
return $latlng;
|
||||
}
|
||||
|
||||
function qralatlngjson($qra) {
|
||||
$this->load->library('Qra');
|
||||
$latlng = $this->qra->qra2latlong($qra);
|
||||
print json_encode($latlng);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1087,6 +1087,34 @@ class Logbook_model extends CI_Model {
|
|||
return array("Not Found", "Not Found");
|
||||
}
|
||||
|
||||
public function dxcc_lookup($call, $date){
|
||||
$len = strlen($call);
|
||||
|
||||
// query the table, removing a character from the right until a match
|
||||
for ($i = $len; $i > 0; $i--){
|
||||
//printf("searching for %s\n", substr($call, 0, $i));
|
||||
$dxcc_result = $this->db->select('*')
|
||||
->where('call', substr($call, 0, $i))
|
||||
->where('(start <= ', $date)
|
||||
->or_where("start = '0000-00-00'", NULL, false)
|
||||
->or_where("start is null)", NULL, false)
|
||||
->where('(end >= ', $date)
|
||||
->or_where("end = '0000-00-00'", NULL, false)
|
||||
->or_where("end is null)", NULL, false)
|
||||
->get('dxcc_prefixes');
|
||||
|
||||
//$dxcc_result = $this->db->query("select `call`, `entity`, `adif` from dxcc_prefixes where `call` = '".substr($call, 0, $i) ."'");
|
||||
//print $this->db->last_query();
|
||||
|
||||
if ($dxcc_result->num_rows() > 0){
|
||||
$row = $dxcc_result->row_array();
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
return array("Not Found", "Not Found");
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as check_dxcc_table, but the functionality is in
|
||||
* a stored procedure which we call
|
||||
|
|
|
@ -110,12 +110,26 @@ $(document).ready(function(){
|
|||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "qso") { ?>
|
||||
|
||||
<script>
|
||||
var markers = L.layerGroup();
|
||||
var mymap = L.map('qsomap').setView([51.505, -0.09], 13);
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
||||
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
|
||||
'Created by Cloudlog',
|
||||
id: 'mapbox.streets'
|
||||
}).addTo(mymap);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var manual = <?php echo $_GET['manual']; ?>;
|
||||
|
||||
console.log(manual);
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
/* On Page Load */
|
||||
|
@ -197,6 +211,8 @@ $(document).ready(function(){
|
|||
$('#iota_ref').val("");
|
||||
$("#locator").removeClass("workedGrid");
|
||||
$("#locator").removeClass("newGrid");
|
||||
mymap.setView([51.505, -0.09], 13);
|
||||
mymap.removeLayer(markers);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -208,10 +224,25 @@ $(document).ready(function(){
|
|||
$.getJSON('logbook/json/' + $(this).val(), function(result)
|
||||
{
|
||||
//$('#country').val(result);
|
||||
$('#country').val(convert_case(result.dxcc.Name));
|
||||
$('#callsign_info').text(convert_case(result.dxcc.Name));
|
||||
$('#dxcc_id').val(result.dxcc.DXCC);
|
||||
$('#cqz').val(result.dxcc.CQZ);
|
||||
$('#country').val(convert_case(result.dxcc.entity));
|
||||
$('#callsign_info').text(convert_case(result.dxcc.entity));
|
||||
$('#dxcc_id').val(result.dxcc.adif);
|
||||
$('#cqz').val(result.dxcc.cqz);
|
||||
|
||||
|
||||
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
if (typeof result.latlng !== "undefined") {
|
||||
console.log("defined!");
|
||||
var marker = L.marker([result.latlng[0], result.latlng[1]]);
|
||||
mymap.setView([result.latlng[0], result.latlng[1]], 8);
|
||||
} else {
|
||||
var marker = L.marker([result.dxcc.lat, result.dxcc.long]);
|
||||
mymap.setView([result.dxcc.lat, result.dxcc.long], 8);
|
||||
}
|
||||
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
|
||||
/* Find Locator if the field is empty */
|
||||
if($('#locator').val() == "") {
|
||||
|
@ -301,6 +332,22 @@ $(document).ready(function(){
|
|||
/* On Key up Calculate Bearing and Distance */
|
||||
$("#locator").keyup(function(){
|
||||
if ($(this).val()) {
|
||||
$.getJSON('logbook/qralatlngjson/' + $(this).val(), function(result)
|
||||
{
|
||||
console.log(result[0]);
|
||||
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
if (typeof result !== "undefined") {
|
||||
console.log("defined!");
|
||||
var marker = L.marker([result[0], result[1]]);
|
||||
mymap.setView([result[0], result[1]], 8);
|
||||
}
|
||||
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
|
||||
})
|
||||
|
||||
$('#locator_info').load("logbook/searchbearing/" + $(this).val()).fadeIn("slow");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -292,6 +292,12 @@
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="card qso-map">
|
||||
<div class="card-header"><h4 class="card-title">QSO Map</h4></div>
|
||||
|
||||
<div id="qsomap" style="width: 100%; height: 200px;"></div>
|
||||
</div>
|
||||
|
||||
<div class="card previous-qsos">
|
||||
<div class="card-header"><h4 class="card-title">Previous Contacts</h4></div>
|
||||
<div class="card-body">
|
||||
|
@ -329,6 +335,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -120,3 +120,13 @@ TD.lotw{
|
|||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.qso-map .card-title {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.qso-map {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue