mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Added path lines and band
This commit is contained in:
@@ -417,9 +417,6 @@ class Visitor extends CI_Controller {
|
||||
}
|
||||
|
||||
public function exportmap() {
|
||||
// $data['slug'] = $this->security->xss_clean($this->uri->segment(3));
|
||||
// $data['qsocount'] = $this->security->xss_clean($this->uri->segment(4));
|
||||
|
||||
$data['page_title'] = "Export Map";
|
||||
$this->load->view('visitor/exportmap/header', $data);
|
||||
$this->load->view('visitor/exportmap/exportmap', $data);
|
||||
@@ -435,12 +432,12 @@ class Visitor extends CI_Controller {
|
||||
$qsocount = $this->security->xss_clean($this->input->get('qsocount')) == '' ? '100' : $this->security->xss_clean($this->input->get('qsocount'));
|
||||
$band = $this->security->xss_clean($this->input->get('band'));
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($slug);
|
||||
$this->load->model('stationsetup_model');
|
||||
$logbook_id = $this->stationsetup_model->public_slug_exists_logbook_id($slug);
|
||||
if($logbook_id != false)
|
||||
{
|
||||
// Get associated station locations for mysql queries
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
|
||||
$logbooks_locations_array = $this->stationsetup_model->get_container_relations($logbook_id);
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
show_404('Empty Logbook');
|
||||
@@ -450,12 +447,59 @@ class Visitor extends CI_Controller {
|
||||
show_404('Unknown Public Page.');
|
||||
}
|
||||
|
||||
$qsos = $this->logbook_model->get_qsos($qsocount, null, $logbooks_locations_array);
|
||||
// [PLOT] ADD plot //
|
||||
$plot_array = $this->logbook_model->get_plot_array_for_map($qsos->result());
|
||||
$qsos = $this->logbook_model->get_qsos($qsocount, null, $logbooks_locations_array, $band);
|
||||
|
||||
$mappedcoordinates = array();
|
||||
foreach ($qsos->result('array') as $qso) {
|
||||
if (!empty($qso['COL_MY_GRIDSQUARE']) || !empty($qso['COL_MY_VUCC_GRIDS'])) {
|
||||
if (!empty($qso['COL_GRIDSQUARE']) || !empty($qso['COL_VUCC_GRIDS'])) {
|
||||
$mappedcoordinates[] = $this->calculate($qso, ($qso['COL_MY_GRIDSQUARE'] ?? '') == '' ? $qso['COL_MY_VUCC_GRIDS'] : $qso['COL_MY_GRIDSQUARE'], ($qso['COL_GRIDSQUARE'] ?? '') == '' ? $qso['COL_VUCC_GRIDS'] : $qso['COL_GRIDSQUARE']);
|
||||
} else {
|
||||
if (!empty($qso['lat']) || !empty($qso['long'])) {
|
||||
$mappedcoordinates[] = $this->calculateCoordinates($qso, $qso['lat'], $qso['long'], ($qso['COL_MY_GRIDSQUARE'] ?? '') == '' ? $qso['COL_MY_VUCC_GRIDS'] : $qso['COL_MY_GRIDSQUARE']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($plot_array);
|
||||
echo json_encode($mappedcoordinates);
|
||||
}
|
||||
|
||||
public function calculate($qso, $locator1, $locator2) {
|
||||
$this->load->library('Qra');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$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;
|
||||
$data['confirmed'] = ($this->logbook_model->qso_is_confirmed($qso)==true) ? true : false;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function calculateCoordinates($qso, $lat, $long, $mygrid) {
|
||||
$this->load->library('Qra');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$latlng1 = $this->qra->qra2latlong($mygrid);
|
||||
$latlng2[0] = $lat;
|
||||
$latlng2[1] = $long;
|
||||
$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;
|
||||
$data['confirmed'] = ($this->logbook_model->qso_is_confirmed($qso)==true) ? true : false;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1689,7 +1689,7 @@ class Logbook_model extends CI_Model {
|
||||
return $query;
|
||||
}
|
||||
|
||||
function get_qsos($num, $offset, $StationLocationsArray = null) {
|
||||
function get_qsos($num, $offset, $StationLocationsArray = null, $band = '') {
|
||||
if($StationLocationsArray == null) {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
@@ -1711,6 +1711,16 @@ class Logbook_model extends CI_Model {
|
||||
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||
$this->db->join('dxcc_entities', $this->config->item('table_name').'.col_dxcc = dxcc_entities.adif', 'left');
|
||||
$this->db->join('lotw_users', 'lotw_users.callsign = '.$this->config->item('table_name').'.col_call', 'left outer');
|
||||
|
||||
if ($band != '') {
|
||||
if ($band == 'SAT') {
|
||||
$this->db->where($this->config->item('table_name').'.col_prop_mode', 'SAT');
|
||||
} else {
|
||||
$this->db->where($this->config->item('table_name').'.col_prop_mode !="SAT"');
|
||||
$this->db->where($this->config->item('table_name').'.col_band', $band);
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->where_in($this->config->item('table_name').'.station_id', $logbooks_locations_array);
|
||||
$this->db->order_by(''.$this->config->item('table_name').'.COL_TIME_ON', "desc");
|
||||
|
||||
|
||||
@@ -156,6 +156,24 @@ class Stationsetup_model extends CI_Model {
|
||||
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
|
||||
return $this->db->get('station_profile');
|
||||
}
|
||||
|
||||
function get_container_relations($logbook_id) {
|
||||
|
||||
$relationships_array = array();
|
||||
|
||||
$this->db->where('station_logbook_id', $logbook_id);
|
||||
$query = $this->db->get('station_logbooks_relationship');
|
||||
|
||||
if ($query->num_rows() > 0){
|
||||
foreach ($query->result() as $row) {
|
||||
array_push($relationships_array, $row->station_location_id);
|
||||
}
|
||||
|
||||
return $relationships_array;
|
||||
} else {
|
||||
return array(-1); // Put some default-Value here, if no relation found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<style>
|
||||
#exportmap {
|
||||
height: calc(100vh - 480px) !important;
|
||||
height: 100vh;
|
||||
max-height: 900px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<script id="leafembed" type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leafembed.js" tileUrl="<?php echo $this->optionslib->get_option('map_tile_server');?>"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/sections/exportmap.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/sections/cqmap_geojson.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leaflet.geodesic.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var zonemarkers = [];
|
||||
var clicklines = [];
|
||||
|
||||
$(document).ready(function () {
|
||||
mapQsos();
|
||||
@@ -12,6 +13,7 @@ function mapQsos(form) {
|
||||
const showgrid = urlParams.get('showgrid');
|
||||
const showcq = urlParams.get('showcq');
|
||||
const band = urlParams.get('band');
|
||||
const showlines = urlParams.get('showlines');
|
||||
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/visitor/mapqsos/',
|
||||
@@ -22,14 +24,14 @@ function mapQsos(form) {
|
||||
band: band
|
||||
},
|
||||
success: function(data) {
|
||||
loadMap(data, showgrid, showcq);
|
||||
loadMap(data, showgrid, showcq, showlines);
|
||||
},
|
||||
error: function() {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
function loadMap(data, showgrid, showcq) {
|
||||
function loadMap(data, showgrid, showcq, showlines) {
|
||||
var osmUrl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
var osmAttrib='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
|
||||
// If map is already initialized
|
||||
@@ -70,14 +72,37 @@ function loadMap(data, showgrid, showcq) {
|
||||
var counter = 0;
|
||||
|
||||
clicklines = [];
|
||||
$.each(data.markers, function(k, v) {
|
||||
counter++;
|
||||
$.each(data, function(k, v) {
|
||||
linecolor = 'red';
|
||||
|
||||
if (this.lat < -170) {
|
||||
this.lat = parseFloat(this.lat)+360;
|
||||
if (this.latlng2[1] < -170) {
|
||||
this.latlng2[1] = parseFloat(this.latlng2[1])+360;
|
||||
}
|
||||
if (this.latlng1[1] < -170) {
|
||||
this.latlng1[1] = parseFloat(this.latlng1[1])+360;
|
||||
}
|
||||
|
||||
var marker = L.marker([this.lat, this.lng], {icon: redIcon}, {closeOnClick: false, autoClose: false}).addTo(map);
|
||||
var marker = L.marker([this.latlng1[0], this.latlng1[1]], {icon: redIcon}, {closeOnClick: false, autoClose: false}).addTo(map);
|
||||
|
||||
var marker2 = L.marker([this.latlng2[0], this.latlng2[1]], {icon: redIcon},{closeOnClick: false, autoClose: false}).addTo(map);
|
||||
|
||||
if (showlines === "true") {
|
||||
const multiplelines = [];
|
||||
multiplelines.push(
|
||||
new L.LatLng(this.latlng1[0], this.latlng1[1]),
|
||||
new L.LatLng(this.latlng2[0], this.latlng2[1])
|
||||
)
|
||||
|
||||
const geodesic = L.geodesic(multiplelines, {
|
||||
weight: 1,
|
||||
opacity: 1,
|
||||
color: linecolor,
|
||||
wrap: false,
|
||||
steps: 100
|
||||
}).addTo(map);
|
||||
|
||||
map.addLayer(geodesic);
|
||||
}
|
||||
});
|
||||
|
||||
if (showgrid === "true") {
|
||||
@@ -102,7 +127,6 @@ function loadMap(data, showgrid, showcq) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
map.addLayer(osm);
|
||||
|
||||
var printer = L.easyPrint({
|
||||
|
||||
Reference in New Issue
Block a user