|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BultonFr\NMEA\Frames; |
|
4
|
|
|
|
|
5
|
|
|
use \DateTime; |
|
6
|
|
|
use \DateTimeZone; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Define the parser system for GLL frame type |
|
10
|
|
|
* |
|
11
|
|
|
* @package BultonFr\NMEA |
|
12
|
|
|
* @author Vermeulen Maxime <[email protected]> |
|
13
|
|
|
* @link http://www.gpsinformation.org/dale/nmea.htm#GLL |
|
14
|
|
|
* @link http://aprs.gids.nl/nmea/#gll |
|
15
|
|
|
*/ |
|
16
|
|
|
class GLL extends \BultonFr\NMEA\Frame |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $frameType = 'GLL'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Format : ----GLL,lll.ll,a,yyyyy.yy,a,hhmmss.ss,A |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $frameRegex = '/^' |
|
28
|
|
|
.'([A-Z]{2}[A-Z]{3}),' //Equipment and trame type |
|
29
|
|
|
.'([0-9\.]+),' //Latitude |
|
30
|
|
|
.'(N|S),' //N or S (North or South) |
|
31
|
|
|
.'([0-9\.]+),' //Longitude |
|
32
|
|
|
.'(E|W),' //E or W (East or West) |
|
33
|
|
|
.'(\d{6})(\.\d{2,3})?,' //Time (UTC) |
|
34
|
|
|
.'(A|V)' //Status A=active or V=Void |
|
35
|
|
|
.'(,(A|D|E|N|S)?)?' //Mode indicator (NMEA >= 2.3) |
|
36
|
|
|
.'$/m'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string $latitude Latitude |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $latitude; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var string $latitudeDirection N or S (North or South) |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $latitudeDirection; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var string $longitude Longitude |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $longitude; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var string $longitudeDirection E or W (East or West) |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $longitudeDirection; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @var \DateTime $utcTime Time of the line (UTC) |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $utcTime; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var string $status Status A=active or V=Void |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $status; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var string $mode Mode indicator (NMEA >= 2.3) |
|
70
|
|
|
* * A : autonomous |
|
71
|
|
|
* * D : differential |
|
72
|
|
|
* * E : Estimated |
|
73
|
|
|
* * N : not valid |
|
74
|
|
|
* * S : Simulator |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $mode; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Getter to property latitude |
|
80
|
|
|
* |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getLatitude() |
|
84
|
|
|
{ |
|
85
|
1 |
|
return $this->latitude; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Getter to property latitudeDirection |
|
90
|
|
|
* |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getLatitudeDirection() |
|
94
|
|
|
{ |
|
95
|
1 |
|
return $this->latitudeDirection; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Getter to property longitude |
|
100
|
|
|
* |
|
101
|
|
|
* @return string |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getLongitude() |
|
104
|
|
|
{ |
|
105
|
1 |
|
return $this->longitude; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Getter to property longitudeDirection |
|
110
|
|
|
* |
|
111
|
|
|
* @return string |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getLongitudeDirection() |
|
114
|
|
|
{ |
|
115
|
1 |
|
return $this->longitudeDirection; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Getter to property utcTime |
|
120
|
|
|
* |
|
121
|
|
|
* @return \DateTime |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getUtcTime() |
|
124
|
|
|
{ |
|
125
|
1 |
|
return $this->utcTime; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Getter to property status |
|
130
|
|
|
* |
|
131
|
|
|
* @return float |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getStatus() |
|
134
|
|
|
{ |
|
135
|
1 |
|
return $this->status; |
|
|
|
|
|
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Getter to property mode |
|
140
|
|
|
* |
|
141
|
|
|
* @return string |
|
142
|
|
|
*/ |
|
143
|
|
|
public function getMode() |
|
144
|
|
|
{ |
|
145
|
1 |
|
return $this->mode; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* {@inheritdoc} |
|
150
|
|
|
*/ |
|
151
|
|
|
protected function decodeFrame($msgParts) |
|
152
|
|
|
{ |
|
153
|
1 |
|
$this->latitude = (string) $msgParts[2]; |
|
154
|
1 |
|
$this->latitudeDirection = (string) $msgParts[3]; |
|
155
|
1 |
|
$this->longitude = (string) $msgParts[4]; |
|
156
|
1 |
|
$this->longitudeDirection = (string) $msgParts[5]; |
|
157
|
|
|
|
|
158
|
1 |
|
$this->utcTime = DateTime::createFromFormat( |
|
|
|
|
|
|
159
|
1 |
|
'His', |
|
160
|
1 |
|
$msgParts[6], |
|
161
|
1 |
|
new DateTimeZone('UTC') |
|
162
|
|
|
); |
|
163
|
|
|
|
|
164
|
1 |
|
$this->status = (string) $msgParts[8]; |
|
165
|
|
|
|
|
166
|
1 |
|
if (isset($msgParts[10])) { |
|
167
|
1 |
|
$this->mode = (string) $msgParts[10]; |
|
168
|
|
|
} |
|
169
|
1 |
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|