@@ -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) |
@@ -281,7 +281,7 @@ |
||
281 | 281 | |
282 | 282 | // all rings (LineStrings) have to be valid itself |
283 | 283 | /** |
284 | - * @var \geoPHP\Geometry\LineString $ring |
|
284 | + * @var \geoPHP\Geometry\LineString $ring |
|
285 | 285 | */ |
286 | 286 | foreach ($this->components as $ring) { |
287 | 287 | if ($ring->isEmpty()) { |
@@ -290,7 +290,7 @@ |
||
290 | 290 | if (!$ring->isValid()) { |
291 | 291 | return false; |
292 | 292 | } |
293 | - $wkt = str_ireplace(['LINESTRING(',')'], '', $ring->asText()); |
|
293 | + $wkt = str_ireplace(['LINESTRING(', ')'], '', $ring->asText()); |
|
294 | 294 | $pts = array_unique(array_map('trim', explode(',', $wkt))); |
295 | 295 | if (count($pts) < 3) { |
296 | 296 | return false; |
@@ -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 |
@@ -120,10 +120,8 @@ |
||
120 | 120 | public function boundary(): Geometry |
121 | 121 | { |
122 | 122 | return $this->isEmpty() ? |
123 | - new LineString() : |
|
124 | - ($this->isClosed() ? |
|
125 | - new MultiPoint() : |
|
126 | - new MultiPoint([$this->startPoint(), $this->endPoint()]) |
|
123 | + new LineString() : ($this->isClosed() ? |
|
124 | + new MultiPoint() : new MultiPoint([$this->startPoint(), $this->endPoint()]) |
|
127 | 125 | ); |
128 | 126 | } |
129 | 127 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function read(string $gpx, array $allowedElements = []): Geometry |
68 | 68 | { |
69 | 69 | // Converts XML tags to lower-case (DOMDocument functions are case sensitive) |
70 | - $gpx = preg_replace_callback("/(<\/?\w+)(.*?>)/", function ($m) { |
|
70 | + $gpx = preg_replace_callback("/(<\/?\w+)(.*?>)/", function($m) { |
|
71 | 71 | return strtolower($m[1]) . $m[2]; |
72 | 72 | }, $gpx); |
73 | 73 | |
@@ -217,14 +217,13 @@ discard block |
||
217 | 217 | $points[] = $this->parsePoint($trkpt); |
218 | 218 | } |
219 | 219 | // Avoids creating invalid LineString |
220 | - if (count($points)>1) { |
|
220 | + if (count($points) > 1) { |
|
221 | 221 | $segments[] = new LineString($points); |
222 | 222 | } |
223 | 223 | } |
224 | 224 | if (!empty($segments)) { |
225 | 225 | $track = count($segments) === 1 ? |
226 | - $segments[0] : |
|
227 | - new MultiLineString($segments); |
|
226 | + $segments[0] : new MultiLineString($segments); |
|
228 | 227 | $track->setData($this->parseNodeProperties($trk, $this->gpxTypes->get('trkType'))); |
229 | 228 | $track->setData('gpxType', 'track'); |
230 | 229 | $tracks[] = $track; |
@@ -440,7 +439,7 @@ discard block |
||
440 | 439 | { |
441 | 440 | $metadata = self::processGeometryData($geometry, $this->gpxTypes->get('metadataType')); |
442 | 441 | $metadata = empty($metadata) || !in_array('metadataType', $this->gpxTypes->get('gpxType')) ? |
443 | - '' : "<metadata>\n" . $metadata. "</metadata>\n\n"; |
|
442 | + '' : "<metadata>\n" . $metadata . "</metadata>\n\n"; |
|
444 | 443 | $wayPoints = $routes = $tracks = ""; |
445 | 444 | |
446 | 445 | foreach ($geometry->getComponents() as $component) { |
@@ -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 | } |
@@ -544,7 +544,7 @@ |
||
544 | 544 | { |
545 | 545 | /** @noinspection PhpUnusedParameterInspection */ |
546 | 546 | set_error_handler( |
547 | - function ($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
547 | + function($errNO, $errStr, $errFile, $errLine, $errContext) { |
|
548 | 548 | if (isset($errContext['http_response_header'])) { |
549 | 549 | foreach ($errContext['http_response_header'] as $line) { |
550 | 550 | 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 | /** |