1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CodecsTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use CommonTestClass; |
7
|
|
|
use kalanis\kw_coordinates\CoordinatesException; |
8
|
|
|
use kalanis\kw_coordinates\Support; |
9
|
|
|
use kalanis\kw_coordinates\Codecs; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class PassingTest extends CommonTestClass |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param float $coordLon |
16
|
|
|
* @param float $coordLat |
17
|
|
|
* @param float $coordAlt |
18
|
|
|
* @param string $x |
19
|
|
|
* @param string $y |
20
|
|
|
* @param string $z |
21
|
|
|
* @param bool $useAlt |
22
|
|
|
* @throws CoordinatesException |
23
|
|
|
* @dataProvider transferProvider |
24
|
|
|
*/ |
25
|
|
|
public function testPassFrom(float $coordLon, float $coordLat, float $coordAlt, string $x, string $y, string $z, bool $useAlt = true): void |
26
|
|
|
{ |
27
|
|
|
$lib = new Codecs\Passing(); |
28
|
|
|
$transport = new Support\Position(); |
29
|
|
|
$result = $lib->fromLonLat($transport->setData($coordLon, $coordLat, $useAlt ? $coordAlt : 0.0), []); |
30
|
|
|
|
31
|
|
|
$this->assertEquals(sprintf('%01.6f', $x), sprintf('%01.6f', $result->getLongitude())); |
32
|
|
|
$this->assertEquals(sprintf('%01.6f', $y), sprintf('%01.6f', $result->getLatitude())); |
33
|
|
|
if ($useAlt) $this->assertEquals(sprintf('%01.6f', $z), sprintf('%01.6f', $result->getAltitude())); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param float $coordLon |
38
|
|
|
* @param float $coordLat |
39
|
|
|
* @param float $coordAlt |
40
|
|
|
* @param string $x |
41
|
|
|
* @param string $y |
42
|
|
|
* @param string $z |
43
|
|
|
* @param bool $useAlt |
44
|
|
|
* @throws CoordinatesException |
45
|
|
|
* @dataProvider transferProvider |
46
|
|
|
*/ |
47
|
|
|
public function testPassTo(float $coordLon, float $coordLat, float $coordAlt, string $x, string $y, string $z, bool $useAlt = true): void |
48
|
|
|
{ |
49
|
|
|
$lib = new Codecs\Passing(); |
50
|
|
|
$transport = new Support\DegreesObject(); |
51
|
|
|
$result = $lib->toLonLat($transport->setData($x, $y, $useAlt ? $z : 0.0), []); |
52
|
|
|
|
53
|
|
|
$this->assertEquals(sprintf('%01.6f', $coordLon), sprintf('%01.6f', $result->getLongitude())); |
54
|
|
|
$this->assertEquals(sprintf('%01.6f', $coordLat), sprintf('%01.6f', $result->getLatitude())); |
55
|
|
|
if ($useAlt) $this->assertEquals($coordAlt, $result->getAltitude()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return array |
60
|
|
|
*/ |
61
|
|
|
public function transferProvider(): array |
62
|
|
|
{ |
63
|
|
|
return [ |
64
|
|
|
[48.1417237, 17.1000319, 305, '48.1417237', '17.1000319', '305', false], // bratislavsky hrad |
65
|
|
|
[-548.1417237, -17.1000319, 305, '-548.1417237', '-17.1000319', '305', true], // nekde jinde |
66
|
|
|
[12.8069888666667, -49.4522626972222, 512.30, '12.8069888666667', '-49.4522626972222', '512.3', true], // testovaci bod 109 |
67
|
|
|
[-12.8069888666667, 4995.4522626972222, 559.417, '-12.8069888666667', '4995.4522626972222', '0.0', false], // zase jinde |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|