@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Get SQL query part for filter used |
| 17 | 17 | * @param Array $filter the filter |
| 18 | - * @return Array the SQL part |
|
| 18 | + * @return string the SQL part |
|
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -552,25 +552,6 @@ discard block |
||
| 552 | 552 | * |
| 553 | 553 | * @param String $fammarine_id the ID |
| 554 | 554 | * @param String $ident the marine ident |
| 555 | - * @param String $departure_airport_icao the departure airport |
|
| 556 | - * @param String $arrival_airport_icao the arrival airport |
|
| 557 | - * @param String $latitude latitude of flight |
|
| 558 | - * @param String $longitude latitude of flight |
|
| 559 | - * @param String $waypoints waypoints of flight |
|
| 560 | - * @param String $heading heading of flight |
|
| 561 | - * @param String $groundspeed speed of flight |
|
| 562 | - * @param String $date date of flight |
|
| 563 | - * @param String $departure_airport_time departure time of flight |
|
| 564 | - * @param String $arrival_airport_time arrival time of flight |
|
| 565 | - * @param String $squawk squawk code of flight |
|
| 566 | - * @param String $route_stop route stop of flight |
|
| 567 | - * @param String $highlight highlight or not |
|
| 568 | - * @param String $ModeS ModesS code of flight |
|
| 569 | - * @param String $registration registration code of flight |
|
| 570 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 571 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 572 | - * @param String $verticalrate vertival rate of flight |
|
| 573 | - * @return String success or false |
|
| 574 | 555 | */ |
| 575 | 556 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$status = '',$format_source = '', $source_name = '') |
| 576 | 557 | { |
@@ -1440,7 +1421,7 @@ discard block |
||
| 1440 | 1421 | /** |
| 1441 | 1422 | * Parses the direction degrees to working |
| 1442 | 1423 | * |
| 1443 | - * @param Float $direction the direction in degrees |
|
| 1424 | + * @param integer $direction the direction in degrees |
|
| 1444 | 1425 | * @return Array the direction information |
| 1445 | 1426 | * |
| 1446 | 1427 | */ |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | |
| 21 | 21 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Executes the SQL statements to get the spotter information |
|
| 84 | - * |
|
| 85 | - * @param String $query the SQL query |
|
| 86 | - * @param Array $params parameter of the query |
|
| 87 | - * @param String $limitQuery the limit query |
|
| 88 | - * @return Array the spotter information |
|
| 89 | - * |
|
| 90 | - */ |
|
| 83 | + * Executes the SQL statements to get the spotter information |
|
| 84 | + * |
|
| 85 | + * @param String $query the SQL query |
|
| 86 | + * @param Array $params parameter of the query |
|
| 87 | + * @param String $limitQuery the limit query |
|
| 88 | + * @return Array the spotter information |
|
| 89 | + * |
|
| 90 | + */ |
|
| 91 | 91 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 92 | 92 | { |
| 93 | 93 | date_default_timezone_set('UTC'); |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * Gets all the spotter information based on the latest data entry |
|
| 203 | - * |
|
| 204 | - * @return Array the spotter information |
|
| 205 | - * |
|
| 206 | - */ |
|
| 202 | + * Gets all the spotter information based on the latest data entry |
|
| 203 | + * |
|
| 204 | + * @return Array the spotter information |
|
| 205 | + * |
|
| 206 | + */ |
|
| 207 | 207 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 208 | 208 | { |
| 209 | 209 | global $global_query; |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | - * Gets all the spotter information based on the callsign |
|
| 265 | - * |
|
| 266 | - * @return Array the spotter information |
|
| 267 | - * |
|
| 268 | - */ |
|
| 264 | + * Gets all the spotter information based on the callsign |
|
| 265 | + * |
|
| 266 | + * @return Array the spotter information |
|
| 267 | + * |
|
| 268 | + */ |
|
| 269 | 269 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 270 | 270 | { |
| 271 | 271 | global $global_query; |
@@ -376,12 +376,12 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | - * Gets all source name |
|
| 380 | - * |
|
| 381 | - * @param String type format of source |
|
| 382 | - * @return Array list of source name |
|
| 383 | - * |
|
| 384 | - */ |
|
| 379 | + * Gets all source name |
|
| 380 | + * |
|
| 381 | + * @param String type format of source |
|
| 382 | + * @return Array list of source name |
|
| 383 | + * |
|
| 384 | + */ |
|
| 385 | 385 | public function getAllSourceName($type = '',$filters = array()) |
| 386 | 386 | { |
| 387 | 387 | $filter_query = $this->getFilter($filters,true,true); |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | /** |
| 414 | - * Gets a list of all idents/callsigns |
|
| 415 | - * |
|
| 416 | - * @return Array list of ident/callsign names |
|
| 417 | - * |
|
| 418 | - */ |
|
| 414 | + * Gets a list of all idents/callsigns |
|
| 415 | + * |
|
| 416 | + * @return Array list of ident/callsign names |
|
| 417 | + * |
|
| 418 | + */ |
|
| 419 | 419 | public function getAllIdents($filters = array()) |
| 420 | 420 | { |
| 421 | 421 | $filter_query = $this->getFilter($filters,true,true); |
@@ -439,11 +439,11 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
| 442 | - * Gets all info from a mmsi |
|
| 443 | - * |
|
| 444 | - * @return Array list of mmsi info |
|
| 445 | - * |
|
| 446 | - */ |
|
| 442 | + * Gets all info from a mmsi |
|
| 443 | + * |
|
| 444 | + * @return Array list of mmsi info |
|
| 445 | + * |
|
| 446 | + */ |
|
| 447 | 447 | public function getIdentity($mmsi) |
| 448 | 448 | { |
| 449 | 449 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -500,18 +500,18 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | |
| 502 | 502 | /** |
| 503 | - * Update ident tracker data |
|
| 504 | - * |
|
| 505 | - * @param String $fammarine_id the ID |
|
| 506 | - * @param String $ident the marine ident |
|
| 507 | - * @return String success or false |
|
| 508 | - * |
|
| 509 | - */ |
|
| 503 | + * Update ident tracker data |
|
| 504 | + * |
|
| 505 | + * @param String $fammarine_id the ID |
|
| 506 | + * @param String $ident the marine ident |
|
| 507 | + * @return String success or false |
|
| 508 | + * |
|
| 509 | + */ |
|
| 510 | 510 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 511 | 511 | { |
| 512 | 512 | |
| 513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 514 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 515 | 515 | |
| 516 | 516 | try { |
| 517 | 517 | $sth = $this->db->prepare($query); |
@@ -524,17 +524,17 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | } |
| 526 | 526 | /** |
| 527 | - * Update latest marine data |
|
| 528 | - * |
|
| 529 | - * @param String $fammarine_id the ID |
|
| 530 | - * @param String $ident the marine ident |
|
| 531 | - * @return String success or false |
|
| 532 | - * |
|
| 533 | - */ |
|
| 527 | + * Update latest marine data |
|
| 528 | + * |
|
| 529 | + * @param String $fammarine_id the ID |
|
| 530 | + * @param String $ident the marine ident |
|
| 531 | + * @return String success or false |
|
| 532 | + * |
|
| 533 | + */ |
|
| 534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 535 | 535 | { |
| 536 | 536 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 537 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 538 | 538 | |
| 539 | 539 | try { |
| 540 | 540 | $sth = $this->db->prepare($query); |
@@ -548,30 +548,30 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | /** |
| 551 | - * Adds a new spotter data |
|
| 552 | - * |
|
| 553 | - * @param String $fammarine_id the ID |
|
| 554 | - * @param String $ident the marine ident |
|
| 555 | - * @param String $departure_airport_icao the departure airport |
|
| 556 | - * @param String $arrival_airport_icao the arrival airport |
|
| 557 | - * @param String $latitude latitude of flight |
|
| 558 | - * @param String $longitude latitude of flight |
|
| 559 | - * @param String $waypoints waypoints of flight |
|
| 560 | - * @param String $heading heading of flight |
|
| 561 | - * @param String $groundspeed speed of flight |
|
| 562 | - * @param String $date date of flight |
|
| 563 | - * @param String $departure_airport_time departure time of flight |
|
| 564 | - * @param String $arrival_airport_time arrival time of flight |
|
| 565 | - * @param String $squawk squawk code of flight |
|
| 566 | - * @param String $route_stop route stop of flight |
|
| 567 | - * @param String $highlight highlight or not |
|
| 568 | - * @param String $ModeS ModesS code of flight |
|
| 569 | - * @param String $registration registration code of flight |
|
| 570 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 571 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 572 | - * @param String $verticalrate vertival rate of flight |
|
| 573 | - * @return String success or false |
|
| 574 | - */ |
|
| 551 | + * Adds a new spotter data |
|
| 552 | + * |
|
| 553 | + * @param String $fammarine_id the ID |
|
| 554 | + * @param String $ident the marine ident |
|
| 555 | + * @param String $departure_airport_icao the departure airport |
|
| 556 | + * @param String $arrival_airport_icao the arrival airport |
|
| 557 | + * @param String $latitude latitude of flight |
|
| 558 | + * @param String $longitude latitude of flight |
|
| 559 | + * @param String $waypoints waypoints of flight |
|
| 560 | + * @param String $heading heading of flight |
|
| 561 | + * @param String $groundspeed speed of flight |
|
| 562 | + * @param String $date date of flight |
|
| 563 | + * @param String $departure_airport_time departure time of flight |
|
| 564 | + * @param String $arrival_airport_time arrival time of flight |
|
| 565 | + * @param String $squawk squawk code of flight |
|
| 566 | + * @param String $route_stop route stop of flight |
|
| 567 | + * @param String $highlight highlight or not |
|
| 568 | + * @param String $ModeS ModesS code of flight |
|
| 569 | + * @param String $registration registration code of flight |
|
| 570 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 571 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 572 | + * @param String $verticalrate vertival rate of flight |
|
| 573 | + * @return String success or false |
|
| 574 | + */ |
|
| 575 | 575 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$status = '',$format_source = '', $source_name = '') |
| 576 | 576 | { |
| 577 | 577 | global $globalURL; |
@@ -655,16 +655,16 @@ discard block |
||
| 655 | 655 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 656 | 656 | $status = filter_var($status,FILTER_SANITIZE_STRING); |
| 657 | 657 | |
| 658 | - if ($latitude == '' && $longitude == '') { |
|
| 659 | - $latitude = 0; |
|
| 660 | - $longitude = 0; |
|
| 661 | - } |
|
| 662 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 663 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 664 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status) |
|
| 658 | + if ($latitude == '' && $longitude == '') { |
|
| 659 | + $latitude = 0; |
|
| 660 | + $longitude = 0; |
|
| 661 | + } |
|
| 662 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 663 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 664 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status) |
|
| 665 | 665 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status)"; |
| 666 | 666 | |
| 667 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status); |
|
| 667 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status); |
|
| 668 | 668 | |
| 669 | 669 | try { |
| 670 | 670 | |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $sth->execute($query_values); |
| 673 | 673 | $this->db = null; |
| 674 | 674 | } catch (PDOException $e) { |
| 675 | - return "error : ".$e->getMessage(); |
|
| 675 | + return "error : ".$e->getMessage(); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | return "success"; |
@@ -681,11 +681,11 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | /** |
| 684 | - * Gets the aircraft ident within the last hour |
|
| 685 | - * |
|
| 686 | - * @return String the ident |
|
| 687 | - * |
|
| 688 | - */ |
|
| 684 | + * Gets the aircraft ident within the last hour |
|
| 685 | + * |
|
| 686 | + * @return String the ident |
|
| 687 | + * |
|
| 688 | + */ |
|
| 689 | 689 | public function getIdentFromLastHour($ident) |
| 690 | 690 | { |
| 691 | 691 | global $globalDBdriver, $globalTimezone; |
@@ -701,11 +701,11 @@ discard block |
||
| 701 | 701 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 702 | 702 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 703 | 703 | $query_data = array(':ident' => $ident); |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | 706 | $sth = $this->db->prepare($query); |
| 707 | 707 | $sth->execute($query_data); |
| 708 | - $ident_result=''; |
|
| 708 | + $ident_result=''; |
|
| 709 | 709 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 710 | 710 | { |
| 711 | 711 | $ident_result = $row['ident']; |
@@ -716,11 +716,11 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | |
| 718 | 718 | /** |
| 719 | - * Gets the aircraft data from the last 20 seconds |
|
| 720 | - * |
|
| 721 | - * @return Array the spotter data |
|
| 722 | - * |
|
| 723 | - */ |
|
| 719 | + * Gets the aircraft data from the last 20 seconds |
|
| 720 | + * |
|
| 721 | + * @return Array the spotter data |
|
| 722 | + * |
|
| 723 | + */ |
|
| 724 | 724 | public function getRealTimeData($q = '') |
| 725 | 725 | { |
| 726 | 726 | global $globalDBdriver; |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Gets all number of flight over countries |
|
| 762 | - * |
|
| 763 | - * @return Array the airline country list |
|
| 764 | - * |
|
| 765 | - */ |
|
| 761 | + * Gets all number of flight over countries |
|
| 762 | + * |
|
| 763 | + * @return Array the airline country list |
|
| 764 | + * |
|
| 765 | + */ |
|
| 766 | 766 | /* |
| 767 | 767 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 768 | 768 | { |
@@ -813,11 +813,11 @@ discard block |
||
| 813 | 813 | |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Gets all callsigns that have flown over |
|
| 817 | - * |
|
| 818 | - * @return Array the callsign list |
|
| 819 | - * |
|
| 820 | - */ |
|
| 816 | + * Gets all callsigns that have flown over |
|
| 817 | + * |
|
| 818 | + * @return Array the callsign list |
|
| 819 | + * |
|
| 820 | + */ |
|
| 821 | 821 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 822 | 822 | { |
| 823 | 823 | global $globalDBdriver; |
@@ -884,11 +884,11 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | |
| 886 | 886 | /** |
| 887 | - * Counts all dates |
|
| 888 | - * |
|
| 889 | - * @return Array the date list |
|
| 890 | - * |
|
| 891 | - */ |
|
| 887 | + * Counts all dates |
|
| 888 | + * |
|
| 889 | + * @return Array the date list |
|
| 890 | + * |
|
| 891 | + */ |
|
| 892 | 892 | public function countAllDates($filters = array()) |
| 893 | 893 | { |
| 894 | 894 | global $globalTimezone, $globalDBdriver; |
@@ -934,11 +934,11 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | /** |
| 937 | - * Counts all dates during the last 7 days |
|
| 938 | - * |
|
| 939 | - * @return Array the date list |
|
| 940 | - * |
|
| 941 | - */ |
|
| 937 | + * Counts all dates during the last 7 days |
|
| 938 | + * |
|
| 939 | + * @return Array the date list |
|
| 940 | + * |
|
| 941 | + */ |
|
| 942 | 942 | public function countAllDatesLast7Days($filters = array()) |
| 943 | 943 | { |
| 944 | 944 | global $globalTimezone, $globalDBdriver; |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | $query .= " GROUP BY date_name |
| 961 | 961 | ORDER BY date_name ASC"; |
| 962 | 962 | $query_data = array(':offset' => $offset); |
| 963 | - } |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | 965 | $sth = $this->db->prepare($query); |
| 966 | 966 | $sth->execute($query_data); |
@@ -980,11 +980,11 @@ discard block |
||
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | - * Counts all dates during the last month |
|
| 984 | - * |
|
| 985 | - * @return Array the date list |
|
| 986 | - * |
|
| 987 | - */ |
|
| 983 | + * Counts all dates during the last month |
|
| 984 | + * |
|
| 985 | + * @return Array the date list |
|
| 986 | + * |
|
| 987 | + */ |
|
| 988 | 988 | public function countAllDatesLastMonth($filters = array()) |
| 989 | 989 | { |
| 990 | 990 | global $globalTimezone, $globalDBdriver; |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | $query .= " GROUP BY date_name |
| 1007 | 1007 | ORDER BY date_name ASC"; |
| 1008 | 1008 | $query_data = array(':offset' => $offset); |
| 1009 | - } |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | 1011 | $sth = $this->db->prepare($query); |
| 1012 | 1012 | $sth->execute($query_data); |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | |
| 1030 | 1030 | /** |
| 1031 | - * Counts all month |
|
| 1032 | - * |
|
| 1033 | - * @return Array the month list |
|
| 1034 | - * |
|
| 1035 | - */ |
|
| 1031 | + * Counts all month |
|
| 1032 | + * |
|
| 1033 | + * @return Array the month list |
|
| 1034 | + * |
|
| 1035 | + */ |
|
| 1036 | 1036 | public function countAllMonths($filters = array()) |
| 1037 | 1037 | { |
| 1038 | 1038 | global $globalTimezone, $globalDBdriver; |
@@ -1077,11 +1077,11 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | 1079 | /** |
| 1080 | - * Counts all dates during the last year |
|
| 1081 | - * |
|
| 1082 | - * @return Array the date list |
|
| 1083 | - * |
|
| 1084 | - */ |
|
| 1080 | + * Counts all dates during the last year |
|
| 1081 | + * |
|
| 1082 | + * @return Array the date list |
|
| 1083 | + * |
|
| 1084 | + */ |
|
| 1085 | 1085 | public function countAllMonthsLastYear($filters) |
| 1086 | 1086 | { |
| 1087 | 1087 | global $globalTimezone, $globalDBdriver; |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $query .= " GROUP BY year_name, month_name |
| 1104 | 1104 | ORDER BY year_name, month_name ASC"; |
| 1105 | 1105 | $query_data = array(':offset' => $offset); |
| 1106 | - } |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | 1108 | $sth = $this->db->prepare($query); |
| 1109 | 1109 | $sth->execute($query_data); |
@@ -1126,11 +1126,11 @@ discard block |
||
| 1126 | 1126 | |
| 1127 | 1127 | |
| 1128 | 1128 | /** |
| 1129 | - * Counts all hours |
|
| 1130 | - * |
|
| 1131 | - * @return Array the hour list |
|
| 1132 | - * |
|
| 1133 | - */ |
|
| 1129 | + * Counts all hours |
|
| 1130 | + * |
|
| 1131 | + * @return Array the hour list |
|
| 1132 | + * |
|
| 1133 | + */ |
|
| 1134 | 1134 | public function countAllHours($orderby,$filters = array()) |
| 1135 | 1135 | { |
| 1136 | 1136 | global $globalTimezone, $globalDBdriver; |
@@ -1193,11 +1193,11 @@ discard block |
||
| 1193 | 1193 | |
| 1194 | 1194 | |
| 1195 | 1195 | /** |
| 1196 | - * Counts all hours by date |
|
| 1197 | - * |
|
| 1198 | - * @return Array the hour list |
|
| 1199 | - * |
|
| 1200 | - */ |
|
| 1196 | + * Counts all hours by date |
|
| 1197 | + * |
|
| 1198 | + * @return Array the hour list |
|
| 1199 | + * |
|
| 1200 | + */ |
|
| 1201 | 1201 | public function countAllHoursByDate($date, $filters = array()) |
| 1202 | 1202 | { |
| 1203 | 1203 | global $globalTimezone, $globalDBdriver; |
@@ -1241,11 +1241,11 @@ discard block |
||
| 1241 | 1241 | |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
| 1244 | - * Counts all hours by a ident/callsign |
|
| 1245 | - * |
|
| 1246 | - * @return Array the hour list |
|
| 1247 | - * |
|
| 1248 | - */ |
|
| 1244 | + * Counts all hours by a ident/callsign |
|
| 1245 | + * |
|
| 1246 | + * @return Array the hour list |
|
| 1247 | + * |
|
| 1248 | + */ |
|
| 1249 | 1249 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1250 | 1250 | { |
| 1251 | 1251 | global $globalTimezone, $globalDBdriver; |
@@ -1290,11 +1290,11 @@ discard block |
||
| 1290 | 1290 | |
| 1291 | 1291 | |
| 1292 | 1292 | /** |
| 1293 | - * Counts all flights that have flown over |
|
| 1294 | - * |
|
| 1295 | - * @return Integer the number of flights |
|
| 1296 | - * |
|
| 1297 | - */ |
|
| 1293 | + * Counts all flights that have flown over |
|
| 1294 | + * |
|
| 1295 | + * @return Integer the number of flights |
|
| 1296 | + * |
|
| 1297 | + */ |
|
| 1298 | 1298 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
| 1299 | 1299 | { |
| 1300 | 1300 | global $globalDBdriver; |
@@ -1329,11 +1329,11 @@ discard block |
||
| 1329 | 1329 | |
| 1330 | 1330 | |
| 1331 | 1331 | /** |
| 1332 | - * Counts all hours of today |
|
| 1333 | - * |
|
| 1334 | - * @return Array the hour list |
|
| 1335 | - * |
|
| 1336 | - */ |
|
| 1332 | + * Counts all hours of today |
|
| 1333 | + * |
|
| 1334 | + * @return Array the hour list |
|
| 1335 | + * |
|
| 1336 | + */ |
|
| 1337 | 1337 | public function countAllHoursFromToday($filters = array()) |
| 1338 | 1338 | { |
| 1339 | 1339 | global $globalTimezone, $globalDBdriver; |
@@ -1373,12 +1373,12 @@ discard block |
||
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | |
| 1376 | - /** |
|
| 1377 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1378 | - * |
|
| 1379 | - * @return Integer the Barrie Spotter ID |
|
| 1376 | + /** |
|
| 1377 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1378 | + * |
|
| 1379 | + * @return Integer the Barrie Spotter ID |
|
| 1380 | 1380 | q * |
| 1381 | - */ |
|
| 1381 | + */ |
|
| 1382 | 1382 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1383 | 1383 | { |
| 1384 | 1384 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1399,13 +1399,13 @@ discard block |
||
| 1399 | 1399 | |
| 1400 | 1400 | |
| 1401 | 1401 | /** |
| 1402 | - * Parses a date string |
|
| 1403 | - * |
|
| 1404 | - * @param String $dateString the date string |
|
| 1405 | - * @param String $timezone the timezone of a user |
|
| 1406 | - * @return Array the time information |
|
| 1407 | - * |
|
| 1408 | - */ |
|
| 1402 | + * Parses a date string |
|
| 1403 | + * |
|
| 1404 | + * @param String $dateString the date string |
|
| 1405 | + * @param String $timezone the timezone of a user |
|
| 1406 | + * @return Array the time information |
|
| 1407 | + * |
|
| 1408 | + */ |
|
| 1409 | 1409 | public function parseDateString($dateString, $timezone = '') |
| 1410 | 1410 | { |
| 1411 | 1411 | $time_array = array(); |
@@ -1438,12 +1438,12 @@ discard block |
||
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | /** |
| 1441 | - * Parses the direction degrees to working |
|
| 1442 | - * |
|
| 1443 | - * @param Float $direction the direction in degrees |
|
| 1444 | - * @return Array the direction information |
|
| 1445 | - * |
|
| 1446 | - */ |
|
| 1441 | + * Parses the direction degrees to working |
|
| 1442 | + * |
|
| 1443 | + * @param Float $direction the direction in degrees |
|
| 1444 | + * @return Array the direction information |
|
| 1445 | + * |
|
| 1446 | + */ |
|
| 1447 | 1447 | public function parseDirection($direction = 0) |
| 1448 | 1448 | { |
| 1449 | 1449 | if ($direction == '') $direction = 0; |
@@ -1522,12 +1522,12 @@ discard block |
||
| 1522 | 1522 | |
| 1523 | 1523 | |
| 1524 | 1524 | /** |
| 1525 | - * Gets Country from latitude/longitude |
|
| 1526 | - * |
|
| 1527 | - * @param Float $latitude latitute of the flight |
|
| 1528 | - * @param Float $longitude longitute of the flight |
|
| 1529 | - * @return String the countrie |
|
| 1530 | - */ |
|
| 1525 | + * Gets Country from latitude/longitude |
|
| 1526 | + * |
|
| 1527 | + * @param Float $latitude latitute of the flight |
|
| 1528 | + * @param Float $longitude longitute of the flight |
|
| 1529 | + * @return String the countrie |
|
| 1530 | + */ |
|
| 1531 | 1531 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1532 | 1532 | { |
| 1533 | 1533 | global $globalDBdriver, $globalDebug; |
@@ -1564,11 +1564,11 @@ discard block |
||
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | /** |
| 1567 | - * Gets Country from iso2 |
|
| 1568 | - * |
|
| 1569 | - * @param String $iso2 ISO2 country code |
|
| 1570 | - * @return String the countrie |
|
| 1571 | - */ |
|
| 1567 | + * Gets Country from iso2 |
|
| 1568 | + * |
|
| 1569 | + * @param String $iso2 ISO2 country code |
|
| 1570 | + * @return String the countrie |
|
| 1571 | + */ |
|
| 1572 | 1572 | public function getCountryFromISO2($iso2) |
| 1573 | 1573 | { |
| 1574 | 1574 | global $globalDBdriver, $globalDebug; |
@@ -1597,12 +1597,12 @@ discard block |
||
| 1597 | 1597 | |
| 1598 | 1598 | |
| 1599 | 1599 | /** |
| 1600 | - * Gets the short url from bit.ly |
|
| 1601 | - * |
|
| 1602 | - * @param String $url the full url |
|
| 1603 | - * @return String the bit.ly url |
|
| 1604 | - * |
|
| 1605 | - */ |
|
| 1600 | + * Gets the short url from bit.ly |
|
| 1601 | + * |
|
| 1602 | + * @param String $url the full url |
|
| 1603 | + * @return String the bit.ly url |
|
| 1604 | + * |
|
| 1605 | + */ |
|
| 1606 | 1606 | public function getBitlyURL($url) |
| 1607 | 1607 | { |
| 1608 | 1608 | global $globalBitlyAccessToken; |
@@ -29,31 +29,31 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | private function make_latf($temp) { // unsigned long |
| 31 | 31 | $flat = 0.0; // float |
| 32 | - $temp = $temp & 0x07FFFFFF; |
|
| 33 | - if ($temp & 0x04000000) { |
|
| 34 | - $temp = $temp ^ 0x07FFFFFF; |
|
| 32 | + $temp = $temp&0x07FFFFFF; |
|
| 33 | + if ($temp&0x04000000) { |
|
| 34 | + $temp = $temp^0x07FFFFFF; |
|
| 35 | 35 | $temp += 1; |
| 36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
| 37 | 37 | $flat *= -1.0; |
| 38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
| 38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
| 39 | 39 | return $flat; // float |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | private function make_lonf($temp) { // unsigned long |
| 43 | 43 | $flon = 0.0; // float |
| 44 | - $temp = $temp & 0x0FFFFFFF; |
|
| 45 | - if ($temp & 0x08000000) { |
|
| 46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
| 44 | + $temp = $temp&0x0FFFFFFF; |
|
| 45 | + if ($temp&0x08000000) { |
|
| 46 | + $temp = $temp^0x0FFFFFFF; |
|
| 47 | 47 | $temp += 1; |
| 48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
| 49 | 49 | $flon *= -1.0; |
| 50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
| 50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
| 51 | 51 | return $flon; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function ascii_2_dec($chr) { |
| 55 | - $dec=ord($chr);//get decimal ascii code |
|
| 56 | - $hex=dechex($dec);//convert decimal to hex |
|
| 55 | + $dec = ord($chr); //get decimal ascii code |
|
| 56 | + $hex = dechex($dec); //convert decimal to hex |
|
| 57 | 57 | return ($dec); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | //only process in the following range: 48-87, 96-119 |
| 73 | 73 | if ($ascii < 48) { } |
| 74 | 74 | else { |
| 75 | - if($ascii>119) { } |
|
| 75 | + if ($ascii > 119) { } |
|
| 76 | 76 | else { |
| 77 | - if ($ascii>87 && $ascii<96) ; |
|
| 77 | + if ($ascii > 87 && $ascii < 96); |
|
| 78 | 78 | else { |
| 79 | - $ascii=$ascii+40; |
|
| 80 | - if ($ascii>128){ |
|
| 81 | - $ascii=$ascii+32; |
|
| 79 | + $ascii = $ascii + 40; |
|
| 80 | + if ($ascii > 128) { |
|
| 81 | + $ascii = $ascii + 32; |
|
| 82 | 82 | } else { |
| 83 | - $ascii=$ascii+40; |
|
| 83 | + $ascii = $ascii + 40; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private function dec_2_6bit($dec) { |
| 92 | - $bin=decbin($dec); |
|
| 92 | + $bin = decbin($dec); |
|
| 93 | 93 | return(substr($bin, -6)); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | '<', '=', '>', '?' |
| 107 | 107 | ); |
| 108 | 108 | $rv = ''; |
| 109 | - if ($_size % 6 == 0) { |
|
| 110 | - $len = $_size / 6; |
|
| 111 | - for ($i=0; $i<$len; $i++) { |
|
| 112 | - $offset = $i * 6; |
|
| 113 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
| 109 | + if ($_size%6 == 0) { |
|
| 110 | + $len = $_size/6; |
|
| 111 | + for ($i = 0; $i < $len; $i++) { |
|
| 112 | + $offset = $i*6; |
|
| 113 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | return $rv; |
@@ -127,40 +127,40 @@ discard block |
||
| 127 | 127 | $ro->lon = 0.0; |
| 128 | 128 | $ro->lat = 0.0; |
| 129 | 129 | $ro->ts = time(); |
| 130 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
| 131 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
| 130 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
| 131 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
| 132 | 132 | if ($ro->id >= 1 && $ro->id <= 3) { |
| 133 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
| 134 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
| 135 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 136 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 133 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
| 134 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
| 135 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 136 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 137 | 137 | $ro->cls = 1; // class A |
| 138 | 138 | } else if ($ro->id == 5) { |
| 139 | 139 | //$imo = bindec(substr($_aisdata,40,30)); |
| 140 | 140 | //$cs = $this->binchar($_aisdata,70,42); |
| 141 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
| 141 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
| 142 | 142 | $ro->cls = 1; // class A |
| 143 | 143 | } else if ($ro->id == 18) { |
| 144 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 145 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
| 147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
| 144 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 145 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
| 147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
| 148 | 148 | $ro->cls = 2; // class B |
| 149 | 149 | } else if ($ro->id == 19) { |
| 150 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
| 151 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
| 152 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
| 153 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
| 154 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
| 150 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
| 151 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
| 152 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
| 153 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
| 154 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
| 155 | 155 | $ro->cls = 2; // class B |
| 156 | 156 | } else if ($ro->id == 24) { |
| 157 | - $pn = bindec(substr($_aisdata,38,2)); |
|
| 157 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
| 158 | 158 | if ($pn == 0) { |
| 159 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
| 159 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
| 160 | 160 | } |
| 161 | 161 | $ro->cls = 2; // class B |
| 162 | 162 | } |
| 163 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
| 163 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
| 164 | 164 | $ro->status = $this->getStatus($ro->statusid); |
| 165 | 165 | //var_dump($ro); // dump results here for demo purpose |
| 166 | 166 | return $ro; |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | global $port; // tcpip port... |
| 207 | 207 | |
| 208 | 208 | static $debug_counter = 0; |
| 209 | - $aisdata168='';//six bit array of ascii characters |
|
| 209 | + $aisdata168 = ''; //six bit array of ascii characters |
|
| 210 | 210 | $ais_nmea_array = str_split($_itu); // convert to an array |
| 211 | 211 | foreach ($ais_nmea_array as $value) { |
| 212 | 212 | $dec = $this->ascii_2_dec($value); |
| 213 | 213 | $bit8 = $this->asciidec_2_8bit($dec); |
| 214 | 214 | $bit6 = $this->dec_2_6bit($bit8); |
| 215 | 215 | //echo $value ."-" .$bit6 .""; |
| 216 | - $aisdata168 .=$bit6; |
|
| 216 | + $aisdata168 .= $bit6; |
|
| 217 | 217 | } |
| 218 | 218 | //echo $aisdata168 . "<br/>"; |
| 219 | 219 | //return $this->decode_ais($aisdata168, $aux); |
@@ -236,20 +236,20 @@ discard block |
||
| 236 | 236 | // calculate checksum after ! till * |
| 237 | 237 | // assume 1st ! is valid |
| 238 | 238 | // find * ensure that it is at correct position |
| 239 | - $end = strrpos ( $rawdata , '*' ); |
|
| 239 | + $end = strrpos($rawdata, '*'); |
|
| 240 | 240 | if ($end === FALSE) return -1; // check for NULLS!!! |
| 241 | - $cs = substr( $rawdata, $end + 1 ); |
|
| 242 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
| 243 | - $dcs = (int)hexdec( $cs ); |
|
| 244 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
| 245 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
| 241 | + $cs = substr($rawdata, $end + 1); |
|
| 242 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
| 243 | + $dcs = (int) hexdec($cs); |
|
| 244 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
| 245 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
| 246 | 246 | $pcs = explode(',', $rawdata); |
| 247 | 247 | // !AI??? identifier |
| 248 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
| 249 | - $seq = (int)$pcs[2]; // get sequence |
|
| 248 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
| 249 | + $seq = (int) $pcs[2]; // get sequence |
|
| 250 | 250 | // get msg sequence id |
| 251 | 251 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
| 252 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
| 252 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
| 253 | 253 | $ais_ch = $pcs[4]; // get AIS channel |
| 254 | 254 | // message sequence checking |
| 255 | 255 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | $itu = $itu.$pcs[5]; // get itu message |
| 285 | - $filler += (int)$pcs[6][0]; // get filler |
|
| 285 | + $filler += (int) $pcs[6][0]; // get filler |
|
| 286 | 286 | if ($num_seq == 1 // valid single message |
| 287 | 287 | || $num_seq == $pseq // valid multi-part message |
| 288 | 288 | ) { |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | $cbuf = $cbuf.$ibuf; |
| 303 | 303 | $last_pos = 0; |
| 304 | 304 | $result = new stdClass(); |
| 305 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
| 305 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
| 306 | 306 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
| 307 | 307 | //DEBUG echo $cbuf; |
| 308 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 308 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
| 309 | 309 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
| 310 | 310 | //DEBUG echo "[$start $end $tst]\n"; |
| 311 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 311 | + $result = $this->process_ais_raw($tst, ""); |
|
| 312 | 312 | $last_pos = $end + 1; |
| 313 | 313 | } else break; |
| 314 | 314 | } |
@@ -320,41 +320,41 @@ discard block |
||
| 320 | 320 | // incoming data from serial or IP comms |
| 321 | 321 | public function process_ais_line($cbuf) { |
| 322 | 322 | $result = new stdClass(); |
| 323 | - $start = strpos($cbuf,"VDM"); |
|
| 323 | + $start = strpos($cbuf, "VDM"); |
|
| 324 | 324 | $tst = substr($cbuf, $start - 3); |
| 325 | - $result = $this->process_ais_raw( $tst, "" ); |
|
| 325 | + $result = $this->process_ais_raw($tst, ""); |
|
| 326 | 326 | return $result; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /* AIS Encoding |
| 330 | 330 | */ |
| 331 | - private function mk_ais_lat( $lat ) { |
|
| 331 | + private function mk_ais_lat($lat) { |
|
| 332 | 332 | //$lat = 1.2569; |
| 333 | - if ($lat<0.0) { |
|
| 333 | + if ($lat < 0.0) { |
|
| 334 | 334 | $lat = -$lat; |
| 335 | - $neg=true; |
|
| 336 | - } else $neg=false; |
|
| 335 | + $neg = true; |
|
| 336 | + } else $neg = false; |
|
| 337 | 337 | $latd = 0x00000000; |
| 338 | - $latd = intval ($lat * 600000.0); |
|
| 339 | - if ($neg==true) { |
|
| 338 | + $latd = intval($lat*600000.0); |
|
| 339 | + if ($neg == true) { |
|
| 340 | 340 | $latd = ~$latd; |
| 341 | - $latd+=1; |
|
| 341 | + $latd += 1; |
|
| 342 | 342 | $latd &= 0x07FFFFFF; |
| 343 | 343 | } |
| 344 | 344 | return $latd; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - private function mk_ais_lon( $lon ) { |
|
| 347 | + private function mk_ais_lon($lon) { |
|
| 348 | 348 | //$lon = 103.851; |
| 349 | - if ($lon<0.0) { |
|
| 349 | + if ($lon < 0.0) { |
|
| 350 | 350 | $lon = -$lon; |
| 351 | - $neg=true; |
|
| 352 | - } else $neg=false; |
|
| 351 | + $neg = true; |
|
| 352 | + } else $neg = false; |
|
| 353 | 353 | $lond = 0x00000000; |
| 354 | - $lond = intval ($lon * 600000.0); |
|
| 355 | - if ($neg==true) { |
|
| 354 | + $lond = intval($lon*600000.0); |
|
| 355 | + if ($neg == true) { |
|
| 356 | 356 | $lond = ~$lond; |
| 357 | - $lond+=1; |
|
| 357 | + $lond += 1; |
|
| 358 | 358 | $lond &= 0x0FFFFFFF; |
| 359 | 359 | } |
| 360 | 360 | return $lond; |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | private function char2bin($name, $max_len) { |
| 364 | 364 | $len = strlen($name); |
| 365 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
| 366 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
| 365 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
| 366 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
| 367 | 367 | else $pad = ''; |
| 368 | 368 | $rv = ''; |
| 369 | 369 | $ais_chars = array( |
@@ -379,26 +379,26 @@ discard block |
||
| 379 | 379 | if ($_a) foreach ($_a as $_1) { |
| 380 | 380 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
| 381 | 381 | else $dec = 0; |
| 382 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
| 382 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
| 383 | 383 | $rv .= $bin; |
| 384 | 384 | //echo "$_1 $dec ($bin)<br/>"; |
| 385 | 385 | } |
| 386 | 386 | return $rv.$pad; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
| 389 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
| 390 | 390 | $len_bit = strlen($_enc); |
| 391 | - $rem6 = $len_bit % 6; |
|
| 391 | + $rem6 = $len_bit%6; |
|
| 392 | 392 | $pad6_len = 0; |
| 393 | 393 | if ($rem6) $pad6_len = 6 - $rem6; |
| 394 | 394 | //echo $pad6_len.'<br>'; |
| 395 | 395 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
| 396 | - $len_enc = strlen($_enc) / 6; |
|
| 396 | + $len_enc = strlen($_enc)/6; |
|
| 397 | 397 | //echo $_enc.' '.$len_enc.'<br/>'; |
| 398 | 398 | $itu = ''; |
| 399 | - for ($i=0; $i<$len_enc; $i++) { |
|
| 400 | - $offset = $i * 6; |
|
| 401 | - $dec = bindec(substr($_enc,$offset,6)); |
|
| 399 | + for ($i = 0; $i < $len_enc; $i++) { |
|
| 400 | + $offset = $i*6; |
|
| 401 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
| 402 | 402 | if ($dec < 40) $dec += 48; |
| 403 | 403 | else $dec += 56; |
| 404 | 404 | //echo chr($dec)." $dec<br/>"; |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | $chksum = 0; |
| 409 | 409 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
| 410 | 410 | $len_itu = strlen($itu); |
| 411 | - for ($i=0; $i<$len_itu; $i++) { |
|
| 412 | - $chksum ^= ord( $itu[$i] ); |
|
| 411 | + for ($i = 0; $i < $len_itu; $i++) { |
|
| 412 | + $chksum ^= ord($itu[$i]); |
|
| 413 | 413 | } |
| 414 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
| 415 | - $lsb = $chksum & 0x0F; |
|
| 416 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
| 414 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
| 415 | + $lsb = $chksum&0x0F; |
|
| 416 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
| 417 | 417 | else $lsbc = '0'; |
| 418 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
| 419 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
| 418 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
| 419 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
| 420 | 420 | else $msbc = '0'; |
| 421 | 421 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
| 422 | 422 | return $itu; |
@@ -442,13 +442,13 @@ discard block |
||
| 442 | 442 | public function parse_line($buffer) { |
| 443 | 443 | $result = array(); |
| 444 | 444 | $data = new stdClass(); |
| 445 | - $start = strpos($buffer,"VDM"); |
|
| 445 | + $start = strpos($buffer, "VDM"); |
|
| 446 | 446 | $tst = substr($buffer, $start - 3); |
| 447 | - $data = $this->process_ais_raw( $tst, "" ); |
|
| 447 | + $data = $this->process_ais_raw($tst, ""); |
|
| 448 | 448 | if (!is_object($data)) return array(); |
| 449 | 449 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
| 450 | 450 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
| 451 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
| 451 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
| 452 | 452 | $result['timestamp'] = $data->ts; |
| 453 | 453 | $result['mmsi'] = $data->mmsi; |
| 454 | 454 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |