@@ -41,9 +41,9 @@ |
||
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Cartesian constructor. |
| 44 | - * @param int $x |
|
| 45 | - * @param int $y |
|
| 46 | - * @param int $z |
|
| 44 | + * @param double $x |
|
| 45 | + * @param double $y |
|
| 46 | + * @param double $z |
|
| 47 | 47 | * @param RefEll $refEll |
| 48 | 48 | */ |
| 49 | 49 | public function __construct(float $x, float $y, float $z, RefEll $refEll) |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * @package PHPCoord |
| 5 | 5 | * @author Doug Wright |
| 6 | 6 | */ |
| 7 | -declare(strict_types=1); |
|
| 7 | +declare(strict_types = 1); |
|
| 8 | 8 | namespace PHPCoord; |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $phi = atan(($this->z + ($this->refEll->getEcc() * $v * sin($phi))) / $p); |
| 117 | 117 | } while (abs($phi - $phi1) >= 0.00001); |
| 118 | 118 | |
| 119 | - $h = (int)round($p / cos($phi) - $v); |
|
| 119 | + $h = (int) round($p / cos($phi) - $v); |
|
| 120 | 120 | |
| 121 | 121 | $phi = rad2deg($phi); |
| 122 | 122 | |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @author Jonathan Stott |
| 6 | 6 | * @author Doug Wright |
| 7 | 7 | */ |
| 8 | -declare(strict_types=1); |
|
| 8 | +declare(strict_types = 1); |
|
| 9 | 9 | namespace PHPCoord; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -92,17 +92,17 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | |
| 94 | 94 | //first (major) letter is the 500km grid sq, origin at -1000000, -500000 |
| 95 | - $majorEasting = strpos(self::GRID_LETTERS, $ref[0]) % 5 * 500000 - 1000000; |
|
| 95 | + $majorEasting = strpos(self::GRID_LETTERS, $ref[0]) % 5 * 500000 - 1000000; |
|
| 96 | 96 | $majorNorthing = (floor(strpos(self::GRID_LETTERS, $ref[0]) / 5)) * 500000 - 500000; |
| 97 | 97 | |
| 98 | 98 | //second (minor) letter is 100km grid sq, origin at 0,0 of this square |
| 99 | - $minorEasting = strpos(self::GRID_LETTERS, $ref[1]) % 5 * 100000; |
|
| 99 | + $minorEasting = strpos(self::GRID_LETTERS, $ref[1]) % 5 * 100000; |
|
| 100 | 100 | $minorNorthing = (floor(strpos(self::GRID_LETTERS, $ref[1]) / 5)) * 100000; |
| 101 | 101 | |
| 102 | 102 | $easting = $majorEasting + $minorEasting + (substr($ref, 2, 3) * 100); |
| 103 | 103 | $northing = $majorNorthing + $minorNorthing + (substr($ref, 5, 3) * 100); |
| 104 | 104 | |
| 105 | - return new static((int)$easting, (int)$northing); |
|
| 105 | + return new static((int) $easting, (int) $northing); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -116,24 +116,24 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $halfLength = $length / 2; |
| 118 | 118 | |
| 119 | - $easting = str_pad((string)$this->x, 6, '0', STR_PAD_LEFT); |
|
| 120 | - $northing = str_pad((string)$this->y, 6, '0', STR_PAD_LEFT); |
|
| 119 | + $easting = str_pad((string) $this->x, 6, '0', STR_PAD_LEFT); |
|
| 120 | + $northing = str_pad((string) $this->y, 6, '0', STR_PAD_LEFT); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | $adjustedX = $this->x + 1000000; |
| 124 | 124 | $adjustedY = $this->y + 500000; |
| 125 | 125 | $majorSquaresEast = floor($adjustedX / 500000); |
| 126 | 126 | $majorSquaresNorth = floor($adjustedY / 500000); |
| 127 | - $majorLetterIndex = (int)(5 * $majorSquaresNorth + $majorSquaresEast); |
|
| 127 | + $majorLetterIndex = (int) (5 * $majorSquaresNorth + $majorSquaresEast); |
|
| 128 | 128 | $majorLetter = substr(self::GRID_LETTERS, $majorLetterIndex, 1); |
| 129 | 129 | |
| 130 | 130 | //second (minor) letter is 100km grid sq, origin at 0,0 of this square |
| 131 | 131 | $minorSquaresEast = $easting[0] % 5; |
| 132 | 132 | $minorSquaresNorth = $northing[0] % 5; |
| 133 | - $minorLetterIndex = (int)(5 * $minorSquaresNorth + $minorSquaresEast); |
|
| 133 | + $minorLetterIndex = (int) (5 * $minorSquaresNorth + $minorSquaresEast); |
|
| 134 | 134 | $minorLetter = substr(self::GRID_LETTERS, $minorLetterIndex, 1); |
| 135 | 135 | |
| 136 | - return $majorLetter . $minorLetter . substr($easting, 1, $halfLength) . substr($northing, 1, $halfLength); |
|
| 136 | + return $majorLetter.$minorLetter.substr($easting, 1, $halfLength).substr($northing, 1, $halfLength); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | * @package PHPCoord |
| 5 | 5 | * @author Doug Wright |
| 6 | 6 | */ |
| 7 | -declare(strict_types=1); |
|
| 7 | +declare(strict_types = 1); |
|
| 8 | 8 | namespace PHPCoord; |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @author Jonathan Stott |
| 6 | 6 | * @author Doug Wright |
| 7 | 7 | */ |
| 8 | -declare(strict_types=1); |
|
| 8 | +declare(strict_types = 1); |
|
| 9 | 9 | namespace PHPCoord; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | $d = acos(sin($latFrom) * sin($latTo) + cos($latFrom) * cos($latTo) * cos($lngTo - $lngFrom)) * $er; |
| 122 | 122 | |
| 123 | - return (int)round($d); |
|
| 123 | + return (int) round($d); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | { |
| 376 | 376 | $asWGS84 = $this->toWGS84(); |
| 377 | 377 | |
| 378 | - $longitudeZone = (int)(($asWGS84->getLng() + 180) / 6) + 1; |
|
| 378 | + $longitudeZone = (int) (($asWGS84->getLng() + 180) / 6) + 1; |
|
| 379 | 379 | |
| 380 | 380 | // Special zone for Norway |
| 381 | 381 | if ($asWGS84->getLat() >= 56 && $asWGS84->getLat() < 64 && $asWGS84->getLng() >= 3 && $asWGS84->getLng() < 12) { |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $zones = "CDEFGHJKLMNPQRSTUVWXX"; |
| 425 | - $zoneIndex = (int)(($latitude + 80) / 8); |
|
| 425 | + $zoneIndex = (int) (($latitude + 80) / 8); |
|
| 426 | 426 | return $zones[$zoneIndex]; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | $V = $v / 6 * pow($cosLat, 3) * ($v / $p - $tanLatSq); |
| 485 | 485 | $VI = $v / 120 * pow($cosLat, 5) * (5 - 18 * $tanLatSq + pow($tanLatSq, 2) + 14 * $hSq - 58 * $tanLatSq * $hSq); |
| 486 | 486 | |
| 487 | - $E = (int)round($originEasting + $IV * $longMinusOrigin + $V * pow($longMinusOrigin, 3) + $VI * pow($longMinusOrigin, 5)); |
|
| 488 | - $N = (int)round($I + $II * pow($longMinusOrigin, 2) + $III * pow($longMinusOrigin, 4) + $IIIA * pow($longMinusOrigin, 6)); |
|
| 487 | + $E = (int) round($originEasting + $IV * $longMinusOrigin + $V * pow($longMinusOrigin, 3) + $VI * pow($longMinusOrigin, 5)); |
|
| 488 | + $N = (int) round($I + $II * pow($longMinusOrigin, 2) + $III * pow($longMinusOrigin, 4) + $IIIA * pow($longMinusOrigin, 6)); |
|
| 489 | 489 | |
| 490 | 490 | return array('E' => $E, 'N' => $N); |
| 491 | 491 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | * @author Jonathan Stott |
| 6 | 6 | * @author Doug Wright |
| 7 | 7 | */ |
| 8 | -declare(strict_types=1); |
|
| 8 | +declare(strict_types = 1); |
|
| 9 | 9 | namespace PHPCoord; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | * @author Jonathan Stott |
| 6 | 6 | * @author Doug Wright |
| 7 | 7 | */ |
| 8 | -declare(strict_types=1); |
|
| 8 | +declare(strict_types = 1); |
|
| 9 | 9 | namespace PHPCoord; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * @package PHPCoord |
| 5 | 5 | * @author Doug Wright |
| 6 | 6 | */ |
| 7 | -declare(strict_types=1); |
|
| 7 | +declare(strict_types = 1); |
|
| 8 | 8 | namespace PHPCoord; |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | public static function fromSixFigureReference($ref): IrishGridRef |
| 88 | 88 | { |
| 89 | 89 | |
| 90 | - $easting = (int)strpos(self::GRID_LETTERS, $ref[0]) % 5 * 100000 + (substr($ref, 1, 3) * 100); |
|
| 91 | - $northing = (int)(floor(strpos(self::GRID_LETTERS, $ref[0]) / 5)) * 100000 + (substr($ref, 4, 3) * 100); |
|
| 90 | + $easting = (int) strpos(self::GRID_LETTERS, $ref[0]) % 5 * 100000 + (substr($ref, 1, 3) * 100); |
|
| 91 | + $northing = (int) (floor(strpos(self::GRID_LETTERS, $ref[0]) / 5)) * 100000 + (substr($ref, 4, 3) * 100); |
|
| 92 | 92 | |
| 93 | 93 | return new IrishGridRef($easting, $northing); |
| 94 | 94 | } |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | public function toSixFigureReference(): string |
| 103 | 103 | { |
| 104 | 104 | |
| 105 | - $easting = str_pad((string)$this->x, 6, '0', STR_PAD_LEFT); |
|
| 106 | - $northing = str_pad((string)$this->y, 6, '0', STR_PAD_LEFT); |
|
| 105 | + $easting = str_pad((string) $this->x, 6, '0', STR_PAD_LEFT); |
|
| 106 | + $northing = str_pad((string) $this->y, 6, '0', STR_PAD_LEFT); |
|
| 107 | 107 | |
| 108 | 108 | //100km grid sq, origin at 0,0 |
| 109 | 109 | $minorSquaresEast = $easting[0] % 5; |
| 110 | 110 | $minorSquaresNorth = $northing[0] % 5; |
| 111 | - $minorLetterIndex = (int)(5 * $minorSquaresNorth + $minorSquaresEast); |
|
| 111 | + $minorLetterIndex = (int) (5 * $minorSquaresNorth + $minorSquaresEast); |
|
| 112 | 112 | $minorLetter = substr(self::GRID_LETTERS, $minorLetterIndex, 1); |
| 113 | 113 | |
| 114 | - return $minorLetter . substr($easting, 1, 3) . substr($northing, 1, 3); |
|
| 114 | + return $minorLetter.substr($easting, 1, 3).substr($northing, 1, 3); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @author Jonathan Stott |
| 6 | 6 | * @author Doug Wright |
| 7 | 7 | */ |
| 8 | -declare(strict_types=1); |
|
| 8 | +declare(strict_types = 1); |
|
| 9 | 9 | namespace PHPCoord; |
| 10 | 10 | |
| 11 | 11 | /** |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | //Because this is a 2D grid, we can use simple Pythagoras |
| 235 | - $distanceX = $to->getX()-$this->getX(); |
|
| 236 | - $distanceY = $to->getY()-$this->getY(); |
|
| 235 | + $distanceX = $to->getX() - $this->getX(); |
|
| 236 | + $distanceY = $to->getY() - $this->getY(); |
|
| 237 | 237 | |
| 238 | 238 | return (int) round(pow(pow($distanceX, 2) + pow($distanceY, 2), 0.5)); |
| 239 | 239 | |