bulton-fr /
nmea-parser
| 1 | <?php |
||
| 2 | |||
| 3 | namespace BultonFr\NMEA\Frames; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Define the parser system for GSA frame type |
||
| 7 | * |
||
| 8 | * @package BultonFr\NMEA |
||
| 9 | * @author Vermeulen Maxime <[email protected]> |
||
| 10 | * @link http://www.gpsinformation.org/dale/nmea.htm#GSA |
||
| 11 | * @link http://aprs.gids.nl/nmea/#gsa |
||
| 12 | */ |
||
| 13 | class GSA extends \BultonFr\NMEA\Frame |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * {@inheritdoc} |
||
| 17 | */ |
||
| 18 | protected $frameType = 'GSA'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * {@inheritdoc} |
||
| 22 | */ |
||
| 23 | protected $frameRegex = '/^' |
||
| 24 | .'([A-Z]{2}[A-Z]{3}),' //Equipment and trame type |
||
| 25 | .'(A|M),' // selection type of 2D or 3D (manual or automatic) |
||
| 26 | .'(1|2|3),' // Mode (2d / 3d) |
||
| 27 | .'(\d*),' //PRNs of satellites used for fix |
||
| 28 | .'(\d*),' //PRNs of satellites used for fix |
||
| 29 | .'(\d*),' //PRNs of satellites used for fix |
||
| 30 | .'(\d*),' //PRNs of satellites used for fix |
||
| 31 | .'(\d*),' //PRNs of satellites used for fix |
||
| 32 | .'(\d*),' //PRNs of satellites used for fix |
||
| 33 | .'(\d*),' //PRNs of satellites used for fix |
||
| 34 | .'(\d*),' //PRNs of satellites used for fix |
||
| 35 | .'(\d*),' //PRNs of satellites used for fix |
||
| 36 | .'(\d*),' //PRNs of satellites used for fix |
||
| 37 | .'(\d*),' //PRNs of satellites used for fix |
||
| 38 | .'(\d*),' //PRNs of satellites used for fix |
||
| 39 | .'([0-9\.]+),' //PDOP (dilution of precision) |
||
| 40 | .'([0-9\.]+),' //Horizontal dilution of precision (HDOP) |
||
| 41 | .'([0-9\.]+)' //Vertical dilution of precision (VDOP) |
||
| 42 | .'$/m'; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var float $selection Auto selection of 2D or 3D fix |
||
| 46 | * * A : Automatic, 3D/2D |
||
| 47 | * * M : Manual, forced to operate in 2D or 3D |
||
| 48 | */ |
||
| 49 | protected $selection; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var string $mode Mode type |
||
| 53 | * * 1 : no fix |
||
| 54 | * * 2 : 2d fix |
||
| 55 | * * 3 : 3d fix |
||
| 56 | */ |
||
| 57 | protected $mode; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var array $satellitesPNR PRNs of satellites used for fix |
||
| 61 | */ |
||
| 62 | protected $satellitesPNR; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var float $pdop PDOP (dilution of precision) |
||
| 66 | */ |
||
| 67 | protected $pdop; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var float $hdop Horizontal dilution of precision (HDOP) |
||
| 71 | */ |
||
| 72 | protected $hdop; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var float $vdop Vertical dilution of precision (VDOP) |
||
| 76 | */ |
||
| 77 | protected $vdop; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Getter to property selection |
||
| 81 | * |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | public function getSelection() |
||
| 85 | { |
||
| 86 | 1 | return $this->selection; |
|
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Getter to property mode |
||
| 91 | * |
||
| 92 | * @return string |
||
| 93 | */ |
||
| 94 | public function getMode() |
||
| 95 | { |
||
| 96 | 1 | return $this->mode; |
|
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Getter to property satellitesPNR |
||
| 101 | * |
||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | public function getSatellitesPNR() |
||
| 105 | { |
||
| 106 | 1 | return $this->satellitesPNR; |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Getter to property pdop |
||
| 111 | * |
||
| 112 | * @return string |
||
| 113 | */ |
||
| 114 | public function getPdop() |
||
| 115 | { |
||
| 116 | 1 | return $this->pdop; |
|
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Getter to property hdop |
||
| 121 | * |
||
| 122 | * @return string |
||
| 123 | */ |
||
| 124 | public function getHdop() |
||
| 125 | { |
||
| 126 | 1 | return $this->hdop; |
|
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Getter to property vdop |
||
| 131 | * |
||
| 132 | * @return string |
||
| 133 | */ |
||
| 134 | public function getVdop() |
||
| 135 | { |
||
| 136 | 1 | return $this->vdop; |
|
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * {@inheritdoc} |
||
| 141 | */ |
||
| 142 | protected function decodeFrame($msgParts) |
||
| 143 | { |
||
| 144 | 1 | $this->selection = (string) $msgParts[2]; |
|
|
0 ignored issues
–
show
The property
$selection was declared of type double, but (string)$msgParts[2] is of type string. Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
Loading history...
|
|||
| 145 | 1 | $this->mode = (int) $msgParts[3]; |
|
| 146 | |||
| 147 | 1 | for ($msgIndex = 4; $msgIndex <= 15; $msgIndex++) { |
|
| 148 | 1 | $this->satellitesPNR[] = (int) $msgParts[$msgIndex]; |
|
| 149 | } |
||
| 150 | |||
| 151 | 1 | $this->pdop = (float) $msgParts[16]; |
|
| 152 | 1 | $this->hdop = (float) $msgParts[17]; |
|
| 153 | 1 | $this->vdop = (float) $msgParts[18]; |
|
| 154 | 1 | } |
|
| 155 | } |
||
| 156 |