1 | <?php |
||
26 | class LOC implements RdataInterface |
||
27 | { |
||
28 | 1 | use RdataTrait; |
|
29 | |||
30 | const TYPE = 'LOC'; |
||
31 | const TYPE_CODE = 29; |
||
32 | const LATITUDE = 'LATITUDE'; |
||
33 | const LONGITUDE = 'LONGITUDE'; |
||
34 | const FORMAT_DECIMAL = 'DECIMAL'; |
||
35 | const FORMAT_DMS = 'DMS'; |
||
36 | |||
37 | /** |
||
38 | * @var float|null |
||
39 | */ |
||
40 | private $latitude; |
||
41 | |||
42 | /** |
||
43 | * @var float|null |
||
44 | */ |
||
45 | private $longitude; |
||
46 | |||
47 | /** |
||
48 | * @var float |
||
49 | */ |
||
50 | private $altitude = 0.0; |
||
51 | |||
52 | /** |
||
53 | * @var float |
||
54 | */ |
||
55 | private $size = 1.0; |
||
56 | |||
57 | /** |
||
58 | * @var float |
||
59 | */ |
||
60 | private $horizontalPrecision = 10000.0; |
||
61 | |||
62 | /** |
||
63 | * @var float |
||
64 | */ |
||
65 | private $verticalPrecision = 10.0; |
||
66 | |||
67 | 14 | public function setLatitude(float $latitude): void |
|
71 | |||
72 | /** |
||
73 | * @return float|string|null |
||
74 | */ |
||
75 | 6 | public function getLatitude(string $format = self::FORMAT_DECIMAL) |
|
83 | |||
84 | 14 | public function setLongitude(float $longitude): void |
|
88 | |||
89 | /** |
||
90 | * @return float|string|null |
||
91 | */ |
||
92 | 6 | public function getLongitude(string $format = self::FORMAT_DECIMAL) |
|
100 | |||
101 | /** |
||
102 | * @throws \OutOfRangeException |
||
103 | */ |
||
104 | 16 | public function setAltitude(float $altitude): void |
|
112 | |||
113 | 4 | public function getAltitude(): float |
|
117 | |||
118 | /** |
||
119 | * @throws \OutOfRangeException |
||
120 | */ |
||
121 | 16 | public function setHorizontalPrecision(float $horizontalPrecision): void |
|
129 | |||
130 | 4 | public function getHorizontalPrecision(): float |
|
134 | |||
135 | /** |
||
136 | * @throws \OutOfRangeException |
||
137 | */ |
||
138 | 16 | public function setSize(float $size): void |
|
146 | |||
147 | 4 | public function getSize(): float |
|
151 | |||
152 | /** |
||
153 | * @throws \OutOfRangeException |
||
154 | */ |
||
155 | 16 | public function setVerticalPrecision(float $verticalPrecision): void |
|
163 | |||
164 | 4 | public function getVerticalPrecision(): float |
|
168 | |||
169 | 5 | public function toText(): string |
|
181 | |||
182 | /** |
||
183 | * Determine the degree minute seconds value from decimal. |
||
184 | */ |
||
185 | 7 | private function toDms(float $decimal, string $axis = self::LATITUDE): string |
|
198 | |||
199 | 1 | public function toWire(): string |
|
211 | |||
212 | 1 | private static function numberToExponentValue(float $num): int |
|
219 | |||
220 | 1 | private static function exponentValueToNumber(int $val): float |
|
227 | |||
228 | /** |
||
229 | * Transform a DMS string to a decimal representation. Used for LOC records. |
||
230 | * |
||
231 | * @param int $deg Degrees |
||
232 | * @param int $min Minutes |
||
233 | * @param float $sec Seconds |
||
234 | * @param string $hemisphere Either 'N', 'S', 'E', or 'W' |
||
235 | */ |
||
236 | 1 | public static function dmsToDecimal(int $deg, int $min, float $sec, string $hemisphere): float |
|
242 | |||
243 | 1 | public function fromText(string $text): void |
|
256 | |||
257 | 1 | /** |
|
258 | * @throws DecodeException |
||
259 | 1 | */ |
|
260 | 1 | public function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): void |
|
274 | } |
||
275 |