Ability to map gridsquares at /gridsquares/
You can now see gridsquares on the map at /gridsquares either satellites or by band
这个提交包含在:
		
							父节点
							
								
									57fecec4fc
								
							
						
					
					
						当前提交
						1734a05ded
					
				
					共有  6 个文件被更改,包括 368 次插入 和 0 次删除
				
			
		|  | @ -0,0 +1,165 @@ | ||||||
|  | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||||||
|  | 
 | ||||||
|  | /* | ||||||
|  | 	 | ||||||
|  | 	Gridsquares Controller | ||||||
|  | 		 | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | class Gridsquares extends CI_Controller { | ||||||
|  | 
 | ||||||
|  | 	public function index() { | ||||||
|  | 		$data['page_title'] = "Gridsquare Map"; | ||||||
|  | 
 | ||||||
|  | 		$this->load->view('interface_assets/header', $data); | ||||||
|  | 		$this->load->view('gridsquares/main.php'); | ||||||
|  | 		$this->load->view('interface_assets/footer'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function satellites() | ||||||
|  | 	{ | ||||||
|  | 		$this->load->model('gridsquares_model'); | ||||||
|  | 
 | ||||||
|  | 		$data['page_title'] = "Satellite Gridsquare Map"; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$array_grid_2char = array(); | ||||||
|  | 		$array_grid_4char = array(); | ||||||
|  | 
 | ||||||
|  | 		$grid_2char = ""; | ||||||
|  | 		$grid_4char = ""; | ||||||
|  | 
 | ||||||
|  | 		$query = $this->gridsquares_model->get_worked_sat_squares(); | ||||||
|  | 
 | ||||||
|  | 		if ($query->num_rows() > 0) | ||||||
|  | 		{ | ||||||
|  | 			foreach ($query->result() as $row) | ||||||
|  | 			{ | ||||||
|  | 
 | ||||||
|  | 				$grid_two = strtoupper(substr($row->SAT_SQUARE,0,2)); | ||||||
|  | 				$grid_four = strtoupper(substr($row->SAT_SQUARE,0,4)); | ||||||
|  | 
 | ||||||
|  | 				// Check if 2 Char is in array
 | ||||||
|  | 				if(!in_array($grid_two, $array_grid_2char)){ | ||||||
|  | 					array_push($array_grid_2char, $grid_two);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 				if(!in_array($grid_four, $array_grid_4char)){ | ||||||
|  | 					array_push($array_grid_4char, $grid_four);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		$query_vucc = $this->gridsquares_model->get_worked_sat_vucc_squares(); | ||||||
|  | 
 | ||||||
|  | 		if ($query_vucc->num_rows() > 0) | ||||||
|  | 		{ | ||||||
|  | 			foreach ($query_vucc->result() as $row) | ||||||
|  | 			{ | ||||||
|  | 
 | ||||||
|  | 				$grids = explode(",", $row->COL_VUCC_GRIDS); | ||||||
|  | 
 | ||||||
|  | 				foreach($grids as $key) {     | ||||||
|  | 				    $grid_two = strtoupper(substr($key,0,2)); | ||||||
|  | 					$grid_four = strtoupper(substr($key,0,4)); | ||||||
|  | 
 | ||||||
|  | 					// Check if 2 Char is in array
 | ||||||
|  | 					if(!in_array($grid_two, $array_grid_2char)){ | ||||||
|  | 						array_push($array_grid_2char, $grid_two);	 | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 					if(!in_array($grid_four, $array_grid_4char)){ | ||||||
|  | 						array_push($array_grid_4char, $grid_four);	 | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		function js_str($s) | ||||||
|  | 		{ | ||||||
|  | 		    return '"' . addcslashes($s, "\0..\37\"\\") . '"'; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		function js_array($array) | ||||||
|  | 		{ | ||||||
|  | 		    $temp = array_map('js_str', $array); | ||||||
|  | 		    return '[' . implode(',', $temp) . ']'; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$data['grid_2char'] = js_array($array_grid_2char); | ||||||
|  | 		$data['grid_4char'] = js_array($array_grid_4char); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$this->load->view('interface_assets/header', $data); | ||||||
|  | 		$this->load->view('gridsquares/index.php'); | ||||||
|  | 		$this->load->view('interface_assets/footer'); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 
 | ||||||
|  | 	public function band($band) | ||||||
|  | 	{ | ||||||
|  | 		$this->load->model('gridsquares_model'); | ||||||
|  | 
 | ||||||
|  | 		$data['page_title'] = "Gridsquare Map"; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$array_grid_2char = array(); | ||||||
|  | 		$array_grid_4char = array(); | ||||||
|  | 
 | ||||||
|  | 		$grid_2char = ""; | ||||||
|  | 		$grid_4char = ""; | ||||||
|  | 
 | ||||||
|  | 		$query = $this->gridsquares_model->get_band($band); | ||||||
|  | 
 | ||||||
|  | 		if ($query->num_rows() > 0) | ||||||
|  | 		{ | ||||||
|  | 			foreach ($query->result() as $row) | ||||||
|  | 			{ | ||||||
|  | 
 | ||||||
|  | 				$grid_two = strtoupper(substr($row->GRID_SQUARES,0,2)); | ||||||
|  | 				$grid_four = strtoupper(substr($row->GRID_SQUARES,0,4)); | ||||||
|  | 
 | ||||||
|  | 				// Check if 2 Char is in array
 | ||||||
|  | 				if(!in_array($grid_two, $array_grid_2char)){ | ||||||
|  | 					array_push($array_grid_2char, $grid_two);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 				if(!in_array($grid_four, $array_grid_4char)){ | ||||||
|  | 					array_push($array_grid_4char, $grid_four);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		function js_str($s) | ||||||
|  | 		{ | ||||||
|  | 		    return '"' . addcslashes($s, "\0..\37\"\\") . '"'; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		function js_array($array) | ||||||
|  | 		{ | ||||||
|  | 		    $temp = array_map('js_str', $array); | ||||||
|  | 		    return '[' . implode(',', $temp) . ']'; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$data['grid_2char'] = js_array($array_grid_2char); | ||||||
|  | 		$data['grid_4char'] = js_array($array_grid_4char); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		$this->load->view('interface_assets/header', $data); | ||||||
|  | 		$this->load->view('gridsquares/index.php'); | ||||||
|  | 		$this->load->view('interface_assets/footer'); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
|  | @ -0,0 +1,25 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | class Gridsquares_model extends CI_Model { | ||||||
|  | 
 | ||||||
|  |     function __construct() | ||||||
|  |     { | ||||||
|  |         // Call the Model constructor
 | ||||||
|  |         parent::__construct(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     function get_worked_sat_squares() { | ||||||
|  |         return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as SAT_SQUARE, COL_SAT_NAME FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_SAT_NAME != ""'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  |     function get_worked_sat_vucc_squares() { | ||||||
|  | 	    $this->db->select('COL_PRIMARY_KEY, COL_VUCC_GRIDS, COL_SAT_NAME'); | ||||||
|  |     	$this->db->where('COL_VUCC_GRIDS !=', ""); | ||||||
|  |     	$this->db->where('COL_SAT_NAME !=', ""); | ||||||
|  | 		return $this->db->get($this->config->item('table_name')); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  |     function get_band($band) { | ||||||
|  |         return $this->db->query('SELECT distinct substring(COL_GRIDSQUARE,1,4) as GRID_SQUARES, COL_BAND FROM '.$this->config->item('table_name').' WHERE COL_GRIDSQUARE != "" AND COL_BAND = "'.$band.'"'); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,13 @@ | ||||||
|  | <div class="container"> | ||||||
|  | 
 | ||||||
|  | 	<br> | ||||||
|  | 
 | ||||||
|  | 		<?php if($this->session->flashdata('message')) { ?>
 | ||||||
|  | 			<!-- Display Message --> | ||||||
|  | 			<div class="alert-message error"> | ||||||
|  | 			  <p><?php echo $this->session->flashdata('message'); ?></p>
 | ||||||
|  | 			</div> | ||||||
|  | 		<?php } ?>
 | ||||||
|  | 
 | ||||||
|  | 	<div id="map" style="width: 100%; height: 800px"></div> | ||||||
|  | </div> | ||||||
|  | @ -0,0 +1,18 @@ | ||||||
|  | <div class="container"> | ||||||
|  | 
 | ||||||
|  | 	<br> | ||||||
|  | 
 | ||||||
|  | 		<?php if($this->session->flashdata('message')) { ?>
 | ||||||
|  | 			<!-- Display Message --> | ||||||
|  | 			<div class="alert-message error"> | ||||||
|  | 			  <p><?php echo $this->session->flashdata('message'); ?></p>
 | ||||||
|  | 			</div> | ||||||
|  | 		<?php } ?>
 | ||||||
|  | 
 | ||||||
|  | 	<h2><?php echo $page_title; ?></h2>
 | ||||||
|  | 
 | ||||||
|  | 	<nav class="nav"> | ||||||
|  | 	  <a class="nav-link" href="<?php echo site_url('gridsquares/satellite'); ?>">Satellites</a> | ||||||
|  | 	  <a class="nav-link" href="<?php echo site_url('gridsquares/band/2m'); ?>">Band</a> | ||||||
|  | 	</nav> | ||||||
|  | </div> | ||||||
|  | @ -519,6 +519,35 @@ $(document).ready(function(){ | ||||||
| }); | }); | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
|  | <?php } ?>
 | ||||||
|  | 
 | ||||||
|  | <?php if ($this->uri->segment(1) == "gridsquares") { ?>
 | ||||||
|  | 
 | ||||||
|  | <script type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/L.MaidenheadColoured.js"></script> | ||||||
|  | 
 | ||||||
|  | <script> | ||||||
|  | 
 | ||||||
|  |   var layer = 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' | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   var map = L.map('map', { | ||||||
|  |     layers: [layer], | ||||||
|  |     center: [19, 0], | ||||||
|  |     zoom: 2 | ||||||
|  |   }); | ||||||
|  |    | ||||||
|  |   var grid_two = <?php echo $grid_2char; ?>;
 | ||||||
|  |   var grid_four = <?php echo $grid_4char; ?>;
 | ||||||
|  | 
 | ||||||
|  |   var maidenhead = L.maidenhead().addTo(map); | ||||||
|  | 
 | ||||||
|  | </script> | ||||||
| <?php } ?>
 | <?php } ?>
 | ||||||
| 
 | 
 | ||||||
|   </body> |   </body> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,118 @@ | ||||||
|  | /* | ||||||
|  |  * L.Maidenhead displays a Maidenhead Locator of lines on the map. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | L.Maidenhead = L.LayerGroup.extend({ | ||||||
|  | 
 | ||||||
|  | 	 | ||||||
|  | 	options: { | ||||||
|  | 		// Line and label color
 | ||||||
|  | 		color: 'rgba(255, 0, 0, 0.4)', | ||||||
|  | 
 | ||||||
|  | 		// Redraw on move or moveend
 | ||||||
|  | 		redraw: 'move' | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	initialize: function (options) { | ||||||
|  | 		L.LayerGroup.prototype.initialize.call(this); | ||||||
|  | 		L.Util.setOptions(this, options); | ||||||
|  | 
 | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	onAdd: function (map) { | ||||||
|  | 		this._map = map; | ||||||
|  | 		var grid = this.redraw(); | ||||||
|  | 		this._map.on('viewreset '+ this.options.redraw, function () { | ||||||
|  | 			grid.redraw(); | ||||||
|  | 		}); | ||||||
|  | 
 | ||||||
|  | 		this.eachLayer(map.addLayer, map); | ||||||
|  | 	}, | ||||||
|  | 	 | ||||||
|  | 	onRemove: function (map) { | ||||||
|  | 		// remove layer listeners and elements
 | ||||||
|  | 		map.off('viewreset '+ this.options.redraw, this.map); | ||||||
|  | 		this.eachLayer(this.removeLayer, this); | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	redraw: function () { | ||||||
|  | 		var d3 =         new Array(20,10,10,10,10,10,1 ,1 ,1 ,1 ,1/24,1/24,1/24,1/24,1/24,1/240,1/240,1/240,1/240,1/240/24,1/240/24 ); | ||||||
|  | 		var lat_cor =    new Array(0 ,8 ,8 ,8 ,10,14,6 ,8 ,8 ,8 ,1.4 ,2.5 ,3   ,3.5 ,4   ,4    ,3.5  ,3.5  ,3    ,1.8     ,1.6      ); | ||||||
|  | 		var bounds = map.getBounds(); | ||||||
|  | 		var zoom = map.getZoom(); | ||||||
|  | 		var unit = d3[zoom]; | ||||||
|  | 		var lcor = lat_cor[zoom]; | ||||||
|  | 		var w = bounds.getWest(); | ||||||
|  | 		var e = bounds.getEast(); | ||||||
|  | 		var n = bounds.getNorth(); | ||||||
|  | 		var s = bounds.getSouth(); | ||||||
|  | 		if (zoom==1) {var c = 2;} else {var c = 0.1;} | ||||||
|  | 		if (n > 85) n = 85; | ||||||
|  | 		if (s < -85) s = -85; | ||||||
|  | 		var left = Math.floor(w/(unit*2))*(unit*2); | ||||||
|  | 		var right = Math.ceil(e/(unit*2))*(unit*2); | ||||||
|  | 		var top = Math.ceil(n/unit)*unit; | ||||||
|  | 		var bottom = Math.floor(s/unit)*unit; | ||||||
|  | 		this.eachLayer(this.removeLayer, this); | ||||||
|  | 		for (var lon = left; lon < right; lon += (unit*2)) { | ||||||
|  | 			for (var lat = bottom; lat < top; lat += unit) { | ||||||
|  | 			var bounds = [[lat,lon],[lat+unit,lon+(unit*2)]]; | ||||||
|  | 			if(grid_two.includes(this._getLocator(lon,lat)) || grid_four.includes(this._getLocator(lon,lat))) { | ||||||
|  | 				this.addLayer(L.rectangle(bounds, {color: this.options.color, weight: 1, fillOpacity: 0.6, fill:true, interactive: false})); | ||||||
|  | 			} else { | ||||||
|  | 				this.addLayer(L.rectangle(bounds, {color: this.options.color, weight: 1, fill:false, interactive: false}));	 | ||||||
|  | 			} | ||||||
|  | 			//var pont = map.latLngToLayerPoint([lat,lon]);
 | ||||||
|  | 			//console.log(pont.x);
 | ||||||
|  | 			this.addLayer(this._getLabel(lon+unit-(unit/lcor),lat+(unit/2)+(unit/lcor*c))); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return this; | ||||||
|  | 	}, | ||||||
|  |     	 | ||||||
|  | 	_getLabel: function(lon,lat) { | ||||||
|  | 	  var title_size = new Array(0 ,10,12,16,20,26,12,16,24,36,12  ,14  ,20  ,36  ,60  ,12   ,20   ,36   ,60   ,12      ,24       ); | ||||||
|  | 	  var zoom = map.getZoom(); | ||||||
|  | 	  var size = title_size[zoom]+'px'; | ||||||
|  | 	  var title = '<span style="cursor: default;"><font style="color:'+this.options.color+'; font-size:'+size+'; font-weight: 900; ">' + this._getLocator(lon,lat) + '</font></span>'; | ||||||
|  |       var myIcon = L.divIcon({className: 'my-div-icon', html: title}); | ||||||
|  |       var marker = L.marker([lat,lon], {icon: myIcon}, clickable=false); | ||||||
|  |       return marker; | ||||||
|  | 	}, | ||||||
|  | 	 | ||||||
|  | 	_getLocator: function(lon,lat) { | ||||||
|  | 	  var ydiv_arr=new Array(10, 1, 1/24, 1/240, 1/240/24); | ||||||
|  | 	  var d1 = "ABCDEFGHIJKLMNOPQR".split(""); | ||||||
|  | 	  var d2 = "ABCDEFGHIJKLMNOPQRSTUVWX".split(""); | ||||||
|  | 	  var d4 =         new Array(0 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,3   ,3   ,3   ,3   ,3   ,4    ,4    ,4    ,4    ,5       ,5        ); | ||||||
|  |       var locator = ""; | ||||||
|  |       var x = lon; | ||||||
|  |       var y = lat; | ||||||
|  |       var precision = d4[map.getZoom()]; | ||||||
|  |       while (x < -180) {x += 360;} | ||||||
|  |       while (x > 180) {x -=360;} | ||||||
|  |       x = x + 180; | ||||||
|  |       y = y + 90; | ||||||
|  |       locator = locator + d1[Math.floor(x/20)] + d1[Math.floor(y/10)]; | ||||||
|  |       for (var i=0; i<4; i=i+1) { | ||||||
|  | 		if (precision > i+1) { | ||||||
|  |         rlon = x%(ydiv_arr[i]*2); | ||||||
|  |         rlat = y%(ydiv_arr[i]); | ||||||
|  | 			if ((i%2)==0) { | ||||||
|  | 				locator += Math.floor(rlon/(ydiv_arr[i+1]*2)) +""+ Math.floor(rlat/(ydiv_arr[i+1])); | ||||||
|  | 			} else { | ||||||
|  | 				locator += d2[Math.floor(rlon/(ydiv_arr[i+1]*2))] +""+ d2[Math.floor(rlat/(ydiv_arr[i+1]))];	 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	  }   | ||||||
|  |       return locator; | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  |    | ||||||
|  | 	 | ||||||
|  | 
 | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | L.maidenhead = function (options) { | ||||||
|  | 	return new L.Maidenhead(options); | ||||||
|  | }; | ||||||
		正在加载…
	
		在新工单中引用