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