| Total Complexity | 7 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class MercatorProjection implements Projection |
||
| 9 | { |
||
| 10 | 1 | public function getX(Position $position): float |
|
| 11 | { |
||
| 12 | 1 | return ($position->longitude + 180) * (Position::TOTAL_LONGITUDE * .5 / 360); |
|
| 13 | } |
||
| 14 | |||
| 15 | 1 | public function getY(Position $position): float |
|
| 16 | { |
||
| 17 | 1 | $latitude = $position->latitude; |
|
| 18 | 1 | if ($latitude > $this->getMaxLatitude() - 0.001) { |
|
| 19 | 1 | $latitude = $this->getMaxLatitude() - 0.001; |
|
| 20 | } |
||
| 21 | |||
| 22 | 1 | if ($latitude < (-$this->getMaxLatitude()) + 0.001) { |
|
| 23 | 1 | $latitude = (-$this->getMaxLatitude()) + 0.001; |
|
| 24 | } |
||
| 25 | |||
| 26 | 1 | return (Position::TOTAL_LATITUDE / 2) - (Position::TOTAL_LONGITUDE * .5 * log(tan((M_PI / 4) + (($latitude*M_PI / 180) / 2))) / (2 * M_PI)); |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | public function getMaxX(): float |
|
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function getMaxY(): float |
|
| 35 | { |
||
| 36 | 1 | return Position::TOTAL_LATITUDE; |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | public function getMaxLatitude(): float |
|
| 42 | } |
||
| 43 | } |
||
| 44 |