@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | $y = 0; |
80 | 80 | $length = 0.0; |
81 | 81 | $points = $this->getPoints(); |
82 | - $numPoints = count($points)-1; |
|
83 | - for ($i=0; $i<$numPoints; ++$i) { |
|
82 | + $numPoints = count($points) - 1; |
|
83 | + for ($i = 0; $i < $numPoints; ++$i) { |
|
84 | 84 | $currX = $points[$i]->getX(); |
85 | 85 | $currY = $points[$i]->getY(); |
86 | - $nextX = $points[$i+1]->getX(); |
|
87 | - $nextY = $points[$i+1]->getY(); |
|
86 | + $nextX = $points[$i + 1]->getX(); |
|
87 | + $nextY = $points[$i + 1]->getY(); |
|
88 | 88 | |
89 | 89 | $dx = $nextX - $currX; |
90 | 90 | $dy = $nextY - $currY; |
91 | - $segmentLength = sqrt($dx*$dx + $dy*$dy); |
|
91 | + $segmentLength = sqrt($dx * $dx + $dy * $dy); |
|
92 | 92 | $length += $segmentLength; |
93 | 93 | $x += ($currX + $nextX) / 2 * $segmentLength; |
94 | 94 | $y += ($currY + $nextY) / 2 * $segmentLength; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | |
115 | 115 | $length = 0.0; |
116 | 116 | $points = $this->getPoints(); |
117 | - $numPoints = count($points)-1; |
|
118 | - for ($i=0; $i<$numPoints; ++$i) { |
|
117 | + $numPoints = count($points) - 1; |
|
118 | + for ($i = 0; $i < $numPoints; ++$i) { |
|
119 | 119 | $length += sqrt( |
120 | - pow(($points[$i]->getX() - $points[$i+1]->getX()), 2) + |
|
121 | - pow(($points[$i]->getY() - $points[$i+1]->getY()), 2) |
|
120 | + pow(($points[$i]->getX() - $points[$i + 1]->getX()), 2) + |
|
121 | + pow(($points[$i]->getY() - $points[$i + 1]->getY()), 2) |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | $C = $f / 16 * $cosSqAlpha * (4 + $f * (4 - 3 * $cosSqAlpha)); |
271 | 271 | $lambdaP = $lambda; |
272 | 272 | $lambda = $L + (1 - $C) * $f * $sinAlpha * |
273 | - ($sigma + $C * $sinSigma * ($cos2SigmaM + $C * $cosSigma * (- 1 + 2 * $cos2SigmaM * $cos2SigmaM))); |
|
273 | + ($sigma + $C * $sinSigma * ($cos2SigmaM + $C * $cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM))); |
|
274 | 274 | } while (abs($lambda - $lambdaP) > 1e-12 && --$iterationLimit > 0); |
275 | 275 | if ($iterationLimit == 0) { |
276 | 276 | return 0.0; // not converging |
277 | 277 | } |
278 | 278 | $uSq = $cosSqAlpha * ($a * $a - $b * $b) / ($b * $b); |
279 | - $A = 1 + $uSq / 16384 * (4096 + $uSq * (- 768 + $uSq * (320 - 175 * $uSq))); |
|
280 | - $B = $uSq / 1024 * (256 + $uSq * (- 128 + $uSq * (74 - 47 * $uSq))); |
|
279 | + $A = 1 + $uSq / 16384 * (4096 + $uSq * (-768 + $uSq * (320 - 175 * $uSq))); |
|
280 | + $B = $uSq / 1024 * (256 + $uSq * (-128 + $uSq * (74 - 47 * $uSq))); |
|
281 | 281 | $deltaSigma = $B * $sinSigma * ($cos2SigmaM + $B / 4 * |
282 | 282 | ($cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM) - $B / 6 |
283 | 283 | * $cos2SigmaM * (-3 + 4 * $sinSigma * $sinSigma) |
@@ -51,8 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | } else { |
53 | 53 | $componentType = gettype($components[$i]) !== 'object' ? |
54 | - gettype($components[$i]) : |
|
55 | - get_class($components[$i]); |
|
54 | + gettype($components[$i]) : get_class($components[$i]); |
|
56 | 55 | |
57 | 56 | throw new InvalidGeometryException( |
58 | 57 | 'Cannot create a collection of ' . $componentType . ' components, ' . |
@@ -250,9 +250,9 @@ |
||
250 | 250 | public function equals(Geometry $geometry): bool |
251 | 251 | { |
252 | 252 | return $geometry->geometryType() === Geometry::POINT |
253 | - ? ( abs(($this->getX()??0) - ($geometry->getX()??0)) <= 1.0E-9 && |
|
254 | - abs(($this->getY()??0) - ($geometry->getY()??0)) <= 1.0E-9 && |
|
255 | - abs(($this->getZ()??0) - ($geometry->getZ()??0)) <= 1.0E-9) |
|
253 | + ? (abs(($this->getX() ?? 0) - ($geometry->getX() ?? 0)) <= 1.0E-9 && |
|
254 | + abs(($this->getY() ?? 0) - ($geometry->getY() ?? 0)) <= 1.0E-9 && |
|
255 | + abs(($this->getZ() ?? 0) - ($geometry->getZ() ?? 0)) <= 1.0E-9) |
|
256 | 256 | : false; |
257 | 257 | } |
258 | 258 |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * MULTIPOINT (1 2, 3 4) |
199 | 199 | */ |
200 | 200 | foreach (explode(',', $dataString) as $part) { |
201 | - $points[] = $this->parsePoint(trim($part, ' ()')); |
|
201 | + $points[] = $this->parsePoint(trim($part, ' ()')); |
|
202 | 202 | } |
203 | 203 | return new MultiPoint($points); |
204 | 204 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $m = []; |
219 | 219 | if (preg_match_all('/(\([^(]+?\)|EMPTY)/', $dataString, $m)) { |
220 | 220 | foreach ($m[1] as $part) { |
221 | - $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
221 | + $lines[] = $this->parseLineString(trim($part, ' ()')); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return new MultiLineString($lines); |
@@ -548,7 +548,7 @@ |
||
548 | 548 | if (isset($errContext['http_response_header'])) { |
549 | 549 | foreach ($errContext['http_response_header'] as $line) { |
550 | 550 | if (strpos($line, 'Error: ') > -1) { |
551 | - throw new \Exception($line); |
|
551 | + throw new \Exception($line); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $lon = null; |
98 | 98 | |
99 | 99 | /** @var \DOMElement $node */ |
100 | - if($node->attributes !== null) { |
|
100 | + if ($node->attributes !== null) { |
|
101 | 101 | $lat = $node->attributes->getNamedItem('lat')->nodeValue; |
102 | 102 | $lon = $node->attributes->getNamedItem('lon')->nodeValue; |
103 | 103 | $nodeId = intval($node->attributes->getNamedItem('id')->nodeValue); |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | $wayId = 0; |
129 | 129 | foreach ($this->xmlObj->getElementsByTagName('way') as $way) { |
130 | 130 | /** @var \DOMElement $way */ |
131 | - if($way->attributes !== null) { |
|
131 | + if ($way->attributes !== null) { |
|
132 | 132 | $wayId = intval($way->attributes->getNamedItem('id')->nodeValue); |
133 | 133 | } else { |
134 | 134 | ++$wayId; |
135 | 135 | } |
136 | 136 | $wayNodes = []; |
137 | 137 | foreach ($way->getElementsByTagName('nd') as $node) { |
138 | - if($node->attributes === null) { |
|
138 | + if ($node->attributes === null) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | $ref = intval($node->attributes->getNamedItem('ref')->nodeValue); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | { |
578 | 578 | /** @noinspection PhpUnusedParameterInspection */ |
579 | 579 | set_error_handler( |
580 | - function ($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
580 | + function($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
581 | 581 | if (isset($errContext['http_response_header'])) { |
582 | 582 | foreach ($errContext['http_response_header'] as $line) { |
583 | 583 | if (strpos($line, 'Error: ') > -1) { |
@@ -104,8 +104,7 @@ |
||
104 | 104 | { |
105 | 105 | $bin = fread($this->buffer, $length); |
106 | 106 | return $this->isLittleEndian() ? |
107 | - array_values(unpack("d*", $bin)) : |
|
108 | - array_reverse(unpack("d*", strrev($bin))); |
|
107 | + array_values(unpack("d*", $bin)) : array_reverse(unpack("d*", strrev($bin))); |
|
109 | 108 | } |
110 | 109 | |
111 | 110 | /** |
@@ -189,8 +189,7 @@ |
||
189 | 189 | return new Point($coordinates[0], $coordinates[1]); |
190 | 190 | case 3: |
191 | 191 | return $this->hasZ ? |
192 | - new Point($coordinates[0], $coordinates[1], $coordinates[2]) : |
|
193 | - new Point($coordinates[0], $coordinates[1], null, $coordinates[2]); |
|
192 | + new Point($coordinates[0], $coordinates[1], $coordinates[2]) : new Point($coordinates[0], $coordinates[1], null, $coordinates[2]); |
|
194 | 193 | case 4: |
195 | 194 | return new Point($coordinates[0], $coordinates[1], $coordinates[2], $coordinates[3]); |
196 | 195 | } |
@@ -112,8 +112,7 @@ |
||
112 | 112 | |
113 | 113 | // The document does not have a placemark, try to create a valid geometry from the root element |
114 | 114 | $nodeName = $this->xmlObject->documentElement->nodeName === 'multigeometry' ? |
115 | - 'geometrycollection' : |
|
116 | - $this->xmlObject->documentElement->nodeName; |
|
115 | + 'geometrycollection' : $this->xmlObject->documentElement->nodeName; |
|
117 | 116 | |
118 | 117 | if (array_key_exists($nodeName, geoPHP::getGeometryList())) { |
119 | 118 | $function = 'parse' . geoPHP::getGeometryList()[$nodeName]; |
@@ -365,7 +365,7 @@ |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | // First char is a tab, space or carriage-return. trim it and try again |
368 | - if (in_array($bytes[1], [9,10,32], true)) { |
|
368 | + if (in_array($bytes[1], [9, 10, 32], true)) { |
|
369 | 369 | $input = ltrim($input); |
370 | 370 | return geoPHP::detectFormat($input); |
371 | 371 | } |