kopia lustrzana https://github.com/magicbug/Cloudlog
[IOTA Map] Added map to display IOTA's
rodzic
4ab4f06a25
commit
e1444c2abf
|
@ -619,4 +619,70 @@ class Awards extends CI_Controller {
|
|||
header('Content-Type: application/json');
|
||||
echo json_encode($zones);
|
||||
}
|
||||
|
||||
/*
|
||||
function iota
|
||||
This displays the IOTA map
|
||||
*/
|
||||
public function iota_map() {
|
||||
$this->load->model('iota');
|
||||
$this->load->model('bands');
|
||||
|
||||
$bands[] = $this->input->post('band');
|
||||
|
||||
$postdata['lotw'] = $this->input->post('lotw') == 0 ? NULL: 1;
|
||||
$postdata['qsl'] = $this->input->post('qsl') == 0 ? NULL: 1;
|
||||
$postdata['worked'] = $this->input->post('worked') == 0 ? NULL: 1;
|
||||
$postdata['confirmed'] = $this->input->post('confirmed') == 0 ? NULL: 1;
|
||||
$postdata['notworked'] = $this->input->post('notworked') == 0 ? NULL: 1;
|
||||
$postdata['band'] = $this->input->post('band');
|
||||
$postdata['mode'] = $this->input->post('mode');
|
||||
$postdata['includedeleted'] = $this->input->post('includedeleted') == 0 ? NULL: 1;
|
||||
$postdata['Africa'] = $this->input->post('Africa') == 0 ? NULL: 1;
|
||||
$postdata['Asia'] = $this->input->post('Asia') == 0 ? NULL: 1;
|
||||
$postdata['Europe'] = $this->input->post('Europe') == 0 ? NULL: 1;
|
||||
$postdata['NorthAmerica'] = $this->input->post('NorthAmerica') == 0 ? NULL: 1;
|
||||
$postdata['SouthAmerica'] = $this->input->post('SouthAmerica') == 0 ? NULL: 1;
|
||||
$postdata['Oceania'] = $this->input->post('Oceania') == 0 ? NULL: 1;
|
||||
$postdata['Antarctica'] = $this->input->post('Antarctica') == 0 ? NULL: 1;
|
||||
|
||||
$iotalist = $this->iota->fetchIota($postdata);
|
||||
|
||||
$iota_array = $this->iota->get_iota_array($iotalist, $bands, $postdata);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($iotalist as $iota) {
|
||||
$newiota[$i]['tag'] = $iota->tag;
|
||||
$newiota[$i]['prefix'] = $iota->prefix;
|
||||
$newiota[$i]['name'] = ucwords(strtolower($iota->name), "- (/");
|
||||
if ($iota->status == 'D') {
|
||||
$newiota[$i]['name'] .= ' (deleted)';
|
||||
}
|
||||
$newiota[$i]['lat1'] = $iota->lat1;
|
||||
$newiota[$i]['lon1'] = $iota->lon1;
|
||||
$newiota[$i]['lat2'] = $iota->lat2;
|
||||
$newiota[$i]['lon2'] = $iota->lon2;
|
||||
$newiota[$i++]['status'] = isset($iota_array[$iota->tag]) ? $this->returnStatus($iota_array[$iota->tag]) : 'x';
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($newiota);
|
||||
}
|
||||
|
||||
function returnStatus($string) {
|
||||
foreach ($string as $key) {
|
||||
if($key != "") {
|
||||
if (strpos($key, '>W<') !== false) {
|
||||
return 'W';
|
||||
}
|
||||
if (strpos($key, '>C<') !== false) {
|
||||
return 'C';
|
||||
}
|
||||
if ($key == '-') {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -78,13 +78,7 @@ class IOTA extends CI_Model {
|
|||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
}
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
$sql .= $this->addBandToQuery($band);
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and coalesce(iota.status, '') <> 'D'";
|
||||
|
@ -107,13 +101,7 @@ class IOTA extends CI_Model {
|
|||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
}
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
$sql .= $this->addBandToQuery($band);
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and coalesce(iota.status, '') <> 'D'";
|
||||
|
@ -137,7 +125,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$sql = "select tag, name, prefix, dxccid, status from iota where 1=1";
|
||||
$sql = "select tag, name, prefix, dxccid, status, lat1, lat2, lon1, lon2 from iota where 1=1";
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and coalesce(iota.status, '') <> 'D'";
|
||||
|
@ -182,27 +170,11 @@ class IOTA extends CI_Model {
|
|||
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
|
||||
}
|
||||
|
||||
if ($postdata['band'] != 'All') {
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $postdata['band'] . "'";
|
||||
}
|
||||
}
|
||||
$sql .= $this->addBandToQuery($postdata['band']);
|
||||
|
||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y'))";
|
||||
|
||||
if ($postdata['band'] != 'All') {
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $postdata['band'] . "'";
|
||||
}
|
||||
}
|
||||
$sql .= $this->addBandToQuery($postdata['band']);
|
||||
|
||||
if ($postdata['includedeleted'] == NULL) {
|
||||
$sql .= " and coalesce(iota.status, '') <> 'D'";
|
||||
|
@ -236,15 +208,7 @@ class IOTA extends CI_Model {
|
|||
|
||||
$sql .= $this->addContinentsToQuery($postdata);
|
||||
|
||||
if ($postdata['band'] != 'All') {
|
||||
if ($postdata['band'] == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
|
||||
}
|
||||
else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $postdata['band'] . "'";
|
||||
}
|
||||
}
|
||||
$sql .= $this->addBandToQuery($postdata['band']);
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
@ -392,5 +356,18 @@ class IOTA extends CI_Model {
|
|||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function addBandToQuery($band) {
|
||||
$sql = '';
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,38 @@
|
|||
|
||||
<style>
|
||||
#iotamap {
|
||||
height: calc(100vh - 500px) !important;
|
||||
max-height: 900px !important;
|
||||
}
|
||||
/*Legend specific*/
|
||||
.legend {
|
||||
padding: 6px 8px;
|
||||
font: 14px Arial, Helvetica, sans-serif;
|
||||
background: white;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
line-height: 24px;
|
||||
color: #555;
|
||||
}
|
||||
.legend h4 {
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
margin: 2px 12px 8px;
|
||||
color: #777;
|
||||
}
|
||||
.legend span {
|
||||
position: relative;
|
||||
bottom: 3px;
|
||||
}
|
||||
.legend i {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
float: left;
|
||||
margin: 0 8px 0 0;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="container">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
|
@ -108,11 +142,35 @@
|
|||
<div class="col-md-10">
|
||||
<button id="button2id" type="reset" name="button2id" class="btn btn-sm btn-warning">Reset</button>
|
||||
<button id="button1id" type="submit" name="button1id" class="btn btn-sm btn-primary">Show</button>
|
||||
<?php if ($iota_array) {
|
||||
?><button type="button" onclick="load_iota_map();" class="btn btn-info btn-sm"><i class="fas fa-globe-americas"></i> Show IOTA Map</button>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="table-tab" data-toggle="tab" href="#table" role="tab" aria-controls="table" aria-selected="true">Table</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="map-tab" data-toggle="tab" href="#iotamaptab" role="tab" aria-controls="home" aria-selected="false">Map</a>
|
||||
</li>
|
||||
</ul>
|
||||
<br />
|
||||
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade" id="iotamaptab" role="tabpanel" aria-labelledby="home-tab">
|
||||
<br />
|
||||
|
||||
<div id="iotamap"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade show active" id="table" role="tabpanel" aria-labelledby="table-tab">
|
||||
|
||||
<?php
|
||||
$i = 1;
|
||||
if ($iota_array) {
|
||||
|
@ -180,4 +238,6 @@
|
|||
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -44,6 +44,10 @@ function load_was_map() {
|
|||
<script id="cqmapjs" type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/cqmap.js" tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "awards" && ($this->uri->segment(2) == "iota") ) { ?>
|
||||
<script id="iotamapjs" type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/iotamap.js" tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "statistics") { ?>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/chart.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/chartjs-plugin-piechart-outlabels.js"></script>
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
var osmUrl = $('#iotamapjs').attr("tileUrl");
|
||||
|
||||
function load_iota_map() {
|
||||
$('.nav-tabs a[href="#iotamaptab"]').tab('show');
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/awards/iota_map',
|
||||
type: 'post',
|
||||
data: {
|
||||
band: $('#band2').val(),
|
||||
mode: $('#mode').val(),
|
||||
worked: +$('#worked').prop('checked'),
|
||||
confirmed: +$('#confirmed').prop('checked'),
|
||||
notworked: +$('#notworked').prop('checked'),
|
||||
qsl: +$('#qsl').prop('checked'),
|
||||
lotw: +$('#lotw').prop('checked'),
|
||||
includedeleted: +$('#includedeleted').prop('checked'),
|
||||
Africa: +$('#Africa').prop('checked'),
|
||||
Asia: +$('#Asia').prop('checked'),
|
||||
Europe: +$('#Europe').prop('checked'),
|
||||
NorthAmerica: +$('#NorthAmerica').prop('checked'),
|
||||
SouthAmerica: +$('#SouthAmerica').prop('checked'),
|
||||
Oceania: +$('#Oceania').prop('checked'),
|
||||
Antarctica: +$('#Antarctica').prop('checked'),
|
||||
},
|
||||
success: function(data) {
|
||||
load_iota_map2(data, worked, confirmed, notworked);
|
||||
},
|
||||
error: function() {
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function load_iota_map2(data, worked, confirmed, notworked) {
|
||||
|
||||
// If map is already initialized
|
||||
var container = L.DomUtil.get('iotamap');
|
||||
|
||||
if(container != null){
|
||||
container._leaflet_id = null;
|
||||
container.remove();
|
||||
$("#iotamaptab").append('<div id="iotamap"></div>');
|
||||
}
|
||||
|
||||
var map = L.map('iotamap');
|
||||
L.tileLayer(
|
||||
osmUrl,
|
||||
{
|
||||
attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
|
||||
maxZoom: 18
|
||||
}
|
||||
).addTo(map);
|
||||
|
||||
var notworkedcount = data.length;
|
||||
var confirmedcount = 0;
|
||||
var workednotconfirmedcount = 0;
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var D = data[i];
|
||||
if (D['status'] != 'x') {
|
||||
var mapColor = 'red';
|
||||
|
||||
if (D['status'] == 'C') {
|
||||
mapColor = 'green';
|
||||
if (confirmed != '0') {
|
||||
addPolygon(L, D, mapColor, map);
|
||||
addMarker(L, D, mapColor, map);
|
||||
confirmedcount++;
|
||||
notworkedcount--;
|
||||
}
|
||||
}
|
||||
if (D['status'] == 'W') {
|
||||
mapColor = 'orange';
|
||||
if (worked != '0') {
|
||||
addPolygon(L, D, mapColor, map);
|
||||
addMarker(L, D, mapColor, map);
|
||||
workednotconfirmedcount++;
|
||||
notworkedcount--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make a check here and hide what I don't want to show
|
||||
if (notworked != '0') {
|
||||
if (mapColor == 'red') {
|
||||
addPolygon(L, D, mapColor, map);
|
||||
addMarker(L, D, mapColor, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Legend specific*/
|
||||
var legend = L.control({ position: "topright" });
|
||||
|
||||
if (notworked.checked == false) {
|
||||
notworkedcount = 0;
|
||||
}
|
||||
|
||||
legend.onAdd = function(map) {
|
||||
var div = L.DomUtil.create("div", "legend");
|
||||
div.innerHTML += "<h4>Colors</h4>";
|
||||
div.innerHTML += '<i style="background: green"></i><span>Confirmed ('+confirmedcount+')</span><br>';
|
||||
div.innerHTML += '<i style="background: orange"></i><span>Worked not confirmed ('+workednotconfirmedcount+')</span><br>';
|
||||
div.innerHTML += '<i style="background: red"></i><span>Not worked ('+notworkedcount+')</span><br>';
|
||||
return div;
|
||||
};
|
||||
|
||||
legend.addTo(map);
|
||||
|
||||
map.setView([20, 0], 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to fix some islands that would wrap around the whole map.
|
||||
* That's why we add 360 degrees to some of them.
|
||||
* The following island have this problem:
|
||||
* AN-016, AS-027, AS-092, AS-174, OC-016
|
||||
* AN-020 is and exception
|
||||
*/
|
||||
function addPolygon(L, D, mapColor, map) {
|
||||
if (D['tag'] != 'AN-016') {
|
||||
if (D['lon1'] > 0 && D['lon2'] < 0 && D['lon1'] - D['lon2'] > 180) {
|
||||
D['lon2'] = parseFloat(D['lon2'])+360;
|
||||
|
||||
}
|
||||
|
||||
if (D['lon1'] < 0 && D['lon2'] > 0 && D['lon2'] - D['lon1'] > 180) {
|
||||
D['lon1'] = parseFloat(D['lon1'])+360;
|
||||
}
|
||||
}
|
||||
|
||||
// It seems to me that latitudes have the wrong sign to be drawn correctly in leaflet. That's why they are mulitipled with -1 to be drawn in the correct hemisphere.
|
||||
var latlngs = [
|
||||
[D['lat1']*-1, D['lon1']],
|
||||
[D['lat2']*-1, D['lon1']],
|
||||
[D['lat2']*-1, D['lon2']],
|
||||
[D['lat1']*-1, D['lon2']]
|
||||
];
|
||||
|
||||
var polygon = L.polygon(latlngs, {color: mapColor}).addTo(map);
|
||||
}
|
||||
|
||||
function addMarker(L, D, mapColor, map) {
|
||||
var title = '<span><font style="color: ' +mapColor+ '; text-shadow: 1px 0 #fff, -1px 0 #fff, 0 1px #fff, 0 -1px #fff, 1px 1px #fff, -1px -1px #fff, 1px -1px #fff, -1px 1px #fff;font-size: 14px; font-weight: 900;">' + D['tag'] + '</font></span>';
|
||||
var myIcon = L.divIcon({
|
||||
className: 'my-div-icon',
|
||||
html: title,
|
||||
iconSize: [60, 10]
|
||||
});
|
||||
|
||||
// It seems to me that latitudes have the wrong sign to be drawn correctly in leaflet. That's why they are mulitipled with -1 to be drawn in the correct hemisphere.
|
||||
L.marker(
|
||||
[D['lat1']*-1, D['lon1']], {
|
||||
icon: myIcon,
|
||||
iota: D['tag'],
|
||||
title: D['tag'],
|
||||
}
|
||||
).addTo(map).on('click', onClick);
|
||||
}
|
||||
|
||||
function onClick(e) {
|
||||
var marker = e.target;
|
||||
displayContacts(marker.options.iota, $('#band2').val(), $('#mode').val(), 'IOTA');
|
||||
}
|
Ładowanie…
Reference in New Issue