[QRB Calc] Added some error checking and rounding of coordinates.
这个提交包含在:
		
							父节点
							
								
									831708ffc2
								
							
						
					
					
						当前提交
						0763e64777
					
				
					共有  2 个文件被更改,包括 41 次插入 和 20 次删除
				
			
		|  | @ -50,8 +50,15 @@ class Qrbcalc extends CI_Controller { | ||||||
| 		$data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base); | 		$data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base); | ||||||
| 		$data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist; | 		$data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist; | ||||||
| 		$data['bearing'] = $this->qra->get_bearing($locator1, $locator2) . "º "; | 		$data['bearing'] = $this->qra->get_bearing($locator1, $locator2) . "º "; | ||||||
| 		$data['latlng1'] = $this->qra->qra2latlong($locator1); | 		$latlng1 = $this->qra->qra2latlong($locator1); | ||||||
| 		$data['latlng2'] = $this->qra->qra2latlong($locator2); | 		$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; | ||||||
| 		header('Content-Type: application/json'); | 		header('Content-Type: application/json'); | ||||||
| 		echo json_encode($data); | 		echo json_encode($data); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -457,6 +457,9 @@ function calculateQrb(form) { | ||||||
|     let locator1 = form.locator1.value; |     let locator1 = form.locator1.value; | ||||||
|     let locator2 = form.locator2.value; |     let locator2 = form.locator2.value; | ||||||
| 
 | 
 | ||||||
|  |     $(".qrbalert").remove(); | ||||||
|  | 
 | ||||||
|  |     if (validateLocator(locator1) && validateLocator(locator2)) { | ||||||
|         $.ajax({ |         $.ajax({ | ||||||
|             url: base_url+'index.php/qrbcalc/calculate', |             url: base_url+'index.php/qrbcalc/calculate', | ||||||
|             type: 'post', |             type: 'post', | ||||||
|  | @ -474,6 +477,17 @@ function calculateQrb(form) { | ||||||
|                 newpath(html['latlng1'], html['latlng2']); |                 newpath(html['latlng1'], html['latlng2']); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |     } else { | ||||||
|  |         $('.qrbResult').html('<div class="qrbalert alert alert-danger" role="alert">Error in locators. Please check.</div>'); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function validateLocator(locator) { | ||||||
|  |     if(locator.length < 4 && !(/^[a-rA-R]{2}[0-9]{2}[a-xA-X]{0,2}[0-9]{0,2}[a-xA-X]{0,2}$/.test(locator))) { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function newpath(locator1, locator2) { | function newpath(locator1, locator2) { | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用