@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | |
169 | 169 | private function urshift($n, $s) { |
170 | - return ($n >= 0) ? ($n >> $s) : |
|
171 | - (($n & 0x7fffffff) >> $s) | |
|
170 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
172 | 171 | (0x40000000 >> ($s - 1)); |
173 | 172 | } |
174 | 173 | |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | //$split_input = str_split($input); |
181 | 180 | |
182 | 181 | /* Find the end of header checking for NULL bytes while doing it. */ |
183 | - $splitpos = strpos($input,':'); |
|
182 | + $splitpos = strpos($input, ':'); |
|
184 | 183 | |
185 | 184 | /* Check that end was found and body has at least one byte. */ |
186 | 185 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -190,15 +189,15 @@ discard block |
||
190 | 189 | |
191 | 190 | if ($debug) echo 'input : '.$input."\n"; |
192 | 191 | /* Save header and body. */ |
193 | - $body = substr($input,$splitpos+1,$input_len); |
|
192 | + $body = substr($input, $splitpos + 1, $input_len); |
|
194 | 193 | $body_len = strlen($body); |
195 | - $header = substr($input,0,$splitpos); |
|
194 | + $header = substr($input, 0, $splitpos); |
|
196 | 195 | //$header_len = strlen($header); |
197 | 196 | if ($debug) echo 'header : '.$header."\n"; |
198 | 197 | |
199 | 198 | /* Parse source, target and path. */ |
200 | 199 | //FLRDF0A52>APRS,qAS,LSTB |
201 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
200 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
202 | 201 | $ident = $matches[1]; |
203 | 202 | $all_elements = $matches[2]; |
204 | 203 | if ($ident == 'AIRCRAFT') { |
@@ -215,14 +214,14 @@ discard block |
||
215 | 214 | if ($debug) 'No ident'."\n"; |
216 | 215 | return false; |
217 | 216 | } |
218 | - $elements = explode(',',$all_elements); |
|
217 | + $elements = explode(',', $all_elements); |
|
219 | 218 | $source = end($elements); |
220 | 219 | $result['source'] = $source; |
221 | 220 | foreach ($elements as $element) { |
222 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
221 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
223 | 222 | //echo "ok"; |
224 | 223 | //if ($element == 'TCPIP*') return false; |
225 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
224 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
226 | 225 | if ($debug) echo 'element : '.$element."\n"; |
227 | 226 | return false; |
228 | 227 | } |
@@ -235,14 +234,14 @@ discard block |
||
235 | 234 | */ |
236 | 235 | } |
237 | 236 | |
238 | - $type = substr($body,0,1); |
|
237 | + $type = substr($body, 0, 1); |
|
239 | 238 | if ($debug) echo 'type : '.$type."\n"; |
240 | 239 | if ($type == ';') { |
241 | 240 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
242 | - $result['address'] = trim(substr($body,1,9)); |
|
241 | + $result['address'] = trim(substr($body, 1, 9)); |
|
243 | 242 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
244 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
245 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
243 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
244 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
246 | 245 | } elseif ($type == ',') { |
247 | 246 | // Invalid data or test data |
248 | 247 | return false; |
@@ -250,24 +249,24 @@ discard block |
||
250 | 249 | |
251 | 250 | // Check for Timestamp |
252 | 251 | $find = false; |
253 | - $body_parse = substr($body,1); |
|
252 | + $body_parse = substr($body, 1); |
|
254 | 253 | //echo 'Body : '.$body."\n"; |
255 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
256 | - $body_parse = substr($body_parse,10); |
|
254 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
255 | + $body_parse = substr($body_parse, 10); |
|
257 | 256 | $find = true; |
258 | 257 | //echo $body_parse."\n"; |
259 | 258 | } |
260 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
261 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
259 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
260 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
262 | 261 | $find = true; |
263 | 262 | //echo $body_parse."\n"; |
264 | 263 | } |
265 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
266 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
264 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
265 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
267 | 266 | $find = true; |
268 | 267 | //echo $body_parse."\n"; |
269 | 268 | } |
270 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
269 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
271 | 270 | $find = true; |
272 | 271 | //print_r($matches); |
273 | 272 | $timestamp = $matches[0]; |
@@ -282,19 +281,19 @@ discard block |
||
282 | 281 | // This work or not ? |
283 | 282 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
284 | 283 | } |
285 | - $body_parse = substr($body_parse,7); |
|
284 | + $body_parse = substr($body_parse, 7); |
|
286 | 285 | $result['timestamp'] = $timestamp; |
287 | 286 | //echo date('Ymd H:i:s',$timestamp); |
288 | 287 | } |
289 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
288 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
290 | 289 | $find = true; |
291 | 290 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
292 | - $body_parse = substr($body_parse,8); |
|
291 | + $body_parse = substr($body_parse, 8); |
|
293 | 292 | $result['timestamp'] = $timestamp; |
294 | 293 | //echo date('Ymd H:i:s',$timestamp); |
295 | 294 | } |
296 | 295 | //if (strlen($body_parse) > 19) { |
297 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
296 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
298 | 297 | $find = true; |
299 | 298 | // 4658.70N/00707.78Ez |
300 | 299 | //print_r(str_split($body_parse)); |
@@ -321,11 +320,11 @@ discard block |
||
321 | 320 | */ |
322 | 321 | $latitude = $lat + floatval($lat_min)/60; |
323 | 322 | $longitude = $lon + floatval($lon_min)/60; |
324 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
325 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
323 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
324 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
326 | 325 | $result['latitude'] = $latitude; |
327 | 326 | $result['longitude'] = $longitude; |
328 | - $body_parse = substr($body_parse,18); |
|
327 | + $body_parse = substr($body_parse, 18); |
|
329 | 328 | $body_parse_len = strlen($body_parse); |
330 | 329 | } |
331 | 330 | $body_parse_len = strlen($body_parse); |
@@ -357,7 +356,7 @@ discard block |
||
357 | 356 | //echo $body_parse; |
358 | 357 | //if ($type != ';' && $type != '>') { |
359 | 358 | if ($type != '') { |
360 | - $body_parse = substr($body_parse,1); |
|
359 | + $body_parse = substr($body_parse, 1); |
|
361 | 360 | $body_parse_len = strlen($body_parse); |
362 | 361 | $result['symbol_code'] = $symbol_code; |
363 | 362 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -368,16 +367,16 @@ discard block |
||
368 | 367 | //$body_parse_len = strlen($body_parse); |
369 | 368 | if ($body_parse_len >= 7) { |
370 | 369 | |
371 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
372 | - $course = substr($body_parse,0,3); |
|
370 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
371 | + $course = substr($body_parse, 0, 3); |
|
373 | 372 | $tmp_s = intval($course); |
374 | 373 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
375 | - $speed = substr($body_parse,4,3); |
|
374 | + $speed = substr($body_parse, 4, 3); |
|
376 | 375 | if ($speed != '...') { |
377 | 376 | //$result['speed'] = round($speed*1.852); |
378 | 377 | $result['speed'] = intval($speed); |
379 | 378 | } |
380 | - $body_parse = substr($body_parse,7); |
|
379 | + $body_parse = substr($body_parse, 7); |
|
381 | 380 | } |
382 | 381 | // Check PHGR, PHG, RNG |
383 | 382 | } |
@@ -387,12 +386,12 @@ discard block |
||
387 | 386 | } |
388 | 387 | */ |
389 | 388 | if (strlen($body_parse) > 0) { |
390 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
389 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
391 | 390 | $altitude = intval($matches[1]); |
392 | 391 | //$result['altitude'] = round($altitude*0.3048); |
393 | 392 | $result['altitude'] = $altitude; |
394 | 393 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
395 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
394 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
396 | 395 | } |
397 | 396 | } |
398 | 397 | |
@@ -404,13 +403,13 @@ discard block |
||
404 | 403 | */ |
405 | 404 | // DAO |
406 | 405 | |
407 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
406 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
408 | 407 | |
409 | 408 | $dao = $matches[1]; |
410 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
409 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
411 | 410 | $dao_split = str_split($dao); |
412 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
413 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
411 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
412 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
414 | 413 | |
415 | 414 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
416 | 415 | else $result['latitude'] += $lat_off; |
@@ -418,50 +417,50 @@ discard block |
||
418 | 417 | else $result['longitude'] += $lon_off; |
419 | 418 | } |
420 | 419 | |
421 | - $body_parse = substr($body_parse,6); |
|
420 | + $body_parse = substr($body_parse, 6); |
|
422 | 421 | } |
423 | 422 | //echo 'bodyparse : '.$body_parse."\n"; |
424 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
425 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
423 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
424 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
426 | 425 | } |
427 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
426 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
428 | 427 | $result['squawk'] = $matches[1]; |
429 | 428 | } |
430 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
429 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
431 | 430 | $result['aircraft_icao'] = $matches[1]; |
432 | 431 | } |
433 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
432 | + if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { |
|
434 | 433 | $result['verticalrate'] = $matches[1]; |
435 | 434 | } |
436 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
435 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
437 | 436 | $result['typeid'] = $matches[1]; |
438 | 437 | } |
439 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
438 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
440 | 439 | $result['statusid'] = $matches[1]; |
441 | 440 | } |
442 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
441 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
443 | 442 | $result['imo'] = $matches[1]; |
444 | 443 | } |
445 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
444 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
446 | 445 | $result['arrival_date'] = $matches[1]; |
447 | 446 | } |
448 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
449 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
447 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
448 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
450 | 449 | } |
451 | 450 | // OGN comment |
452 | 451 | // echo "Before OGN : ".$body_parse."\n"; |
453 | 452 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
454 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
453 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
455 | 454 | $id = $matches[1]; |
456 | 455 | //$mode = substr($id,0,2); |
457 | - $address = substr($id,2); |
|
456 | + $address = substr($id, 2); |
|
458 | 457 | //print_r($matches); |
459 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
458 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
460 | 459 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
461 | 460 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
462 | 461 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
463 | 462 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
464 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
463 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
465 | 464 | $result['aircrafttype_code'] = $aircraftType; |
466 | 465 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
467 | 466 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -478,7 +477,7 @@ discard block |
||
478 | 477 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
479 | 478 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
480 | 479 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
481 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
480 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
482 | 481 | $result['stealth'] = $stealth; |
483 | 482 | $result['address'] = $address; |
484 | 483 | } |
@@ -490,96 +489,96 @@ discard block |
||
490 | 489 | //$body_parse = substr($body_parse,1); |
491 | 490 | //$body_parse_len = strlen($body_parse); |
492 | 491 | //echo 'weather'."\n"; |
493 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
492 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
494 | 493 | $result['wind_dir'] = intval($matches[1]); |
495 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
496 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
497 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
498 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
499 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
494 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
495 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
496 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
497 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
498 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
500 | 499 | $result['wind_dir'] = intval($matches[1]); |
501 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
502 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
503 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
504 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
505 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
500 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
501 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
502 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
503 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
504 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
506 | 505 | $result['wind_dir'] = intval($matches[1]); |
507 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
508 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
509 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
510 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
506 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
507 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
508 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
509 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
511 | 510 | $result['wind_dir'] = intval($matches[1]); |
512 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
513 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
514 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
511 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
512 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
513 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
515 | 514 | } |
516 | 515 | //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
517 | 516 | //g012t088r000p000P000h38b10110 |
518 | 517 | //g011t086r000p000P000h29b10198 |
519 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
523 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
524 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
518 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
519 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
520 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
521 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
522 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
523 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
525 | 524 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
526 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
527 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
528 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
529 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
530 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
531 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
532 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
533 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
525 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
526 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
527 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
528 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
529 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
530 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
531 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
532 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
534 | 533 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
535 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
536 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
537 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
538 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
539 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
540 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
541 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
542 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
534 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
535 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
536 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
537 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
538 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
539 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
540 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
541 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
543 | 542 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
544 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
545 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
546 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
547 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
548 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
549 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
550 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
543 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
544 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
545 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
546 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
547 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
548 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
549 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
551 | 550 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
552 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
553 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
554 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
555 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
556 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
557 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
558 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
551 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
552 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
553 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
554 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
555 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
556 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
557 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
559 | 558 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
560 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
561 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
562 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
563 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
564 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
565 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
566 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
559 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
560 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
561 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
562 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
563 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
564 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
565 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
567 | 566 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
568 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
569 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
570 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
571 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
572 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
567 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
568 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
569 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
570 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
571 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
573 | 572 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
574 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
575 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
576 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
577 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
578 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
579 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
573 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
574 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
575 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
576 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
577 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
578 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
580 | 579 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
581 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
582 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
580 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
581 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
583 | 582 | } |
584 | 583 | $result['comment'] = trim($body_parse); |
585 | 584 | } |
@@ -587,42 +586,42 @@ discard block |
||
587 | 586 | |
588 | 587 | } |
589 | 588 | //} |
590 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
591 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
589 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
590 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
592 | 591 | if ($debug) print_r($result); |
593 | 592 | return $result; |
594 | 593 | } |
595 | 594 | |
596 | 595 | public function connect() { |
597 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
596 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
598 | 597 | $aprs_connect = 0; |
599 | 598 | $aprs_keep = 120; |
600 | 599 | $aprs_last_tx = time(); |
601 | 600 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
602 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
601 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
603 | 602 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
604 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
603 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
605 | 604 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
606 | 605 | else $aprs_pass = '-1'; |
607 | 606 | |
608 | - $aprs_filter = ''; |
|
607 | + $aprs_filter = ''; |
|
609 | 608 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
610 | 609 | $Common = new Common(); |
611 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
610 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
612 | 611 | if ($s !== false) { |
613 | 612 | echo 'Connected to APRS server! '."\n"; |
614 | 613 | $authstart = time(); |
615 | 614 | $this->socket = $s; |
616 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
617 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
|
618 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
615 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
616 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
617 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
619 | 618 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
620 | 619 | echo 'APRS user verified !'."\n"; |
621 | 620 | $this->connected = true; |
622 | 621 | return true; |
623 | 622 | break; |
624 | 623 | } |
625 | - if (time()-$authstart > 5) { |
|
624 | + if (time() - $authstart > 5) { |
|
626 | 625 | echo 'APRS timeout'."\n"; |
627 | 626 | break; |
628 | 627 | } |
@@ -637,7 +636,7 @@ discard block |
||
637 | 636 | public function send($data) { |
638 | 637 | global $globalDebug; |
639 | 638 | if ($this->connected === false) $this->connect(); |
640 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
639 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
641 | 640 | if ($send === FALSE) { |
642 | 641 | if ($globalDebug) echo 'Reconnect...'; |
643 | 642 | socket_close($this->socket); |
@@ -647,17 +646,17 @@ discard block |
||
647 | 646 | } |
648 | 647 | |
649 | 648 | class APRSSpotter extends APRS { |
650 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
649 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
651 | 650 | $Common = new Common(); |
652 | 651 | date_default_timezone_set('UTC'); |
653 | 652 | if ($latitude != '' && $longitude != '') { |
654 | 653 | $lat = $latitude; |
655 | 654 | $long = $longitude; |
656 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
657 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
658 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
659 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
660 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
655 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
656 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
657 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
658 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
659 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
661 | 660 | $w = $w1.$w2; |
662 | 661 | //$w = '00'; |
663 | 662 | $custom = ''; |
@@ -684,26 +683,26 @@ discard block |
||
684 | 683 | $geoid= round($GeoidClass->get($lat,$long)*3.28084,2); |
685 | 684 | $altitude_real = round($altitude_real + $geoid); |
686 | 685 | */ |
687 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
686 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
688 | 687 | } |
689 | 688 | } |
690 | 689 | } |
691 | 690 | class APRSMarine extends APRS { |
692 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
691 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
693 | 692 | $Common = new Common(); |
694 | 693 | date_default_timezone_set('UTC'); |
695 | 694 | if ($latitude != '' && $longitude != '') { |
696 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
697 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
698 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
699 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
700 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
695 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
696 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
697 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
698 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
699 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
701 | 700 | $w = $w1.$w2; |
702 | 701 | //$w = '00'; |
703 | 702 | $custom = ''; |
704 | 703 | if ($ident != '') { |
705 | 704 | if ($custom != '') $custom .= '/'; |
706 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
705 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
707 | 706 | } |
708 | 707 | if ($typeid != '') { |
709 | 708 | if ($custom != '') $custom .= '/'; |
@@ -723,11 +722,11 @@ discard block |
||
723 | 722 | } |
724 | 723 | if ($arrival_code != '') { |
725 | 724 | if ($custom != '') $custom .= '/'; |
726 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
725 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
727 | 726 | } |
728 | 727 | if ($custom != '') $custom = ' '.$custom; |
729 | 728 | $altitude = 0; |
730 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
729 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
731 | 730 | } |
732 | 731 | } |
733 | 732 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -154,65 +154,65 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
182 | 182 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | 184 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
188 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
188 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | - $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']); |
|
190 | + $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']); |
|
191 | 191 | $Marine->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
197 | 197 | } |
198 | 198 | |
199 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
199 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
200 | 200 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
201 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
201 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
202 | 202 | } else { |
203 | 203 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
204 | 204 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
205 | 205 | return ''; |
206 | 206 | } |
207 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
207 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
208 | 208 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
209 | 209 | return ''; |
210 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
210 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
211 | 211 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
212 | 212 | return ''; |
213 | 213 | } elseif (!isset($line['datetime'])) { |
214 | 214 | date_default_timezone_set('UTC'); |
215 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
215 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
216 | 216 | } else { |
217 | 217 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
218 | 218 | return ''; |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | |
221 | 221 | |
222 | 222 | if (isset($line['speed'])) { |
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
224 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
224 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
225 | 225 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
226 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
227 | 227 | if ($distance > 1000 && $distance < 10000) { |
228 | 228 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
229 | 229 | $speed = $speed*3.6; |
230 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
230 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
231 | 231 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | 235 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
236 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
237 | 237 | else unset($timediff); |
238 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
238 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
239 | 239 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
240 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
240 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
241 | 241 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
242 | 242 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
243 | 243 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | $timeelapsed = microtime(true); |
247 | 247 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
248 | 248 | $Marine = new Marine($this->db); |
249 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
250 | 250 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
251 | 251 | $Marine->db = null; |
252 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
252 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
253 | 253 | } |
254 | 254 | $this->tmd = 0; |
255 | 255 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -258,52 +258,52 @@ discard block |
||
258 | 258 | |
259 | 259 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
260 | 260 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
261 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
261 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
262 | 262 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
263 | 263 | $dataFound = true; |
264 | 264 | $this->all_tracked[$id]['time_last_coord'] = time(); |
265 | 265 | } |
266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
267 | 267 | } |
268 | 268 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
269 | 269 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
270 | 270 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
271 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
271 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
272 | 272 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
273 | 273 | $dataFound = true; |
274 | 274 | $this->all_tracked[$id]['time_last_coord'] = time(); |
275 | 275 | } |
276 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
276 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | } else if ($globalDebug && $timediff > 20) { |
280 | 280 | $this->tmd = $this->tmd + 1; |
281 | 281 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
282 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
283 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
282 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
283 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
284 | 284 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
285 | 285 | } |
286 | 286 | } |
287 | 287 | if (isset($line['last_update']) && $line['last_update'] != '') { |
288 | 288 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
289 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
289 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
290 | 290 | } |
291 | 291 | if (isset($line['format_source']) && $line['format_source'] != '') { |
292 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
293 | 293 | } |
294 | 294 | if (isset($line['source_name']) && $line['source_name'] != '') { |
295 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
296 | 296 | } |
297 | 297 | if (isset($line['status']) && $line['status'] != '') { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
299 | 299 | } |
300 | 300 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
302 | 302 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
303 | 303 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Marine = new Marine($this->db); |
306 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
306 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
307 | 307 | unset($Marine); |
308 | 308 | } |
309 | 309 | } |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
314 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if (isset($line['heading']) && $line['heading'] != '') { |
318 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
320 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
318 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
320 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
321 | 321 | //$dataFound = true; |
322 | 322 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
323 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
324 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
325 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
323 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
324 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
325 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
326 | 326 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
327 | 327 | } |
328 | 328 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
333 | 333 | $this->all_tracked[$id]['lastupdate'] = time(); |
334 | 334 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
335 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
336 | 336 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
337 | 337 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
338 | 338 | if ($globalDebug) echo "Check if vessel is already in DB..."; |
@@ -340,37 +340,37 @@ discard block |
||
340 | 340 | $MarineLive = new MarineLive($this->db); |
341 | 341 | if (isset($line['id'])) { |
342 | 342 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
343 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
344 | 344 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
345 | 345 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
347 | 347 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
348 | 348 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
349 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
349 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
350 | 350 | } else $recent_ident = ''; |
351 | - $MarineLive->db=null; |
|
351 | + $MarineLive->db = null; |
|
352 | 352 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
353 | 353 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
354 | 354 | } else $recent_ident = ''; |
355 | 355 | } else { |
356 | 356 | $recent_ident = ''; |
357 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
357 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
358 | 358 | } |
359 | 359 | //if there was no vessel with the same callsign within the last hour and go post it into the archive |
360 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
361 | 361 | { |
362 | 362 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
363 | 363 | //adds the spotter data for the archive |
364 | 364 | $highlight = ''; |
365 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
366 | 366 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
367 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
368 | 368 | $timeelapsed = microtime(true); |
369 | 369 | $Marine = new Marine($this->db); |
370 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
371 | 371 | $Marine->db = null; |
372 | 372 | if ($globalDebug && isset($result)) echo $result."\n"; |
373 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | $Stats = new Stats($this->db); |
379 | 379 | if (!empty($this->stats)) { |
380 | 380 | if ($globalDebug) echo 'Add source stats : '; |
381 | - foreach($this->stats as $date => $data) { |
|
382 | - foreach($data as $source => $sourced) { |
|
381 | + foreach ($this->stats as $date => $data) { |
|
382 | + foreach ($data as $source => $sourced) { |
|
383 | 383 | //print_r($sourced); |
384 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
385 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
384 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
385 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
386 | 386 | if (isset($sourced['msg'])) { |
387 | 387 | if (time() - $sourced['msg']['date'] > 10) { |
388 | 388 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
389 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
390 | 390 | unset($this->stats[$date][$source]['msg']); |
391 | 391 | } |
392 | 392 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
411 | 411 | $MarineLive = new MarineLive($this->db); |
412 | 412 | $MarineLive->deleteLiveMarineData(); |
413 | - $MarineLive->db=null; |
|
413 | + $MarineLive->db = null; |
|
414 | 414 | if ($globalDebug) echo " Done\n"; |
415 | 415 | } |
416 | 416 | $this->last_delete = time(); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
422 | 422 | if (isset($globalDaemon) && !$globalDaemon) { |
423 | 423 | $Marine = new Marine($this->db); |
424 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
424 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
425 | 425 | $Marine->db = null; |
426 | 426 | } |
427 | 427 | } |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | $ignoreImport = false; |
437 | 437 | |
438 | 438 | if (!$ignoreImport) { |
439 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
439 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
440 | 440 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
441 | 441 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
442 | 442 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
443 | 443 | $timeelapsed = microtime(true); |
444 | 444 | $MarineLive = new MarineLive($this->db); |
445 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
445 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
446 | 446 | $MarineLive->db = null; |
447 | 447 | if ($globalDebug) echo $result."\n"; |
448 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
448 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
452 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
453 | 453 | } |
454 | 454 | $this->all_tracked[$id]['putinarchive'] = false; |
455 | 455 | |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | $latitude = $globalCenterLatitude; |
469 | 469 | $longitude = $globalCenterLongitude; |
470 | 470 | } |
471 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
471 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
472 | 472 | } else { |
473 | 473 | $latitude = $this->source_location[$source]['latitude']; |
474 | 474 | $longitude = $this->source_location[$source]['longitude']; |
475 | 475 | } |
476 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
476 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
477 | 477 | //$stats_heading = $stats_heading%22.5; |
478 | 478 | $stats_heading = round($stats_heading/22.5); |
479 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
479 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
480 | 480 | $current_date = date('Y-m-d'); |
481 | 481 | if ($stats_heading == 16) $stats_heading = 0; |
482 | 482 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
483 | - for ($i=0;$i<=15;$i++) { |
|
483 | + for ($i = 0; $i <= 15; $i++) { |
|
484 | 484 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
485 | 485 | } |
486 | 486 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
496 | 496 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
497 | 497 | end($this->stats[$current_date][$source]['hist']); |
498 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
498 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
499 | 499 | } else $mini = 0; |
500 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
500 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
501 | 501 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
502 | 502 | } |
503 | 503 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | $this->all_tracked[$id]['lastupdate'] = time(); |
511 | 511 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
512 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
512 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
513 | 513 | //$this->del(); |
514 | 514 | |
515 | 515 |