|
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
|
|
|
/** |
|
13
|
|
|
* Class Sjtsk1Test |
|
14
|
|
|
* @package CodecsTests |
|
15
|
|
|
* @see http://freegis.fsv.cvut.cz/gwiki/S-JTSK |
|
16
|
|
|
*/ |
|
17
|
|
|
class Sjtsk1Test extends CommonTestClass |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param float $coordLon |
|
21
|
|
|
* @param float $coordLat |
|
22
|
|
|
* @param float $coordAlt |
|
23
|
|
|
* @param float $x |
|
24
|
|
|
* @param float $y |
|
25
|
|
|
* @param float $z |
|
26
|
|
|
* @param bool $useAlt |
|
27
|
|
|
* @param array<string, string|int|bool> $params |
|
28
|
|
|
* @throws CoordinatesException |
|
29
|
|
|
* @dataProvider transferFromProvider |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testFromJtskToCoord(float $coordLon, float $coordLat, float $coordAlt, float $x, float $y, float $z, bool $useAlt = true, array $params = []): void |
|
32
|
|
|
{ |
|
33
|
|
|
$lib = new Codecs\Sjtsk1(); |
|
34
|
|
|
$transport = new Support\Position(); |
|
35
|
|
|
$result = $lib->fromLonLat($transport->setData($coordLon, $coordLat, $useAlt ? $coordAlt : 0.0), $params); |
|
36
|
|
|
$this->assertEquals(sprintf('%01.6f', $x), sprintf('%01.6f', $result->getLongitude())); |
|
37
|
|
|
$this->assertEquals(sprintf('%01.6f', $y), sprintf('%01.6f', $result->getLatitude())); |
|
38
|
|
|
if ($useAlt) $this->assertEquals(sprintf('%01.6f', $z), sprintf('%01.6f', $result->getAltitude())); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function transferFromProvider(): array |
|
42
|
|
|
{ |
|
43
|
|
|
return [ |
|
44
|
|
|
[17.1000319, 48.1417237, 0, -574330.31144954, -1281026.261520, 0, false, []], // bratislavsky hrad |
|
45
|
|
|
[12.8069819, 49.4522531, 559.417, 868209.23834622, 1095794.6651235, 512.602931, true, ['czech' => true]], // testovaci bod 109 - krizek u Postrekova u Klenci pod Cerchovem |
|
46
|
|
|
]; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param float $coordLon |
|
51
|
|
|
* @param float $coordLat |
|
52
|
|
|
* @param float $coordAlt |
|
53
|
|
|
* @param float $x |
|
54
|
|
|
* @param float $y |
|
55
|
|
|
* @param float $z |
|
56
|
|
|
* @param bool $useAlt |
|
57
|
|
|
* @param array<string, string|int|bool> $params |
|
58
|
|
|
* @throws CoordinatesException |
|
59
|
|
|
* @dataProvider transferToProvider |
|
60
|
|
|
* It hops cca about 10 metres out, but shit happens for this code |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testFromCoordToJtsk(float $coordLon, float $coordLat, float $coordAlt, float $x, float $y, float $z, bool $useAlt = true, array $params = []): void |
|
63
|
|
|
{ |
|
64
|
|
|
$lib = new Codecs\Sjtsk1(); |
|
65
|
|
|
$transport = new Support\JtskObject(); |
|
66
|
|
|
$result = $lib->toLonLat($transport->setData($x, $y, $useAlt ? $z : 0.0), $params); |
|
67
|
|
|
$this->assertEquals(sprintf('%01.6f', $coordLon), sprintf('%01.6f', $result->getLongitude())); |
|
68
|
|
|
$this->assertEquals(sprintf('%01.6f', $coordLat), sprintf('%01.6f', $result->getLatitude())); |
|
69
|
|
|
if ($useAlt) $this->assertEquals(sprintf('%01.6f', $coordAlt), sprintf('%01.6f', $result->getAltitude())); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function transferToProvider(): array |
|
73
|
|
|
{ |
|
74
|
|
|
return [ |
|
75
|
|
|
[17.099988437339, 48.141741927043, 0, -574330.31144954, -1281026.261520, 0, false, []], // bratislavsky hrad |
|
76
|
|
|
[12.807019361493, 49.452368187952, 559.417, 868209.23834622, 1095794.6651235, 512.602931, false, ['czech' => true]], // testovaci bod 109 - krizek u Postrekova u Klenci pod Cerchovem |
|
77
|
|
|
]; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|